mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
BUG Prevent failover / extensions interfering with composite field properties (#7988)
This commit is contained in:
parent
ff7e9e5d8e
commit
be8287fef8
@ -25,7 +25,6 @@ use SilverStripe\ORM\Queries\SQLSelect;
|
||||
*/
|
||||
abstract class DBComposite extends DBField
|
||||
{
|
||||
|
||||
/**
|
||||
* Similiar to {@link DataObject::$db},
|
||||
* holds an array of composite field names.
|
||||
@ -44,6 +43,27 @@ abstract class DBComposite extends DBField
|
||||
*/
|
||||
protected $record = array();
|
||||
|
||||
public function __set($property, $value)
|
||||
{
|
||||
// Prevent failover / extensions from hijacking composite field setters
|
||||
// by intentionally avoiding hasMethod()
|
||||
if ($this->hasField($property) && !method_exists($this, "set$property")) {
|
||||
$this->setField($property, $value);
|
||||
return;
|
||||
}
|
||||
parent::__set($property, $value);
|
||||
}
|
||||
|
||||
public function __get($property)
|
||||
{
|
||||
// Prevent failover / extensions from hijacking composite field getters
|
||||
// by intentionally avoiding hasMethod()
|
||||
if ($this->hasField($property) && !method_exists($this, "get$property")) {
|
||||
return $this->getField($property);
|
||||
}
|
||||
return parent::__get($property);
|
||||
}
|
||||
|
||||
/**
|
||||
* Write all nested fields into a manipulation
|
||||
*
|
||||
@ -243,7 +263,7 @@ abstract class DBComposite extends DBField
|
||||
// Non-db fields get assigned as normal properties
|
||||
if (!$this->hasField($field)) {
|
||||
parent::setField($field, $value);
|
||||
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user