1
0
mirror of https://github.com/processwire/processwire.git synced 2025-08-13 18:24:57 +02:00

Minor tweaks in WireHooks, ProcessForgotPassword and SessionLoginThrottle

This commit is contained in:
Ryan Cramer
2019-12-20 15:06:57 -05:00
parent a11403b913
commit 9a9bdb464a
3 changed files with 26 additions and 7 deletions

View File

@@ -783,6 +783,16 @@ class WireHooks {
$cancelHooks = false;
$profiler = $this->wire->wire('profiler');
$hooks = null;
$methodExists = false;
if($type === 'method') {
$methodExists = method_exists($object, $realMethod);
if(!$methodExists && method_exists($object, $method)) {
// non-hookable method exists, indicating we may be in a manually called runHooks()
$methodExists = true;
$realMethod = $method;
}
}
if(is_array($type)) {
// array of hooks to run provided in $type argument
@@ -793,12 +803,12 @@ class WireHooks {
$result = array(
'return' => null,
'numHooksRun' => 0,
'methodExists' => ($type === 'method' ? method_exists($object, $realMethod) : false),
'methodExists' => $methodExists,
'replace' => false,
);
if($type === 'method' || $type === 'property' || $type === 'either') {
if(!$result['methodExists'] && !$this->isHookedOrParents($object, $method, $type)) {
if(!$methodExists && !$this->isHookedOrParents($object, $method, $type)) {
return $result; // exit quickly when we can
}
}
@@ -809,7 +819,7 @@ class WireHooks {
if($type === 'method') {
if($when === 'after' && $result['replace'] !== true) {
if($result['methodExists']) {
if($methodExists) {
$result['return'] = $object->_callMethod($realMethod, $arguments);
} else {
$result['return'] = null;