Skip to content

Node.js based forum software built for the modern web

fix missing callback

barisusakli11236bb841d2
diff --git a/src/plugins/hooks.js b/src/plugins/hooks.js
index 5bd2ba459e..3e0bdcc848 100644
--- a/src/plugins/hooks.js
+++ b/src/plugins/hooks.js
@@ -14,17 +14,17 @@ module.exports = function(Plugins) {
`data.priority`, the relative priority of the method when it is eventually called (default: 10)
*/
Plugins.registerHook = function(id, data, callback) {
+ callback = callback || function() {};
function register() {
Plugins.loadedHooks[data.hook] = Plugins.loadedHooks[data.hook] || [];
Plugins.loadedHooks[data.hook].push(data);
- if (typeof callback === 'function') {
- callback();
- }
+ callback();
}
if (!data.hook) {
- return winston.warn('[plugins/' + id + '] registerHook called with invalid data.hook', data);
+ winston.warn('[plugins/' + id + '] registerHook called with invalid data.hook', data);
+ return callback();
}
var method;
@@ -69,6 +69,7 @@ module.exports = function(Plugins) {
register();
} else {
winston.warn('[plugins/' + id + '] Hook method mismatch: ' + data.hook + ' => ' + data.method);
+ return callback();
}
}
};