Hi.

A user with "Administer mail templates" privileges is receiving this error when attempting to access any of the pages on admin/config/system/mail-edit:

Notice: Undefined index: localized_options in menu_get_active_breadcrumb() (line 2583 of includes/menu.inc).
Recoverable fatal error: Argument 3 passed to l() must be an array, null given, called in includes/menu.inc on line 2583 and defined in l() (line 2345 of includes/common.inc).

User 1 is able to access the pages without an issue. The main page (admin/config/system/mail-edit) comes up, but none of the mail template edit pages works (e.g. admin/config/system/mail-edit/user_cancel_confirm/en) because of the error.

Let me know what I can do to help.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

salvis’s picture

Category: bug » support

This is not a bug. Argument 3 of l() is optional, meaning it may very well be NULL.

Please install the Devel module and enable it's Backtrace error handler, so that we can see the call stack leading up to the error. Post a screenshot of that.

webdrips’s picture

FileSize
290.13 KB

Thanks for looking into this; I've attached the requested screenshot. Side note: I'm getting a 500 error now on the page generating the error:

PHP Fatal error: Unsupported operand types in includes/common.inc on line 2353, referer: http://www.connectinggate.com/admin/config/system/mail-edit

salvis’s picture

Hmm, let's see...

RecoverableFatalError.png

The "Argument 3 passed to l() must be an array" message is really strange. Typically, this is generated by PHP, but if the signature of l() is l($text, $path, array $options = array()) as api.drupal.org claims, then the argument 3 is optional. However, line 2583 in menu.inc is...

    foreach ($active_trail as $parent) {
      $breadcrumb[] = l($parent['title'], $parent['href'], $parent['localized_options']);
    }

... and $parent['localized_options'] us undefined, so NULL is passed (rather than nothing), which leads to the error. We can try to do some more sleuthing.

Temporarily put a dpm($active_trail); above the foreach, open the array by clicking on it and look for an element that does not have any 'localized_options' key. I have no idea where those keys are coming from, but knowing which element in the array is missing may give us some more information.

When I do this on my test installation, I'm seeing an array with five elements, and each one is another array (click to expand), and each of those has a 'localized_options' key. What do you see?

webdrips’s picture

Okay well this is interesting indeed: logged in as UID 1, I see an array of 5 menu items, all containing an array called localized_options with 0 elements. When I log in as the user with the error, I get the same array, but three of the five menu items are missing the localized_options array with 0 elements (thus the null I suppose). (Wouldn't null be fine for a truly optional argument?).

The $active_trail[X]['path'] for three that are missing for the user with errors are:

  1. admin
  2. admin/config
  3. admin/config/system

However, admin/config/system/mail-edit has the empty array. What's even stranger IMO is when I attempt to access any of the above paths as my "problem" user, I get no errors, but I do get an access denied error, leading me to believe that's the reason the arrays are empty for those paths.

Wait it gets stranger...

When I access admin/config/system/mail-edit as my "problem" user, I get an array with only one element (for the home page), BUT when I access the same page as UID 1, I get the expected 4-element array for the active trail...what???

(As a reminder, the problem page is any child page of this page e.g. admin/config/system/mail-edit/user_register_pending_approval/en)

I then ran grep -r localized_options . on my modules directory, and it turns out a bunch of modules may be contributing to this array, but I have a hunch the culprit null passer may be i18n/i18n_menu/i18n_menu.module.

Seems like a bug either in core or that module. What do you think?

salvis’s picture

(Wouldn't null be fine for a truly optional argument?).

No. NULL is not nothing. If nothing is passed, then PHP adds the default value, which is array() in this case (an empty array). An empty array is not the same thing as NULL.

You're on the right track, and this may turn out to be a Mail Edit bug after all.

If your problem user does not have access to the administrative pages, he should not have access to admin/config/system/mail-edit either, because it's an administrative page.

webdrips’s picture

The problem user has the "Administer mail templates", and other privileges I'd classify as UI interfaces shown to the end user, but that's about it.

In other words, I truly do want this user to be able to edit the mail templates. If they are missing some other permission (e.g. "Administer site configuration"), I'm happy to add it for now, but it would seem to defeat the purpose of having the extra permission, plus I'm just not sure I want them to have that permission all the time.

Please let me know if I can provide any other information.

salvis’s picture

Category: support » bug
Status: Active » Fixed

Mail Editor should not give access to admin/config/system/mail-edit to someone who does not have the "Use the administration pages and help" permission. This is a bug in Mail Editor.

ME's "Administer mail templates" even includes the magic word "administer" — this should be enough of a hint that "Use the administration pages and help" is also needed, because it applies to all "Administer something" permissions. Depending on your theme, if you're using an admin theme, "View the administration theme" would probably be useful or even necessary as well. I've added this information to the README.txt file.

The "Use the administration pages and help" has no security implications. There's no reason to not give it to your problem user.

Thank you for your help and perseverance in tracking this down. ME's failure to check the "Use the administration pages and help" permission allowed you to get into a situation where core was not behaving properly. Since you can't normally get there, it's a non-issue for core, so no further action is needed. BTW, I was eventually able to reproduce this error, even without having i18n installed.

I've committed the fix to the D7 and D6 -dev versions.

webdrips’s picture

Ahhhh....you are absolutely correct of course...I didn't have that permission set for that particular role.

I'm more than happy to help...this is another great module and I commend you on being so active in the queue and your prompt replies to this issue.

salvis’s picture

Thanks!

Status: Fixed » Closed (fixed)

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

Zheka’s picture

Status: Closed (fixed) » Needs review
FileSize
2.79 KB

When it is needed to grant access to ONLY template editing, it is not good to grant "Use the administration pages and help" permission. According to your source code this permission is used to build breadcrumbs, which could be absent on this page.
We suggest not to add a forbidden item to breadcrumbs instead of making the whole page not available. This patch implements this. Please review it.

Status: Needs review » Needs work

The last submitted patch, mail_edit-acces-to-edit-template-page-1806944-10.patch, failed testing.

salvis’s picture

Status: Needs work » Closed (fixed)

#11:

This is a closed issue. What makes you think that your comment belongs here?

Please open a new issue.