From cadc02b63b1f8248a5518e202da6f948ffa5064e Mon Sep 17 00:00:00 2001 From: Patrick Nelson Date: Tue, 28 Apr 2015 15:41:19 -0400 Subject: [PATCH] FIX for #4129: Ensure belongsToComponent() and hasManyComponent() methods return null instead of false, to be consistent with other relation component methods. --- model/DataObject.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/model/DataObject.php b/model/DataObject.php index f1ad7825a..951ad2080 100644 --- a/model/DataObject.php +++ b/model/DataObject.php @@ -1857,7 +1857,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity * @param string $component * @param bool $classOnly If this is TRUE, than any has_many relationships in the form "ClassName.Field" will have * the field data stripped off. It defaults to TRUE. - * @return string|false + * @return string|null */ public function belongsToComponent($component, $classOnly = true) { $belongsTo = (array)Config::inst()->get($this->class, 'belongs_to', Config::INHERITED); @@ -1865,7 +1865,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity if($belongsTo && array_key_exists($component, $belongsTo)) { $belongsTo = $belongsTo[$component]; } else { - return false; + return null; } return ($classOnly) ? preg_replace('/(.+)?\..+/', '$1', $belongsTo) : $belongsTo; @@ -1955,7 +1955,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity * @param string $component * @param bool $classOnly If this is TRUE, than any has_many relationships in the form "ClassName.Field" will have * the field data stripped off. It defaults to TRUE. - * @return string|false + * @return string|null */ public function hasManyComponent($component, $classOnly = true) { $hasMany = (array)Config::inst()->get($this->class, 'has_many', Config::INHERITED); @@ -1963,7 +1963,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity if($hasMany && array_key_exists($component, $hasMany)) { $hasMany = $hasMany[$component]; } else { - return false; + return null; } return ($classOnly) ? preg_replace('/(.+)?\..+/', '$1', $hasMany) : $hasMany;