mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-03 13:58:55 +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
|
// composite keys
|
||||||
|
|
||||||
// ensure keys of $this->link are prefixed the same way as $attributes
|
// ensure keys of $this->link are prefixed the same way as $attributes
|
||||||
$prefixedLink = array_combine(
|
$prefixedLink = array_combine($attributes, $this->link);
|
||||||
$attributes,
|
|
||||||
array_values($this->link)
|
|
||||||
);
|
|
||||||
foreach ($models as $model) {
|
foreach ($models as $model) {
|
||||||
$v = [];
|
$v = [];
|
||||||
foreach ($prefixedLink as $attribute => $link) {
|
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.');
|
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
|
if (is_array($foreignModel->$fk)) { // relation via array valued attribute
|
||||||
$foreignModel->$fk = array_merge($foreignModel->$fk, [$value]);
|
$foreignModel->{$fk}[] = $value;
|
||||||
} else {
|
} else {
|
||||||
$foreignModel->$fk = $value;
|
$foreignModel->{$fk} = $value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$foreignModel->save(false);
|
$foreignModel->save(false);
|
||||||
|
|||||||
Reference in New Issue
Block a user