There's some sort of weird interaction with bootstrap and references_dialog theming of action links. With core bartik no issues. After switching to bootstrap any node with a references_dialog widget can't be edited (maintenance error page displays instead) and results in the following watchdog entry:

Recoverable fatal error: Argument 3 passed to l() must be an array, string given, called in C:\inetpub\xxx\includes\theme.inc on line 1737 and defined in l() (line 2426 of C:\inetpub\xxx\includes\common.inc).

I've traced it down to the info added to the links array processed by theme_links. The bartik array looks like this:

while the bootstrap array looks like this:

It barfs on the non-null icon_position item that has a value of "before" when looping through the array with foreach ($links as $key => $link) in theme_links. I guess it safely ignores null items but I'm confused as to why there's a mixture of indexed and associative array items being processed with a foreach $index => $value loop in core to begin with. Seems like that's asking for trouble like this.

I have no clue what the proper way to fix it is yet, but a work around is to override core's theme_links in the bootstrap subtheme's template.php file and adding the following line right after the foreach ($links as $key => $link):

    foreach ($links as $key => $link) {
      if (!is_integer($key)) continue; //temp fix
      $class = array($key);

      // Add first, last and active classes to the list of links to help out themers.
      if ($i == 1) {
        $class[] = 'first';
      }
      if ($i == $num_links) {
        $class[] = 'last';
      }
      if (isset($link['href']) && ($link['href'] == $_GET['q'] || ($link['href'] == '<front>' && drupal_is_front_page())) && (empty($link['language']) || $link['language']->language == $language_url->language)) {
        $class[] = 'active';
      }
      $output .= '<li' . drupal_attributes(array('class' => $class)) . '>';
....

Anyway, I just wanted to get this posted in case anyone else stumbles across it-- took quite a bit debugging to figure out. I'll try to figure out a proper fix when I get a change.

In the meantime, suggestions would be welcome ;-)

Comments

markhalliwell’s picture

Project: Bootstrap » References dialog
Version: 7.x-3.x-dev » 7.x-1.x-dev

This isn't a Bootstrap base-theme issue. We're not overriding theme_links() in any way, we're just adding the .list-inline class when appropriate: http://cgit.drupalcode.org/bootstrap/tree/templates/system/links.vars.php.

From http://cgit.drupalcode.org/references_dialog/tree/references_dialog.modu...

function theme_references_dialog_links($links) {
  return theme('links', array('links' => $links, 'attributes' => array('class' => 'references-dialog-links')));
}

This module is not using the theme system API properly. It is arbitrarily passing the argument $links (which should actually be $variables btw) directly as the links parameter to the theme_links() hook. This will, of course, blow up. $variables can include various items (including some added by base-themes).

This is what theme_links() expects as it's links parameter:

  • links: An associative array of links to be themed. The key for each link
    is used as its CSS class. Each link should be itself an array, with the
    following elements:
    • title: The link text.
    • href: The link URL. If omitted, the 'title' is shown as a plain text
      item in the links list.
    • html: (optional) Whether or not 'title' is HTML. If set, the title
      will not be passed through check_plain().
    • attributes: (optional) Attributes for the anchor, or for the <span>
      tag used in its place if no 'href' is supplied. If element 'class' is
      included, it must be an array of one or more class names.

    If the 'href' element is supplied, the entire link array is passed to
    l() as its $options parameter.

WorldFallz’s picture

Thanks for the excellent description Mark! Now that I know where/what the bug is, I can submit a patch for it.

WorldFallz’s picture

This should do it.

markhalliwell’s picture

Status: Active » Needs work
  1. +++ b/references_dialog.module
    @@ -326,7 +326,7 @@ function references_dialog_process_widget(&$element) {
    -    $element['#suffix'] = '<div class="dialog-links ' . $element['#id'] . '">' . theme('references_dialog_links', $dialog_links) . '</div>';
    +    $element['#suffix'] = '<div class="dialog-links ' . $element['#id'] . '">' . theme('references_dialog_links', array('links' => $dialog_links)) . '</div>';
    

    This is correct. However there is one other place this needs to happen as well:
    http://cgit.drupalcode.org/references_dialog/tree/references_dialog.modu...

  2. +++ b/references_dialog.module
    @@ -696,8 +696,8 @@ function references_dialog_get_admin_path($entity_type, $op, $bundle = NULL, $en
    +  return theme('links', array('links' => $variables['links'], 'attributes' => array('class' => 'references-dialog-links')));
    

    FYI, classes should always be inside an array:

    array('class' => array('references-dialog-links'))
    
WorldFallz’s picture

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

Thanks for the review, I can't believe I missed those. Updated patch attached.

markhalliwell’s picture

Status: Needs review » Reviewed & tested by the community

Looks good to me, simple and straightforward.

socialnicheguru’s picture

could this be related: https://www.drupal.org/node/1978118
(long shot but thought I'd mention it since this issue arises from 'some sort of weird interaction'.)

vacilando’s picture

Bumped into this problem today right after updating from Drupal 7.32 to 7.33. Applied to patch and the problem went away!

Could someone please commit this to dev?

designerbrent’s picture

This works perfectly to fix the problem. Would love to see this patch committed.

natemow’s picture

Re-rolled patch for beta1 release if anyone needs that instead.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 10: references_dialog_fix_theme_links-2315905-10.patch, failed testing.

acrosman’s picture

Status: Needs work » Reviewed & tested by the community

Looks like the patch in #10 is build from site root instead of the module root.

The patch in #5 applies just fine to the Beta1 release; I don't think it needed any re-rolling.

Setting back to reviewed by community in reference to patch from 5.

markhalliwell’s picture

anybody’s picture

The patch works fine and I can confirm it solves the issue.

I'll be happy when the new stable version is released. :)

gmclelland’s picture

The patch in #5 fixes the "Recoverable fatal error" I was getting when I tried to edit nodes after upgrading from 7.32 to 7.33.

morganl’s picture

Priority: Normal » Critical
morganl’s picture

This bug prevents sites from upgrading to Drupal 7.34, a security issue release. Please push a patch to the stable revision ASAP. Thanks!

rp7’s picture

Patch works. Get this in ASAP please.

jesss’s picture

The patch in #5 works for me. Please commit!

achton’s picture

The patch in #5 did not apply cleanly for me on beta1 (contrary to some comments above). And the reroll in #10 is not correctly formatted. So here's a new patch for beta1, which applies cleanly (I'm using an archaic version of Drush Make here, YMMV).

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 20: references_dialog_beta1-fix_theme_links-2315905-20.patch, failed testing.

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 20: references_dialog_beta1-fix_theme_links-2315905-20.patch, failed testing.

markhalliwell’s picture

Status: Needs work » Reviewed & tested by the community

Patches should always be against the latest HEAD (7.x-x.x branch, -dev), which is why the patch in #20 is failing tests. The patch in #5 should get committed.

achton’s picture

Hmm, ok - I was trying to decipher the output from the bots and expected it to fail at "Detect a non-applicable patch" like with the patch in #10. Sorry 'bout the detour!

kristen pol’s picture

RTBC++ Thanks, WorldFallz!!!!!!!

WorldFallz’s picture

And thanks for Mark for mentoring me through this fix! Now to get it committed... I'm willing to be a comaintainer if necessary....

wroxbox’s picture

Fixes the errors. Makes Node/add edit forms again usable. Thanks @WorldFallz

damienmckenna’s picture

Issue tags: +core incompatibility

I couldn't find another tag for indicating a compatibility problem with specific core releases, so this'll have to do.

morganl’s picture

Note: This affects 7.x-1.0-beta1 as well, not just 7.x-1.x-dev.

markhalliwell’s picture

-_- it affects everything, this issue/patch hasn't been committed to anything yet. 7.x-1.x-dev is just the repo's HEAD (aka: latest code) which is what patches should be applied to: https://www.drupal.org/patch/create

I have contacted both maintainers asking them to take action here.

morganl’s picture

Thank you, Mark.

fmitchell’s picture

If you're still getting this issue after applying the patch to either beta1 or 7.x-dev, it is also because you are probably running <= PHP 5.3 per https://www.drupal.org/node/2379771.

Upgrading to > PHP 5.3 (PHP 5.5 in my case) fixed the issue. If that is not an option, try applying the core patch referenced in the link or wait until 7.35 is released assuming that patch is included.

markhalliwell’s picture

nicxvan’s picture

I applied this patch, I'm not seeing any results though.

rogical’s picture

@WorldFallz, I've added you as a maintainer, thanks!

  • WorldFallz committed ef71913 on 7.x-1.x
    Issue #2315905 by WorldFallz, achton, natemow, Mark Carver: Recoverable...
WorldFallz’s picture

Thanks for the vote of confidence rogical! I've committed this patch to dev. I plan to go through the issue queue and commit any other patches that are essentially RTBC'd before tagging a new official release.

WorldFallz’s picture

Status: Reviewed & tested by the community » Fixed

almost forgot... yay!

Status: Fixed » Closed (fixed)

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

Steven Merrill’s picture

This may not be correct; let me double-check.

Argus’s picture

This issue is closed (Fixed), why do you post a patch?

morganl’s picture

What's the process to get this patch pushed to 7.x-1.0 (not just dev)?

damienmckenna’s picture

@MorganL: Wait for the maintainers to release a new version, or join as a new maintainer and help them get there.

damienmckenna’s picture

@MorganL: Please move the discussion into #2414479: {META] Plan for References Dialog v7.x-1.0 release for what can be done to get v1.0 out the door.

morganl’s picture