I just got a déjà vu.

I would swear that this module has been working... but recently it wasn't, and checking the code I've found that the following check is wrong!

  if ($arg[0] == 'admin' && $arg[1] == 'content' && $arg[2] == 'node-type' && !empty($arg[3])) {

The third argument in the path has always been 'types' (not 'node-type'), so I don't understand how is it possible that the module has been working.

The check for $arg[2] should look like this:

  if ($arg[0] == 'admin' && $arg[1] == 'content' && $arg[2] == 'types' && !empty($arg[3])) {

Is it me that I've been dreaming? ...anyway, I'll commit this fix, but wait a few days to see if there's some feedback.

Comments

markus_petrux’s picture

Title: Wrong checking of content type paths » Extend checking of content type paths to support strange thing performed by admin_menu
Status: Active » Fixed

Ahah! I got it. It is the admin_menu that changes the content type paths... for a reason I don't quite get, yet.

Here's the code in admin_menu_menu_alter() that does this change:

        // For any reason, content-type menu items are registered individually
        // in Drupal core, but also by CCK. We a) have to copy and re-assign
        // them the proper router path and b) turn their parent items from
        // MENU_CALLBACK into something visible; otherwise, the menu system
        // does not find the parents and relocates child items to the top-level.
        if (strpos($path, 'admin/content/node-type/') === 0) {
          // Fix router path.
          $newpath = strtr($path, array('/node-type/' => '/types/'));
          $items[$newpath] = $items[$path];
          // Alter item type and visibility.
          $items[$newpath]['type'] &= ~MENU_CALLBACK;
          if ($items[$newpath]['type'] === 0) {
            $items[$newpath]['type'] |= MENU_NORMAL_ITEM;
          }
          // Use new item from here, but leave old intact to play nice with
          // others.
          $path = $newpath;
          $item = $items[$newpath];
        }

So the correct check for $arg[2] would have to look like this:

  if ($arg[0] == 'admin' && $arg[1] == 'content' && in_array($arg[2], array('types', 'node-type')) && !empty($arg[3])) {

Let's accept the fact that admin_menu needs to perform this change. I'm wondering this does not generate other conflicts somewhere else.

Committed to CVS.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.