Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Currently, _menu_append_contextual_items()
starts like:
foreach ($menu_item_list as $item) {
if (isset($item['callback'])) {
$_menu['callbacks'][$item['path']] = array('callback' => $item['callback']);
if (isset($item['callback arguments'])) {
$_menu['callbacks'][$item['path']]['callback arguments'] = $item['callback arguments'];
}
unset($item['callback arguments']);
unset($item['callback']);
However, it doesn't seem useful to unset these variables if they're not set. Hence a potential minor optimization avoids this useless code:
foreach ($menu_item_list as $item) {
if (isset($item['callback'])) {
$_menu['callbacks'][$item['path']] = array('callback' => $item['callback']);
if (isset($item['callback arguments'])) {
$_menu['callbacks'][$item['path']]['callback arguments'] = $item['callback arguments'];
unset($item['callback arguments']);
unset($item['callback']);
}
The same seems to apply in _menu_build
. The suggested patch modifies both.
Comment | File | Size | Author |
---|---|---|---|
#4 | menu.inc_9.patch | 1.36 KB | fgm |
menu.inc_8.patch | 1.3 KB | fgm | |
Comments
Comment #1
fgm(forgot to set status)
Comment #2
Dries CreditAttribution: Dries commentedThe spaces look wrong? Did you properly intend the code (no tabs)? Otherwise looks good. :)
Comment #3
chx CreditAttribution: chx commentedComment #4
fgmIndeed, incorrect explanation. Here is the fix, with the missing closing brace reinstated:
Patch rerolled just to be sure.
Comment #5
fgmAnd, someday, I won't miss the core indenting conventions:
Comment #6
Dries CreditAttribution: Dries commentedThanks fgm. Committed your patch to CVS HEAD. Keep it coming. :)
Comment #7
(not verified) CreditAttribution: commented