Release 7x-2.12 (at issue submission time not available in the version field) causes a drupal_pre_render_link error. Message says
Notice: Undefined index #title at line 5770 ... drupal_pre_render_link

The odd thing was that the error didn't show up immediately. Some four hours after the update, the error occurred.

Apart from the error code, all non-link titles on rules actions (Loop, Conditional) disappeared.

Reverting to 7x-2..11 erased the error.

Comments

Leiph created an issue. See original summary.

Leiph’s picture

Title: Release 7.12 causes a drupal_pre_render_link error » Release 7.x-2.12 causes a drupal_pre_render_link error
Issue summary: View changes

Typos in the versions fixed.

tr’s picture

Version: 7.x-2.11 » 7.x-2.x-dev
Priority: Major » Normal

Yes, I can confirm. This issue started showing up in the logs on my test site on 18 Jan. The three Rules commits between then and the release can't possibly have caused this (one is documentation comments only, one is hook_uninstall() only, and one only affects rules debug messages shown when you have debugging turned on).

I'll have to spend some quality time with git bisect to see what caused this.

This causes a PHP notice in the logs coupled with some missing text only in the Rules Admin UI. As far as I can tell everything still works and nothing is visible to site users. So classifying this as "normal" for now.

tr’s picture

OK, the cause of this was the patch in #2993473: #type 'markup' removed, committed to Rules on 17 August 2018.

If you are having this problem, you can revert that patch. Here's how:

  1. Download https://www.drupal.org/files/issues/2018-08-17/markup.patch
  2. cd to your rules directory
  3. patch -p1 -R < markup.patch
  4. Clear your Drupal caches

This will fix the problem, and it won't have any bad side-effects.

I'll investigate further and commit a proper fix.

I don't know why that patch would cause a problem because #type=>markup was removed from Drupal core 6 years ago, so #type=>markup use by contributed modules like Rules should be ignored. That was the whole point of the patch, to remove three lines of code that had been obsolete for 6 years. See the Drupal core change notice #type 'markup' removed for more information.

tr’s picture

Status: Active » Needs review
StatusFileSize
new562 bytes

Only one line of that previous patch caused the problem. This new patch restores that one line and should fix any issues.

Please test.

tr’s picture

StatusFileSize
new1.44 KB
new1.99 KB

And here's a test case to verify this works and to ensure this doesn't inadvertently get broken in the future.

The first patch is just the test, without the fix. This test should FAIL, demonstrating the reported bug and showing that the test will detect this error.

The second patch is the test PLUS the fix from#5. This test should PASS, demonstrating the fix works.

The last submitted patch, 6: 3028444-6-test-only.patch, failed testing. View results

tr’s picture

Testing results in #6 are as expected.

Would like confirmation from the community that this fixes the problem for you. @Leiph ?

tory-w’s picture

Confirming patch 6 works.

Along with the "drupal_pre_render_link error", it knocked out my "Conditionals" with Conditional Rules and this patch fixes that as well.

  • TR committed d3fcc26 on 7.x-2.x
    Issue #3028444 by TR: Notice: Undefined index #title at line 5770 ......
tr’s picture

Title: Release 7.x-2.12 causes a drupal_pre_render_link error » Notice: Undefined index #title at line 5770 ... drupal_pre_render_link
Assigned: Unassigned » tr
Status: Needs review » Fixed

Thanks for confirming that @tory-w !

Committed the fix + test from #6 with a few added lines of comments.

bassplaya’s picture

I can confirm too.
Big thanks @TR!
Using version = "7.x-2.12", the patch "3028444-6-markup-and-test.patch" worked for me too and just like with @tory-w, the conditional titles reappeared.

Leiph’s picture

Sorry for late reply, but nevertheless: Thanks @TR! /Leiph

sgdev’s picture

Thanks @TR, cross posting that this has also been reported in the Rules Conditional issue queue.

parasolx’s picture

I also confirm that patch #6 solved problem in my production site.

phily’s picture

Patch #6 is OK for me running Rules 7.x-2.12 and Drupal 7.64
Thanks

delacosta456’s picture

hi
patch #6 OK for me too on Panopoly distro 7.x-1.60 based on D7,63

Many thanks

Status: Fixed » Closed (fixed)

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

web226’s picture

Patch #6 3028444-6-markup-and-test.patch Works for me too with Rules 7.x-2.12, Drupal 7.64 and PHP 7.2

kingandy’s picture

"I don't know why that patch would cause a problem because #type=>markup was removed from Drupal core 6 years ago"

Just for completeness I'll note that the problem was caused because at the point '#type' is set to 'markup', the element already has a '#type' ('link'). Not resetting the #type meant Drupal was still trying to render this element as a link.

An alternative to setting #type=>markup would be to unset the #type property, or redeclare the element entirely ($content['label'] = array('#markup' => check_plain($content['label']['#title']));).

Note however that #type=>markup is still part of the FAPI. Though it's optional, there's no harm in explicitly declaring it.

bluehead’s picture

#6 solves the problem.

marco.b’s picture

#6 worked for me.

The Text was at the top of a reaction rule config page:
> Notice: Undefined index: #title in /includes/common.inc on line 5775

arx-e’s picture

deleted

arx-e’s picture

StatusFileSize
new14.76 KB
tr’s picture

@arx-e: Dude, you've been using Drupal for > 11 years, and you still don't understand how the issue queue works? #3 confirmed this as a bug. #4 provided a workaround. #10 showed that the fix was committed to Rules - that was almost 10 MONTHS ago. So use the latest -dev and clear your caches, or apply the patch in #6 and clear your caches. Regardless, this was already fixed and there are tests proving it was fixed.

arx-e’s picture

I am terribly sorry man! I had a development copy open in different tabs and I was testing in the wrong tab!!!

@TR I am using the latest dev and of course I have cleared all caches and I still see the error message in almost every page load when editing rules.
I have tried the interim solutions just in case some other change had been introduced into the dev version after the commit.