Page MenuHomePhabricator

Improve error handling for hook functions.
Open, MediumPublic

Description

There should be a "fail safe" variant of wfRunHooks (resp Hooks::run) which would catch, log and ignore any exception thrown by a hook function.

THis could be implemented using an optional parameter to Hooks::run which takes an ExceptionHandler object. ExceptionHandler::handleException( Exception $ex ) would return a bool that determins whether the hook should be continued (just like regular hook functions do).

The implementation used per default would just rethrow the exception. An alternative implementation could log the error using wfLogWarning, and then continue (by returning true) or abort (by returning false).

This is more convenient, and allows better control, than just wrapping wfRunHooks in try/catch everywhere.


Version: 1.23.0
Severity: normal
See Also:
https://bugzilla.wikimedia.org/show_bug.cgi?id=64604

Details

Reference
bz63481