mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-02 04:37:42 +08:00
[minor] SCA (#16464)
* Php Inspections (EA Ultimate): new findings * Php Inspections (EA Ultimate): dealing with older PHP versions compatibility
This commit is contained in:
committed by
Alexander Makarov
parent
e55b3e0ba1
commit
84c55b468a
@ -504,10 +504,7 @@ trait ActiveRelationTrait
|
||||
// composite keys
|
||||
|
||||
// ensure keys of $this->link are prefixed the same way as $attributes
|
||||
$prefixedLink = array_combine(
|
||||
$attributes,
|
||||
array_values($this->link)
|
||||
);
|
||||
$prefixedLink = array_combine($attributes, $this->link);
|
||||
foreach ($models as $model) {
|
||||
$v = [];
|
||||
foreach ($prefixedLink as $attribute => $link) {
|
||||
|
||||
@ -1572,9 +1572,9 @@ abstract class BaseActiveRecord extends Model implements ActiveRecordInterface
|
||||
throw new InvalidCallException('Unable to link models: the primary key of ' . get_class($primaryModel) . ' is null.');
|
||||
}
|
||||
if (is_array($foreignModel->$fk)) { // relation via array valued attribute
|
||||
$foreignModel->$fk = array_merge($foreignModel->$fk, [$value]);
|
||||
$foreignModel->{$fk}[] = $value;
|
||||
} else {
|
||||
$foreignModel->$fk = $value;
|
||||
$foreignModel->{$fk} = $value;
|
||||
}
|
||||
}
|
||||
$foreignModel->save(false);
|
||||
|
||||
Reference in New Issue
Block a user