Add a return statement to MenuLinkManager::menuNameInUse and correct the return value of MenuTreeStorage::menuNameInUse

Created on 30 May 2016, over 8 years ago
Updated 23 January 2024, 12 months ago

Problem/Motivation

The return statement is missing in MenuLinkManager::menuNameInUse , in /core/lib/Drupal/Core/Menu/MenuLinkManager.php

  public function menuNameInUse($menu_name) {
    $this->treeStorage->menuNameInUse($menu_name);
  }

The function menuNameInUse in core/lib/Drupal/Core/Menu/MenuTreeStorage.php will always return true

public function menuNameInUse($menu_name) {
    $query = $this->connection->select($this->table, NULL, $this->options);
    $query->addField($this->table, 'mlid');
    $query->condition('menu_name', $menu_name);
    $query->range(0, 1);
    return (bool) $this->safeExecuteSelect($query);
  }

Proposed resolution

The fix would be just adding 'return'

  public function menuNameInUse($menu_name) {
    return $this->treeStorage->menuNameInUse($menu_name);
  }

Remaining tasks

Waiting for review

API changes

core/lib/Drupal/Core/Menu/MenuLinkManager.php method menuNameInUse will return bool.
core/lib/Drupal/Core/Menu/MenuTreeStorage.php method menuNameInUse will return bool.

Data model changes

NA

Release notes snippet

NA

πŸ› Bug report
Status

Needs work

Version

11.0 πŸ”₯

Component
Menu systemΒ  β†’

Last updated 1 day ago

Created by

πŸ‡©πŸ‡ͺGermany ashrafaaref

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024