mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 08:36:12 +01:00
fix: push back some deprecations, remove deprecated stuff scheduled for v1.18.0
This commit is contained in:
@@ -324,7 +324,7 @@ Emailer.sendToEmail = async (template, email, language, params) => {
|
||||
!Plugins.hooks.hasListeners('static:email.send');
|
||||
try {
|
||||
if (Plugins.hooks.hasListeners('filter:email.send')) {
|
||||
// Deprecated, remove in v1.18.0
|
||||
// Deprecated, remove in v1.19.0
|
||||
await Plugins.hooks.fire('filter:email.send', data);
|
||||
} else if (Plugins.hooks.hasListeners('static:email.send')) {
|
||||
await Plugins.hooks.fire('static:email.send', data);
|
||||
|
||||
@@ -82,7 +82,7 @@ module.exports = function (middleware) {
|
||||
return !res.headersSent;
|
||||
}
|
||||
|
||||
// TODO: Remove in v1.18.0
|
||||
// TODO: Remove in v1.19.0
|
||||
middleware.authenticate = helpers.try(async (req, res, next) => {
|
||||
winston.warn(`[middleware] middleware.authenticate has been deprecated, page and API routes are now automatically authenticated via setup(Page|API)Route. Use middleware.authenticateRequest (if not using route helper) and middleware.ensureLoggedIn instead. (request path: ${req.path})`);
|
||||
if (!await authenticate(req, res)) {
|
||||
@@ -101,7 +101,7 @@ module.exports = function (middleware) {
|
||||
next();
|
||||
});
|
||||
|
||||
// TODO: Remove in v1.18.0
|
||||
// TODO: Remove in v1.19.0
|
||||
middleware.authenticateOrGuest = (req, res, next) => {
|
||||
winston.warn(`[middleware] middleware.authenticateOrGuest has been renamed, use middleware.authenticateRequest instead. (request path: ${req.path})`);
|
||||
middleware.authenticateRequest(req, res, next);
|
||||
|
||||
@@ -8,7 +8,7 @@ const utils = require('../utils');
|
||||
const Hooks = module.exports;
|
||||
|
||||
Hooks.deprecatedHooks = {
|
||||
'filter:email.send': 'static:email.send', // 👋 @ 1.18.0
|
||||
'filter:email.send': 'static:email.send', // 👋 @ 1.19.0
|
||||
'filter:router.page': 'response:router.page', // 👋 @ 2.0.0
|
||||
};
|
||||
|
||||
|
||||
@@ -25,23 +25,6 @@ require('./usage')(Plugins);
|
||||
Plugins.data = require('./data');
|
||||
Plugins.hooks = require('./hooks');
|
||||
|
||||
// Backwards compatibility for hooks, remove in v1.18.0
|
||||
const _deprecate = async function (...args) {
|
||||
const oldMethod = args.shift();
|
||||
const newMethod = args.shift();
|
||||
const method = args.shift();
|
||||
const stack = new Error().stack.toString().split(os.EOL);
|
||||
const context = stack[stack.findIndex(line => line.startsWith(' at Object.wrapperCallback')) + 1];
|
||||
winston.warn(`[plugins/hooks] ${oldMethod} has been deprecated, call ${newMethod} instead.`);
|
||||
winston.warn(`[plugins/hooks] ${context}`);
|
||||
return method.apply(Plugins.hooks, args);
|
||||
};
|
||||
Plugins.registerHook = _deprecate.bind(null, 'Plugins.registerHook', 'Plugins.hooks.register', Plugins.hooks.register);
|
||||
Plugins.unregisterHook = _deprecate.bind(null, 'Plugins.unregisterHook', 'Plugins.hooks.unregister', Plugins.hooks.unregister);
|
||||
Plugins.fireHook = _deprecate.bind(null, 'Plugins.fireHook', 'Plugins.hooks.fire', Plugins.hooks.fire);
|
||||
Plugins.hasListeners = _deprecate.bind(null, 'Plugins.hasListeners', 'Plugins.hooks.hasListeners', Plugins.hooks.hasListeners);
|
||||
// end
|
||||
|
||||
Plugins.getPluginPaths = Plugins.data.getPluginPaths;
|
||||
Plugins.loadPluginInfo = Plugins.data.loadPluginInfo;
|
||||
|
||||
|
||||
@@ -9,20 +9,3 @@ privileges.posts = require('./posts');
|
||||
privileges.users = require('./users');
|
||||
|
||||
require('../promisify')(privileges);
|
||||
|
||||
// TODO: backwards compatibility remove in 1.18.0
|
||||
[
|
||||
'privilegeLabels',
|
||||
'userPrivilegeList',
|
||||
'groupPrivilegeList',
|
||||
'privilegeList',
|
||||
].forEach((fieldName) => {
|
||||
Object.defineProperty(privileges, fieldName, {
|
||||
configurable: true,
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
console.warn(`[deprecated] privileges.${fieldName} is deprecated. Use privileges.categories.${fieldName}`);
|
||||
return privileges.categories[fieldName];
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user