Skip to content

Commit 7ef91c1

Browse files
committed
Use array_key_last()
- see OpenMage#4111 (comment)
1 parent 759d160 commit 7ef91c1

File tree

2 files changed

+6
-8
lines changed
  • app/code/core/Mage/Adminhtml

2 files changed

+6
-8
lines changed

app/code/core/Mage/Adminhtml/Block/Page/Menu.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -164,10 +164,9 @@ protected function _buildMenuArray(Varien_Simplexml_Element $parent, $path = '',
164164

165165
uasort($parentArr, [$this, '_sortMenu']);
166166

167-
foreach (array_keys($parentArr) as $key) {
168-
$last = $key;
169-
}
170-
if (isset($last)) {
167+
$last = array_key_last($parentArr);
168+
169+
if (!is_null($last)) {
171170
$parentArr[$last]['last'] = true;
172171
}
173172

app/code/core/Mage/Adminhtml/Model/System/Config/Source/Admin/Page.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,9 @@ protected function _buildMenuArray(?Varien_Simplexml_Element $parent = null, $pa
109109

110110
uasort($parentArr, [$this, '_sortMenu']);
111111

112-
foreach (array_keys($parentArr) as $key) {
113-
$last = $key;
114-
}
115-
if (isset($last)) {
112+
$last = array_key_last($parentArr);
113+
114+
if (!is_null($last)) {
116115
$parentArr[$last]['last'] = true;
117116
}
118117

0 commit comments

Comments
 (0)