MDL-72329 core: Persistent method get needs to return correct type
This commit is contained in:
@@ -143,7 +143,18 @@ abstract class persistent {
|
||||
if (method_exists($this, $methodname)) {
|
||||
return $this->$methodname();
|
||||
}
|
||||
return $this->raw_get($property);
|
||||
|
||||
$properties = static::properties_definition();
|
||||
// If property can be NULL and value is NULL it needs to return null.
|
||||
if ($properties[$property]['null'] === NULL_ALLOWED && $this->raw_get($property) === null) {
|
||||
return null;
|
||||
}
|
||||
// Deliberately cast boolean types as such, because clean_param will cast them to integer.
|
||||
if ($properties[$property]['type'] === PARAM_BOOL) {
|
||||
return (bool)$this->raw_get($property);
|
||||
}
|
||||
|
||||
return clean_param($this->raw_get($property), $properties[$property]['type']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user