This issue happens with PHP 5.0.4, but not with PHP 4.3.11.

Whenever I change a setting from administer > (any module), "changes have been saved" messages and other notifications do not disappear.
I end up with dozens of notifications while changing settings and browsing through drupal modules. Other red error messages stack up as well (even if I fix what they want).

Logging out does not solve the problem.

CommentFileSizeAuthor
#15 bootstrap_14.patch718 bytesTiaan
screenshot_1.jpg42.17 KBPierreM-1
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

PierreM-1’s picture

I may have been unprecise.
Actually, logging out removes the notifications but the problem is still there.

jlangdale’s picture

Title: Notifications does not disappear with PHP 5 » Re: Notifications does not disappear with PHP 5

I upgraded from 4.5, PHP4 to 4.6 and PHP6 yesterday. I am having this same issue with status messages. Messages only go away after logging out.

http://www.langdale.ca:81/drupal
Running:

Darwin 7.9.0 (Mac OS X 10.3.9)
Apache 2.0.54
PHP 5.0.4
Drupal 4.6.0
MySQL 4.0.20 (Standard Darwin 7.3.0 PPC)

Anonymous’s picture

Same problem. Notifications will not go away unless I log out.

Doing a dump of the user variable, I get the following:

public $session = 'messages|a:1:{s:6:"status";a:3:{i:0;s:28:"The changes have been saved.";i:1;s:42:"The configuration options have been saved.";i:2;s:42:"The configuration options have been saved.";}}';

It looks like this never gets set back to an array.

Fedora Core 3
PHP5
Apache2

Robin Monks’s picture

Assigned: Unassigned » Robin Monks

This patch should clear the header after each print-out without using a blank array(), which I believe could cause this:

Index: includes/bootstrap.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/bootstrap.inc,v
retrieving revision 1.46
diff -u -r1.46 bootstrap.inc
--- includes/bootstrap.inc   12 Apr 2005 16:55:11 -0000   1.46
+++ includes/bootstrap.inc   5 May 2005 13:57:54 -0000
 -685,8 +685,8 @@
  */
 function drupal_get_messages() {
   $messages = drupal_set_message();
-  $_SESSION['messages'] = array();
-
+  session_unregister('messages');
+  unset($_SESSION['messages']);
   return $messages;
 }

It might be good for someone who was having this problem to try this patch and see if it does fix the problem.

Robin

killes@www.drop.org’s picture

I don't see how this patch will cure the problem (which I cannot reproduce).

According to the php docs session_unregister() shouldn#t be used with session variables. Oh. and we want attached patches not inlined ones.

kumo’s picture

I've just encountered the same problem. I'm using PHP5.0.4 on Mac OS X Tiger.

I added 'php_value register_long_arrays 1' to Drupal's .htaccess and this cured the problem.

Can someone else try this and see if this works for them?

kumo’s picture

I should have mentioned that I've no idea why the above works and whether it's a Drupal or PHP bug.

Robin Monks’s picture

Assigned: Robin Monks » Unassigned

At any rate, I can't reproduce this. Perhaps it's fixed by another patch?

Robin

TheRoss’s picture

I can duplicate this with Drupal 4.6 and PHP5 (on textdrive.com)

using my .htaccess to force it to use php4 eliminates the problem.

I can provide you with admin access if you would like to test it, contact me at ross@karchner.com

TheRoss’s picture

Here is a PHPinfo of the PHP 5 install that is having this problem:

http://karchner.com/test.php

And the PHP 4 install that isn't

both are using FastCGI, as opposed to mod_php or CGI

TheRoss’s picture

the session_unregister fix worked for me.

danielgm’s picture

Setting register_long_arrays worked for me. Thanks!

wdtj’s picture

Setting register_long_arrays worked for me too. Thanks!

tayknight’s picture

Version: 4.6.0 » 4.6.2

The .htaccess didn't work for me (PHP 5 at Dreamhost). The session_unregister did work. Thanks for the info.

Tiaan’s picture

FileSize
718 bytes

This problem does appear to be a PHP 5 bug (tested with current v.5.0.4), but I have not been able to create an isolated PHP script to log it at http://bugs.php.net and get their opinion. However, the attached Drupal (v.4.6.0 or 4.6.2, likely also for 4.6.1) patch file is a work-around for this issue, and it neither requires enabling the register_long_arrays flag (that messes with the deprecated long $HTTP_*_VARS type predefined variables) nor does it use the session_unregister function (which shouldn't be used with session variables). The modified "bootstrap.inc" file has been tested under both PHP 4.3.9 and 5.0.4, and it seems to work just fine.

Perhaps someone who better understands PHP's reference handling can shed more light on this peculiar work-around. For those that might want to investigate this further, note that the conditional version checking in the modified function is essential for making this code work on both the older and newer PHP versions. The code segment that gets executed under version 5.0+ does not work correctly on PHP 4, but by pure coincidence emulates the PHP 5 bug symptoms under PHP 4. :) Hope this helps.

tayknight’s picture

Tiian. Your patch also worked for me at Dreamhost.

lordslumber’s picture

I was running a fresh install of drupal 4.6.2 on dreamhost with php running as a CGI with PHP version 5 checked, and getting the same bug. Tiaan's patch fixed the problem. Thanks!

jsaints’s picture

The patch is nice, but I think there is something more serious we need to address here. According to my tests, this is not a PHP bug, but a Drupal bug.

I have two drupal 4.6 sites on the same server.

a patched version of 4.6.1 does not have this problem
version 4.6.2 freshly installed is problematic

What changed between the versions that is casing this problem? Can anyone else confirm?

wdtj’s picture

I was having the same bug. I tried regsiter_long_arrays, and that worked for a time but it came back, then tried register_globals, which worked but scared the jeebers out of me.

Applied the patch bootstrap_14_patch and it worked, after I remembered to set the *&^%^% SELinux context right.

I'm running Drupal 4.6.3 with Fedora 4 (PHP 5.0.4 & postgresql 8.0.3).

Dries’s picture

That bootstrap patch is rather ugly.

killes@www.drop.org’s picture

Some discussion revealed that this is possibly a bug in the xtemplate engine or xtemplate based themes. Can the people who have this problem report back?

agentrickard’s picture

I had the same problem on 4.6.3 using PHPTemplate on a fresh install.

Forgive my impudence, but I thought Dries had closed this thread once before?

Has the solution discussed here http://drupal.org/node/33880 been replaced by a better one?

magico’s picture

Status: Active » Closed (fixed)