mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
BUGFIX: DBComposite doesn't allow arbitrary property assignment
To be more consistent with `ViewableData`, whose `setField()` method will fallback on [assigning properties arbitrarily](https://github.com/silverstripe/silverstripe-framework/blob/4/src/View/ViewableData.php#L213), `DBComposite` shouldn't bail out of `setField` when the field specified isn't in the record. Arbitrary property assignment is particularly important in injection. ```yaml SilverStripe\ORM\FieldType\DBComposite: dependencies: myService: %$Service ``` Right now, that fails, because `$obj->myService = Service` invokes `__set()` which calls `setField()` which refuses the assignment when `myService`is not in the record.
This commit is contained in:
parent
697798b464
commit
3ef9ca69d1
@ -240,8 +240,9 @@ abstract class DBComposite extends DBField
|
|||||||
{
|
{
|
||||||
$this->objCacheClear();
|
$this->objCacheClear();
|
||||||
|
|
||||||
// Skip non-db fields
|
// Non-db fields get assigned as normal properties
|
||||||
if (!$this->hasField($field)) {
|
if (!$this->hasField($field)) {
|
||||||
|
$this->$field = $value;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user