Skip to content

Commit

Permalink
Fix "Trying to access array offset on value of type null"
Browse files Browse the repository at this point in the history
which occured under PHP 7.4 when for example a layout called getMenu() with an menu id that doesn't exist.

In this case an empty string will be returned or in other words no menu.
  • Loading branch information
blackcoder87 committed Apr 12, 2020
1 parent fd6d113 commit 99eaf54
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions application/libraries/Ilch/Layout/Helper/Menu/Mapper.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* @copyright Ilch 2.0
* @copyright Ilch 2
* @package ilch
*/

Expand Down Expand Up @@ -54,7 +54,6 @@ public function getMenus()
* Gets the menu for the given id.
*
* @param int $menuId
*
* @return \Ilch\Layout\Helper\Menu\Model
*/
public function getMenu($menuId)
Expand All @@ -67,8 +66,10 @@ public function getMenu($menuId)
->execute()
->fetchAssoc();

$menu->setId($menuRow['id']);
$menu->setTitle($menuRow['title']);
if (!empty($menuRow)) {
$menu->setId($menuRow['id']);
$menu->setTitle($menuRow['title']);
}

return $menu;
}
Expand Down

0 comments on commit 99eaf54

Please sign in to comment.