mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-03 12:36:02 +01:00
fix: deprecated-message not showing for all hooks (#4714)
* fix deprecated hooks params warning + var-cleanup * fix deprecated message
This commit is contained in:
@@ -57,14 +57,16 @@ module.exports = function(Plugins) {
|
|||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
// handle hook's startsWith, i.e. action:homepage.get
|
// handle hook's startsWith, i.e. action:homepage.get
|
||||||
var _parts = data.hook.split(':');
|
var parts = data.hook.split(':');
|
||||||
_parts.pop();
|
if (parts.length > 2) {
|
||||||
var _hook = _parts.join(':');
|
parts.pop();
|
||||||
if (Plugins.deprecatedHooksParams[_hook]) {
|
}
|
||||||
winston.warn('[plugins/' + id + '] Hook `' + _hook + '` parameters: `' + Plugins.deprecatedHooksParams[_hook] + '`, are being deprecated, '
|
var hook = parts.join(':');
|
||||||
+ 'all plugins should now use the `middleware/cls` module instead of hook\'s arguments to get a reference to the `req`, `res` and/or `socket` object(s) (from which you can get the current `uid` if you need to.) '
|
if (Plugins.deprecatedHooksParams[hook]) {
|
||||||
+ '- for more info, visit https://docs.nodebb.org/en/latest/plugins/create.html#getting-a-reference-to-each-request-from-within-any-plugin-hook');
|
winston.warn('[plugins/' + id + '] Hook `' + hook + '` parameters: `' + Plugins.deprecatedHooksParams[hook] + '`, are being deprecated, '
|
||||||
delete Plugins.deprecatedHooksParams[_hook];
|
+ 'all plugins should now use the `middleware/cls` module instead of hook\'s arguments to get a reference to the `http-request` or the `socket-request` object(s) (from which you can get the current `uid` if you need to.) '
|
||||||
|
+ '- for more info, visit https://docs.nodebb.org/en/latest/plugins/create.html#getting-a-reference-to-each-request-from-within-any-plugin-hook\n');
|
||||||
|
delete Plugins.deprecatedHooksParams[hook];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user