Problem/Motivation

Admin menu was recently updated with the issue #2084217: Make field_ui_admin_menu_map() actually work for all entity types. The Field UI mapping is now included by default and does not have to be added in the Node registration hook_admin_menu_map().

Currently this results in a notice:

Proposed resolution

Remove the mapping of fields from hook_admin_menu_map()

Remaining tasks

  • Write a patch
  • Review

User interface changes

None

API changes

None

Comments

idebr’s picture

Status: Active » Needs review
StatusFileSize
new1.1 KB

Attached patch removes the duplicate Field mapping from hook_admin_menu_map().

rudiedirkx’s picture

Wow, that is seriously bad from admin_menu. Obviously all kinds of modules will have implemented this hook. And now it'll be doubled, because suddenly they do it automatically!? But with another function name!?

What about all the nice people that don't have admin_menu-edge?

rudiedirkx’s picture

Is there a way we can 'ask' admin_menu if they already provide the relevant info? Apparently it's not the same function name. I don't want to check version. Other ideas? If not, is there an info alter hook, so we can check if it exists and maybe add it there?

rudiedirkx’s picture

Status: Needs review » Needs work

Looks like there is an alter: http://cgit.drupalcode.org/admin_menu/tree/admin_menu.inc

Whoever makes a patch to still support old admin_menu users, gets a cookie.

idebr’s picture

Yes, admin_menu should have checked for duplicate values. The issue was included in the latest stable release 7.x-3.0-rc5. I would argue the amount of people running the latest Node registration but not admin_menu is not worth the hook. They will only miss a small feature. Either way, I guess I won't be getting that cookie :(

idebr’s picture

Fieldable Panels Panes solved this issue by checking the admin map before adding their own items. This seems like a decent workaround. #2146479: Conflict with Administration menu

  • rudiedirkx committed 40b3456 on 7.x-1.x authored by idebr
    Issue #2407359 by idebr: Remove field mapping from hook_admin_menu_map...
rudiedirkx’s picture

I agree. This hook for NR isn't even in a stable release, so nobody'll miss it. Just me =(

rudiedirkx’s picture

NR dev + admin_menu rc5 doesn't produce a nice admin menu for me though... The generated mapping is quite different from the custom.

Ide, you have commit access =) Fix it.

dpfitzsi’s picture

I've worked on a patch that appears to work (I tested on latest dev and moving back and forth between admin_menu-7.x-3.0-rc4 and rc5. I have added map_alter for older releases so they will still get the menu under structure.

dpfitzsi’s picture

Status: Needs work » Needs review
rudiedirkx’s picture

Status: Needs review » Needs work

I think the patch failed... Lots of white space flaws and where does $admin_path come from? Also, why a hook map AND a hook map alter? Just the alter will do to add stuff if it doesn't exist yet. Or is that the funky patch too?

Why doesn't admin_menu rc5 work with NR items?? Isn't that what they've added supposedly!?

dpfitzsi’s picture

Ok, I'll get those issues fixed and update the patch. I was following the example from davereid to use both, but the alter may do on its own.

dpfitzsi’s picture

Status: Needs work » Needs review
StatusFileSize
new1.32 KB

New patch attached.

rudiedirkx’s picture

Status: Needs review » Needs work

Where does $path come from? I get a bunch of these:

Notice: Undefined variable: path in node_registration_admin_menu_map_alter() (line 504 of node_registration.module).

No rush. I'm creating a new release without admin menu mapping.

dpfitzsi’s picture

Woops, I had missed readding some the code I originally had under the map() in my first patch. The variable $path is now defined. I have retested on rc4 and rc5 and the menu renders on both versions without an error.

dpfitzsi’s picture

Status: Needs work » Needs review
rudiedirkx’s picture

Title: Remove field mapping from hook_admin_menu_map(). Warning: strtr() expects parameter 1 to be string, array given in admin_menu_tree() » Support field mapping for Admin Menu to make all relevant NR Field menu links available
Category: Bug report » Feature request
Status: Needs review » Needs work

I'm sorry, that's just not good enough. Admin Menu adds a map for admin/structure/node_registration/manage/%node_registration_type/fields/%field_ui_menu, which apparently doen't do anything, and then NR adds a map for admin/structure/node_registration/manage/%node_registration_type, which does half (it adds only 1 level, no fields/display).

Plus, the code is weird. What's up with this:

    $arguments = array(
      '%node_registration_type' => array($type),
      '%field_ui_menu' => $fields,
    );
    if (!empty($arguments)) {
      $map["$path/fields/%field_ui_menu"]['parent'] = "$path/fields";
      $map["$path/fields/%field_ui_menu"]['arguments'][] = $arguments;
    }

Of course $arguments is not empty...

Some version soon Admin Menu will 'fix' this weirdness, and NR has to do another update to facilitate. I won't. Not to add 1 level of admin menu.

You can keep working on it until you're satisfied, but I won't be spending much more time on it. I'm sorry you did and now I'm not doing anything with it. We'll blame @idebr for bringing it up =)