To replicate change the Menu Title for "My Account" to anything else and click save.

This will change it, but Drupal throws an undefined variable message at you.
user-links-undefined-variable.png

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Jody Lynn’s picture

Great find. I tracked down the problem to an oversight in drupal_valid_path which was introduced in #190867: Remove access check for anonymous users when creating aliases.

marcingy’s picture

Status: Active » Closed (fixed)

This no longer happens on head.

tedfordgif’s picture

Component: menu.module » path.module
Status: Closed (fixed) » Active

The offending code is still in 7.x and 8.x, so the underlying issue is not fixed.


  elseif ($dynamic_allowed && preg_match('/\/\%/', $path)) {
    // Path is dynamic (ie 'user/%'), so check directly against menu_router table.
    if ($item = db_query("SELECT * FROM {menu_router} where path = :path", array(':path' => $path))->fetchAssoc()) {
      $item['link_path']  = $form_item['link_path'];
      $item['link_title'] = $form_item['link_title'];
      $item['external']   = FALSE;
      $item['options'] = '';
      _menu_link_translate($item);

marcingy’s picture

Status: Active » Postponed (maintainer needs more info)

Can you provide steps to replicate then as following the instructions in step one I could not recreate on head. Or a test that will cause the failure.

tedfordgif’s picture

Do you have display of notices turned on in your php.ini? If that doesn't do it, I should be able to write a test -- just call drupal_validate_path('node/%', TRUE);.

Ingmar’s picture

I also have this error...everytime I try to add a menu-item of change one.
The record is written to the database, but it doesn't show in Drupal.

StayingEnPointe.com’s picture

FileSize
46.55 KB

Subscribing!



I'm having the same problem when I try to change the Parent Link of the "My Blog" menu item.

Does anyone know of a work-around for this problem until it's fixed?



Edit: I was able to work around this by editing the DB entries directly, then I had to reload the theme cache by accessing the "Admin/Appearance/" menu.

_KASH_’s picture

Subscribing

_KASH_’s picture

This happens for me if I add a link to the user menu that uses the % to insert the user id to the menu path. For example user/%/bookmarks

_KASH_’s picture

Status: Postponed (maintainer needs more info) » Active

active

grendzy’s picture

Title: User menu undefined variable notice if you change the My Account title » Notice: Undefined variable: form_item in drupal_valid_path
Version: 7.x-dev » 8.x-dev
Status: Active » Needs review
Issue tags: +Needs backport to D7
FileSize
686 bytes

Edit: not sure this is right, _menu_link_translate() might need link_path to have some value...

mefisto75’s picture

same as at #7

xjm’s picture

Status: Needs review » Needs work

Edit: $form_item does not actually appear to be set anywhere.

xjm’s picture

Status: Needs work » Needs review
FileSize
706 bytes

I did a little git detective work and this dates to #151583: Menu - Fixes that make menu module work in D6 in D6, in menu_valid_path(). Back then $form_item was the name of the function's parameter. Since $path is now just a string, the patch is correct. There's no need to override values loaded from the DB and nothing to override them with.

Here's a reroll for core/.

xjm’s picture

D7 version attached for convenience and testing. If you are encountering this problem, please confirm whether applying this patch and clearing your cache resolves the issue.

grendzy’s picture

I'm starting to suspect the whole $dynamic_allowed thing is conceptually flawed. For example, how could drupal_valid_path('node/%', TRUE) possibly be evaluated if the node ID is unknown? The function is expected to check access, and _menu_check_access() needs to have the access arguments. Can anyone shed some light here?

xjm’s picture

#16: I think the answer to that question is outside the scope of this issue? It's not that the nid is not known; it's that it's a part of the pattern. I may be misunderstanding the question, though. :)

The cleanup above should be made regardless, but let's have someone who can reproduce the bug test the patch and confirm whether it resolves the issue, or whether the part of the problem where the menu items are broken persists.

xjm’s picture

xjm’s picture

Also, WRT the sort of tests that need to be added, from the other issue:

For tests I mean that the fact all core tests pass at the moment means we must have no tests in core that cause this hunk to be evaluated to true - if we did then we'd be getting PHP errors.

if ($item = db_query("SELECT * FROM {menu_router} where path = :path", array(':path' => $path))->fetchAssoc()) {

So without tests for that code, if another regression was introduced into this function in the same place, we'd not know, hence it makes sense to add them while fixing this.

xjm’s picture

Status: Needs review » Needs work

Setting NW for tests.

Jody Lynn’s picture

FileSize
1.88 KB

I added a test that adds a dynamic menu item and I can't get it to work.

_menu_link_translate always gives back $item['access'] = FALSE for dynamic paths and I can't make much sense out of that function in general.

So currently it is impossible to add dynamic paths to menus, making this a pretty serious bug.

Jody Lynn’s picture

Title: Notice: Undefined variable: form_item in drupal_valid_path » drupal_valid_path allows fails for dynamic paths
Jody Lynn’s picture

Jody Lynn’s picture

Title: drupal_valid_path allows fails for dynamic paths » drupal_valid_path fails for dynamic paths (e.g. user/% cannot be added to menus)
droplet’s picture

Status: Needs work » Needs review

see what testbot said.

Status: Needs review » Needs work

The last submitted patch, 876580.patch, failed testing.

apaderno’s picture

I still have to understand what the purpose of allowing users to define a menu item with a link containing % is, if drupal_valid_path($path, TRUE) returns TRUE only for tracker/%, between the default paths defined from Drupal.

I tried the following code, and $result is TRUE only when $path is equal to 'tracker/%'.

global $menu_admin;
$menu_admin = TRUE;

if ($item = db_query("SELECT * FROM {menu_router} where path = :path", array(':path' => $path))->fetchAssoc()) {
  $item['link_path']  = $path;
  $item['external']   = FALSE;
  $item['options'] = '';
  _menu_link_translate($item);
}

$menu_admin = FALSE;
$result = ($item && $item['access']);

The first condition necessary for drupal_valid_path() to return TRUE is that the menu item has to_arg functions; the condition is verified for search/node/%, search/user/%, and tracker/%. Between those paths, drupal_valid_path($path, TRUE) returns TRUE only for tracker/%.

YesCT’s picture

TonyK’s picture

This issue is almost 3 years old. Will this ever be fixed in Drupal 7?

dawehner’s picture

FileSize
2.89 KB

It is a huge problem that we need to support both the old and the new routing system at the same time.

Here is a rough outline how to support the new routing system on top of the menu_router bit in drupal_valid_path.

dawehner’s picture

FileSize
3.94 KB

This fixes dynamic paths for the new routing system, but NOT for the old one, see @todo

Elin Yordanov’s picture

Version: 8.x-dev » 7.x-dev

I'm setting the issue back to 7.x.

mradcliffe’s picture

Version: 7.x-dev » 8.x-dev
Status: Needs work » Needs review

I think this needs to be 8.x so #31 can get tested.

Status: Needs review » Needs work

The last submitted patch, path-876580-31.patch, failed testing.

pingers’s picture

Priority: Normal » Major

This is related to #2086559: Adding an invalid path alias shows an exception in the UI, in which a ResourceNotFoundException is causing WSOD.

For this reason, I'm promoting this to major and we should test that aliasing a path such as "admin/invalid" at admin/config/search/path/add does not WSOD.

I'll try to re-roll what's there to catch this Exception. I.e. checking if a path is valid should not cause WSOD.

pingers’s picture

Status: Needs work » Needs review
FileSize
3.94 KB

Okay, here's the re-roll.

Status: Needs review » Needs work
Issue tags: -Needs tests, -Needs backport to D7

The last submitted patch, path-876580-36.patch, failed testing.

tim.plunkett’s picture

Priority: Major » Normal
Issue summary: View changes

Did this work in D6? I can reproduce in D7, meaning that this is not a regression.

David_Rothstein’s picture

Note that #2106129: drupal_valid_path() Notice: Undefined variable: form_item is semi-duplicate of this issue but now has commits for both Drupal 7 and 8. I'm guessing some of this issue is still valid though (especially the tests).

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

apaderno’s picture

Version: 8.6.x-dev » 8.8.x-dev

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.