Add lazy-load guard to detect N+1 relation queries - #591
Open
KalimeroMK wants to merge 7 commits into
Open
KalimeroMK wants to merge 7 commits into
KalimeroMK wants to merge 7 commits into
Annotations
10 warnings and 1 notice
|
Run infection.:
src/AbstractActiveRecord.php#L945
Escaped Mutant for Mutator "ProtectedVisibility":
@@ @@
*
* @see AbstractActiveRecord::update()
*/
- protected function updateInternal(?array $properties = null): int
+ private function updateInternal(?array $properties = null): int
{
if ($this->isNew()) {
throw new InvalidCallException('The record is new and cannot be updated.');
|
|
Run infection.:
src/AbstractActiveRecord.php#L918
Escaped Mutant for Mutator "ProtectedVisibility":
@@ @@
*
* @see AbstractActiveRecord::refresh()
*/
- protected function refreshInternal(array|ActiveRecordInterface|null $record = null): bool
+ private function refreshInternal(array|ActiveRecordInterface|null $record = null): bool
{
if ($record === null || is_array($record)) {
return false;
|
|
Run infection.:
src/AbstractActiveRecord.php#L847
Escaped Mutant for Mutator "ProtectedVisibility":
@@ @@
*
* @see AbstractActiveRecord::delete()
*/
- protected function deleteInternal(): int
+ private function deleteInternal(): int
{
/**
* We don't check the return value of deleteAll() because it is possible the record is already deleted in
|
|
|
|
Run infection.:
src/AbstractActiveRecord.php#L653
Escaped Mutant for Mutator "LogicalNot":
@@ @@
}
}
- if (!$relation->isMultiple()) {
+ if ($relation->isMultiple()) {
unset($this->related[$relationName]);
} elseif (isset($this->related[$relationName]) && is_array($this->related[$relationName])) {
/** @psalm-var array<array-key, ActiveRecordInterface> $related */
|
|
Run infection.:
src/AbstractActiveRecord.php#L487
Escaped Mutant for Mutator "UnwrapArrayIntersectKey":
@@ @@
public function populateProperties(array $values): void
{
- $values = array_intersect_key($values, array_flip($this->propertyNames()));
+ $values = $values;
foreach ($values as $name => $value) {
$this->populateProperty($name, $value);
}
|
|
Run infection.:
src/AbstractActiveRecord.php#L477
Escaped Mutant for Mutator "Identical":
@@ @@
{
if (
isset($this->relationsDependencies[$propertyName])
- && ($value === null || $this->get($propertyName) !== $value)
+ && ($value !== null || $this->get($propertyName) !== $value)
) {
$this->resetDependentRelations($propertyName);
}
|
|
Run infection.:
src/AbstractActiveRecord.php#L456
Escaped Mutant for Mutator "Foreach_":
@@ @@
public function resetRelation(string $name): void
{
- foreach ($this->relationsDependencies as &$relationNames) {
+ foreach ([] as &$relationNames) {
unset($relationNames[$name]);
}
|
|
Run infection.:
src/AbstractActiveRecord.php#L351
Escaped Mutant for Mutator "UnwrapArrayFlip":
@@ @@
}
if ($this->isNew()) {
- $this->bindModels(array_flip($link), $this, $linkModel);
+ $this->bindModels($link, $this, $linkModel);
} else {
$this->bindModels($link, $linkModel, $this);
}
|
|
Run infection.:
src/AbstractActiveRecord.php#L343
Escaped Mutant for Mutator "UnwrapArrayValues":
@@ @@
} else {
$link = $relation->getLink();
$p1 = $linkModel->isPrimaryKey(array_keys($link));
- $p2 = $this->isPrimaryKey(array_values($link));
+ $p2 = $this->isPrimaryKey($link);
if ($p1 && $p2) {
if ($this->isNew() && $linkModel->isNew()) {
|
|
"The ubuntu-latest label will migrate to Ubuntu 26 beginning October 19, 2026. For more information, see https://github.com/actions/runner-images/issues/14748"
|
background
wait
wait-all
cancel
parallel
Loading