Every time I try to install module, or clear the cache, or run update.php I get the 500 Internal Server Error page, and in the report log the following:
"Trying to get property of non-object in _drupal_session_write() (line 178 of C:\Data\Production\drupalConnection\includes\session.inc)."

That message is written to the log every time one of those actions is attempted. The code around line 178 of that session.inc is:
"if ($is_changed || !isset($user->timestamp) || REQUEST_TIME - $user->timestamp > variable_get('session_write_interval', 180)) {
// Either ssid or sid or both will be added from $key below.
$fields = array(
'uid' => $user->uid,
'cache' => isset($user->cache) ? $user->cache : 0,
'hostname' => ip_address(),
'session' => $value,
'timestamp' => REQUEST_TIME,
);
"

This is on our production server. The report log shows that error back to about the time of the 7.23 core update, and not before. The odd things though, the 7.23 core is also installed on our Beta server, which doesn't have the problem at all.

Any ideas what might be causing this?

Comments

marcingy’s picture

Category: bug » support
Priority: Major » Normal
roberto.s’s picture

I've experienced a similar problem. The problem was, in one of the functions I used a global variable

global $user

and later in that same function the variable $user got overwritten:

<del>$user = 'something';</del>

Using different variable name solved the problem. Hope this helps.

mohmmadalabed’s picture

Issue summary: View changes

#2 works!

Version: 7.23 » 7.x-dev

Core issues are now filed against the dev versions where changes will be made. Document the specific release you are using in your issue comment. More information about choosing a version.

Status: Active » Closed (outdated)

Automatically closed because Drupal 7 security and bugfix support has ended as of 5 January 2025. If the issue verifiably applies to later versions, please reopen with details and update the version.