diff --git a/app/src/Controller/Component/BreadcrumbComponent.php b/app/src/Controller/Component/BreadcrumbComponent.php index 6c6f800e5..9cbc4d82d 100644 --- a/app/src/Controller/Component/BreadcrumbComponent.php +++ b/app/src/Controller/Component/BreadcrumbComponent.php @@ -222,11 +222,9 @@ public function injectPrimaryLink(object $link, bool $index=true, string $linkLa $linkAttr = $link->attr == $modelNameForeignKey ? 'id' : $link->attr; $linkObj = $linkTable ->find() - ->where(["$modelAlias.$linkAttr" => $link->value]); - if ($contain !== null) { - $linkObj = $linkObj->contain($contain); - } - $linkObj = $linkObj->firstOrFail(); + ->where(["$modelAlias.$linkAttr" => $link->value]) + ->contain($contain) + ->firstOrFail(); if($index) { // We need to determine the primary link of the parent, which might or might diff --git a/app/src/Lib/Traits/QueryModificationTrait.php b/app/src/Lib/Traits/QueryModificationTrait.php index 6670ef894..b3aa01cb7 100644 --- a/app/src/Lib/Traits/QueryModificationTrait.php +++ b/app/src/Lib/Traits/QueryModificationTrait.php @@ -35,25 +35,25 @@ trait QueryModificationTrait { // Array of associated models to copy during a duplicate - private $duplicateContains = false; + private array $duplicateContains = []; // Array of associated models to pull during an edit - private $editContains = false; + private array $editContains = []; // Containable models for index actions - private $indexContains = null; + private array $indexContains = []; // Filter (where clause) for index actions - private $indexFilter = null; + private array $indexFilter = []; // Array of associated models to save during a patch - private $patchAssociated = []; + private array $patchAssociated = []; // Array of associated models to pull during a view - private $viewContains = false; + private array $viewContains = []; // Array of associated models to pull during a pick action - private $pickerContains = false; + private array $pickerContains = []; /** @@ -88,7 +88,7 @@ public function checkValidity(Query $query): QueryExpression { * @return array Array of associated models */ - public function getDuplicateContains() { + public function getDuplicateContains(): array { return $this->duplicateContains; } @@ -99,7 +99,7 @@ public function getDuplicateContains() { * @return array Array of associated models */ - public function getEditContains() { + public function getEditContains(): array { return $this->editContains; } @@ -110,7 +110,7 @@ public function getEditContains() { * @param boolean $allowEmpty true if the primary link is permitted to be empty */ - public function getIndexContains() { + public function getIndexContains(): array { return $this->indexContains; } @@ -132,7 +132,7 @@ public function getPatchAssociated() { * @return array Array of associated models */ - public function getPickerContains() { + public function getPickerContains(): array { return $this->pickerContains; } @@ -143,7 +143,7 @@ public function getPickerContains() { * @return array Array of associated models */ - public function getViewContains() { + public function getViewContains(): array { return $this->viewContains; }