After enabling queries logging ($conf['dev_query'] = true) I see PHP notice message:

Notice: Trying to get property of non-object in ...\includes\database.mysqli.inc on line 103

My issue is to change str 103 to:
$name = isset($user->name) ? $user->name : variable_get('anonymous', 'Anonymous');

Comments

gpk’s picture

The original code was:

$name = $user->uid ? $user->name : variable_get('anonymous', 'Anonymous');

Generally global $user exists, except there are perhaps 2 queires during bootstrap before $user is properly instantiated - the first in http://api.drupal.org/api/function/drupal_is_denied/6 and the 2nd (the one used to create $user) in http://api.drupal.org/api/function/sess_read/6.

I'm not sure that these queries should really be attributed to the anon user? But what else to use?

gpk’s picture

Actually it is probably worth having a look at/play with devel.module which is what the query logging functionality was originally aimed at.

Dave Reid’s picture

It should probably be something like the following:

$name = isset($user) && isset($user->uid) ? ($user->uid ? $user->name : variable_get('anonymous', 'Anonymous')) : 'User not loaded';

But that seems...kinda convoluted.

shp’s picture

I'm not sure that these queries should really be attributed to the anon user? But what else to use?

Yes, this 2 bootstrap phases (access & session) passed by all users, if fastpath_cache is not used.

Actually it is probably worth having a look at/play with devel.module which is what the query logging functionality was originally aimed at.

No, I want to have more precise performance info.

shp’s picture

Status: Active » Closed (fixed)
Damien Tournoud’s picture

Version: 6.5 » 6.x-dev
Assigned: shp » Unassigned
Status: Closed (fixed) » Active

I don't believe this bug magically disappeared.

Damien Tournoud’s picture

Title: Notice message » Early bootstrap queries generate notices when query logging is enabled

And clarifying the title.

shp’s picture

Yes, this bug didn't disappeared :) I supposed that if it is not fixed yet, I should to close the issue. So, thank you for hint.

shp’s picture

Assigned: Unassigned » shp
multiplextor’s picture

Status: Active » Closed (won't fix)

Closed. The reason: expired.

jwilson3’s picture

Issue summary: View changes
Status: Closed (won't fix) » Active

How is "expired" a reason to close this issue?

I still have this issue, and actually just filed a separate bug report, which I've now mark as a duplicate of this one:

#2623902: dev_query broken with early db queries

jwilson3’s picture

jwilson3’s picture

Aaaaand another one, that actually has a patch.

#351844: Early mysql queries generate notices when query logging is enabled

FWIW, the patch there is a simplified version of what Dave Reid suggested in comment #3 above.

jwilson3’s picture

Status: Active » Closed (duplicate)

I think we should close this issue, even though it has more followers and comments from respected community members, because #351844 already has a patch, while this one does not. This is so that the person who worked on that patch would get credit were it ever to get committed.

jwilson3’s picture