mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02: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();
|
||||
|
||||
// Skip non-db fields
|
||||
// Non-db fields get assigned as normal properties
|
||||
if (!$this->hasField($field)) {
|
||||
$this->$field = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user