mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
API CHANGE Don't include NULL returns in decorated methods called through Object->extend(), meaning empty method bodies in decorators won't confuse permission checks through $myObj->extend('canView') etc.
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@65451 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
429f81ed14
commit
c30b5812d1
@ -459,19 +459,24 @@ class Object {
|
||||
* originally returned void, so if you wanted to return results, you're hosed.
|
||||
*
|
||||
* Currently returns an array, with an index resulting every time the function is called.
|
||||
* Only adds returns if they're not NULL, to avoid bogus results from methods just
|
||||
* defined on the parent decorator. This is important for permission-checks through
|
||||
* extend, as they use min() to determine if any of the returns is FALSE.
|
||||
* As min() doesn't do type checking, an included NULL return would fail the permission checks.
|
||||
*
|
||||
* @param string $funcName The name of the function.
|
||||
* @param mixed $arg An Argument to be passed to each of the extension functions.
|
||||
*/
|
||||
public function extend($funcName, &$arg=null) {
|
||||
if($this->extension_instances) {
|
||||
$return = array();
|
||||
$returnArr = array();
|
||||
foreach($this->extension_instances as $extension) {
|
||||
if($extension->hasMethod($funcName)) {
|
||||
$return[] = $extension->$funcName($arg);
|
||||
$return = $extension->$funcName($arg);
|
||||
if($return !== NULL) $returnArr[] = $return;
|
||||
}
|
||||
}
|
||||
return $return;
|
||||
return $returnArr;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user