From dd4e66e22c93586d389b47fa197154620508ae8f Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Fri, 3 Sep 2021 12:04:16 -0400 Subject: [PATCH] fix: push back some deprecations, remove deprecated stuff scheduled for v1.18.0 --- src/emailer.js | 2 +- src/middleware/user.js | 4 ++-- src/plugins/hooks.js | 2 +- src/plugins/index.js | 17 ----------------- src/privileges/index.js | 17 ----------------- 5 files changed, 4 insertions(+), 38 deletions(-) diff --git a/src/emailer.js b/src/emailer.js index 0d6e309b0a..754b794c05 100644 --- a/src/emailer.js +++ b/src/emailer.js @@ -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); diff --git a/src/middleware/user.js b/src/middleware/user.js index 4adff804d5..b9f195477e 100644 --- a/src/middleware/user.js +++ b/src/middleware/user.js @@ -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); diff --git a/src/plugins/hooks.js b/src/plugins/hooks.js index d46a1fcdb0..24875ca986 100644 --- a/src/plugins/hooks.js +++ b/src/plugins/hooks.js @@ -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 }; diff --git a/src/plugins/index.js b/src/plugins/index.js index a7e8560dd5..772ec91e19 100644 --- a/src/plugins/index.js +++ b/src/plugins/index.js @@ -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; diff --git a/src/privileges/index.js b/src/privileges/index.js index 4a9c4d2096..6445b07b97 100644 --- a/src/privileges/index.js +++ b/src/privileges/index.js @@ -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]; - }, - }); -});