I've just tried installing Drupal 7 using PHP 5.4. (I installed using Drush, FWIW). When I went to load the site's home page in the browser, I got many errors displayed - all identical.

Notice: Array to string conversion in menu_link_save() (line 3147 of /home/{snip}/includes/menu.inc)

Repeat x 448, if anyone's interested!

Just to clarify, this doesn't happen under PHP 5.3, and I was using the latest 7.x-dev.

The symptoms sound the same as #1423928: Array to string conversion dans menu_link_save() , but that issue did not mention PHP 5.4, and appeared to resolve itself after upgrading to Drupal 7.12, so this sounds like a separate issue.

Comments

webchick’s picture

Status: Active » Closed (duplicate)

This is a duplicate of #1338282: Fix php notice in menu_link_save() I think.

JamesOakley’s picture

Status: Closed (duplicate) » Active
Issue tags: +PHP 5.4

Thanks webchick.

I've now spent a fair bit of time in the issue queue of #1338282: Fix php notice in menu_link_save(), and even offered a patch at #30 of that queue.

I agree that the two issues are related. I'm not sure, however, that they are duplicates. That issue is about menu settings not persisting in particular conditions and is, rightly, prioritised as "normal". It's a wider issue than just PHP 5.4 - it's just that the error becomes visible in PHP 5.4.

This issue here only applies to PHP 5.4, and is a major incompatibility between PHP 5.4 and Drupal 7 (and 8). It's not a critical issue, because (as far as I can tell) Drupal does install correctly. But it's major in that it does not just affect a minority of sites - unless others test to the contrary, it seems that Drupal will not install on PHP 5.4 without throwing 448 identical errors, and you get more of those errors when you try to rebuild the theme registry (so someone has reported to me).

IMHO, fixing this more specific issue is more of a priority than waiting until the wider issue at #1338282: Fix php notice in menu_link_save() can be resolved. Now PHP 5.4 is released, getting Drupal to the point where it can be run on a PHP 5.4 system seems important. At least, even if we can't iron out every pre-existing bug, we want to eliminate new ones that are specific to that PHP version.

That's my view - I look forward to hearing what others think too. (I won't reroll and offer my patch from #30 at #1338282: Fix php notice in menu_link_save() until I hear whether others agree this issue deserves separate treatment. It did seem to fix this specific issue for me, FWIW).

klonos’s picture

Issue tags: -PHP 5.4

While this is somewhat related to the other issue you link to (even the 2-liner patch from #1338282-30: Fix php notice in menu_link_save() fixes this issue here), still this is a separate thing. I might be wrong on this one too, but I think that we should commit that patch in order to fix this issue here. We shouldn't have to wait on the other issue that seems to be more complicated and might take long time to be actually fixed.

klonos’s picture

Issue tags: +PHP 5.4

xpost

droplet’s picture

Version: 7.x-dev » 8.x-dev
Status: Active » Closed (duplicate)

It seems same problem to me. If not, please upload a patch to show us the difference

xjm thinks that needs a test on the patch but as my reply on #31, it's a test cover the errors. Anyone agreed to me could mark it back to RTBC.

C'est la vie

JamesOakley’s picture

Please upload a patch to show us the difference.

That's a fair enough thing to ask for.

However my problem is that I'm not sure I understand the full extent of the issues in #1338282. I'm convinced that (for Drupal 7), the patch in #30 of that queue is sufficient to solve the issue in this queue. I'm convinced that the same patch is necessary to solve the issue in that queue, but it may not be sufficient. That's to say: I'm reluctant to mark #1338282 as RTBC, because I'm not sure that that one change solves the entire menu problem being discussed there.

If you say that it solves the problem, I would certainly agree with you that the purpose of the testbot is not to confirm that the patch works, but to establish it doesn't break anything critical in the process. It's RTBC, after all, not RTB-TestBot.

michaelrajchandra’s picture

I am getting the same problem

My server has Php 5.4

Notice: Array to string conversion in menu_link_save() (line 3155 of /www/users/website.com/includes/menu.inc)

Please help!!!

Is there any new update for the core or the module causing this problem...

I dont know how to use the patch... (Is there any patch installer module)

JamesOakley’s picture

@ZaDeveloper: The fix at #1338282: Fix php notice in menu_link_save() was committed on 12th March 2012. That means that, since that date, Drupal 7.x-dev has that fix applied. It does indeed solve the problem.

That gives you two choices. 1. You could install Drupal 7.x-dev instead of 7.12. If you do that, you also get all the other changes that have been made to Drupal 7 since 7.12 was released (in February). 2. If you don't want all those changes, you can learn how to apply the patch and just make that one alteration. Altering code in Drupal core is usually not recommended, because when Drupal 7.13 comes out your changes will be lost. But that's OK in this case, because 7.13 will include the fix.

If you don't know how to run a patch command (either on your own PC, or on the server), then you can apply the patch by hand. It's the patch at comment #30 that you want at #1338282: Fix php notice in menu_link_save(), which is human-readable. It tells you what file to change, and what lines to change. (The - prefix means "take out this line" and the + prefix means "put this line instead").

klonos’s picture

...yeah, and if James' quick instructions were not clear enough for you, then try Applying a patch manually ;)

chaitanya17’s picture

Issue summary: View changes

I have faced similar issue, after updating Drupal to 7.51 it got fixed.

smartankur4u’s picture

In menu.inc,
replace
if (!$existing_item || (array_intersect_assoc($item, $existing_item)) != $existing_item)

with
if (!$existing_item || (array_intersect_key($item, $existing_item)) != $existing_item)

it works..!!!!!!!!!!

JamesOakley’s picture

@smartankur4u - you're still having this problem? Update to a more recent version of Drupal 7 urgently, or you'll have far bigger problems to tackle.