Posted by Wesley Tanaka on January 15, 2007 at 11:00am
| Project: | Drupal core |
| Version: | 5.x-dev |
| Component: | theme system |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed (fixed) |
Issue Summary
I believe this notice appears the first time I visit a 5.0rc2 site from a given browser as the anonymous user, but I haven't yet investigated further.
Comments
#1
It appears that theme_get_function (where init_theme() is getting called) is passed 'placeholder'?
#2
In case it makes a difference, I have xdebug installed (which has its own pretty printing error handler)
The notice:
Notice: Undefined property: stdClass::$theme in ...../theme.inc on line 45
is being produced by drupal's error_handler() function while it was trying to tell me about some other warning. Something like the following module should be able to reproduce the bug if you go to the 'bug109459' path without any arguments. That produces a "missing function argument" warning, which then gets overridden by the described notice.
function mymodule_menu()
{
return array(
array('path' => 'bug109459',
'title' => t('something'),
'callback' => '_mycallback',
'access' => user_access('access content')),
);
}
function _mycallback($input)
{
include dirname(__FILE__).'/somefile.inc.php';
return callback($input);
}
#3
I am experiencing the same problem although it is while running the cron using wget. I am not getting it with anonymous users just from the cron.
#4
Oh... and I am getting this error with the release version of drupal 5.0.
#5
I have the same error with Drupal 5.1. No clue what triggered it.
But, I also lost all views content. The view content disappeared at the same time the error appeared. How could these be related?
I resaved and even redesigned some views, but they still don't show any content.
#6
The "Undefined property: stdClass::$theme" error message appear when activating the textimage plugin.
When this is desabled, no error.
#7
Well, if in the "background" directory (textimage), we have a file bg.JPG, the error is there.
If the file name is bg.jpg (lowercase), the error is gone.
Hope this helps.
Have no idea howto submit this bug on the textimage (ifthere is the problem), since is no textimage in the dropdown list.
Hope somebody can forward to the right developer.
Thanks.
#8
+1 > I am getting this error too. Seems to be around a file not found... but better error reporting on this one would be much more helpful
#9
We had this issue when registering new users. Check your `sequences` table. We had a dev Drupal DB with maybe 20 users. Then imported 300 users from our amember db, and went live. At this point, `uid` shot up to over 300, but internally, Drupal was up to around 30 in the `sequences` table. This was problematic. We updated `sequences` to 1 higher than our highest `uid`, and now all is well.
#10
I had this when migrating an installation.
Probably not getting to the root of this problems, but changing line 45 to
$theme = isset($user->theme) && $user->theme && $themes[$user->theme]->status ? $user->theme : variable_get('theme_default', 'garland');did the trick for me
#11
The change in #10 works as advertised.
#12
It appears to happen when an error occurs.
Here is a stack trace produced by manually triggering an E_USER_NOTICE in a custom module:
Notice: Undefined property: stdClass::$theme in /home/dr/www/drupal/includes/theme.inc on line 45
Because this error happens from within the error handler, it does not invoke the error handler again. Instead PHP just sends the error message to the user (if the display_errors ini setting is true) and writes a line in the error log.
When this error occured, $user contained the following:
object(stdClass)#2 (5) {["uid"]=>
int(0)
["hostname"]=>
string(14) "192.168.10.188"
["roles"]=>
array(1) {
[1]=>
string(14) "anonymous user"
}
["session"]=>
string(0) ""
["cache"]=>
int(0)
}
I also sometimes get another error in the same method, "Trying to get property of non-object" in theme.inc line 58 (this line reads:
if (strpos($themes[$theme]->filename, '.css')) {), but that may be unrelated to this issue.#13
Better solution is in bootstrap.inc on line 828 change function drupal_anonymous_user() to:
function drupal_anonymous_user($session = '') {$user = new stdClass();
$user->uid = 0;
$user->hostname = $_SERVER['REMOTE_ADDR'];
$user->roles = array();
$user->roles[DRUPAL_ANONYMOUS_RID] = 'anonymous user';
$user->session = $session;
$user->cache = 0;
$user->data = NULL;
$user->theme = NULL;
return $user;
}
Add variable $data and $theme.
#14
Since when 5.X is notice free?
#15
5.X isn't notice free, but almost all notices are muted by the built-in error handler (in common.inc). The error described in this issue is one of the few that are not caught by the error handler (because it happens after the error handler has kicked in due to another error).
#16
Well, then let's try fixing it, adding to the anonymous user is a good idea, but theme and data needs to be the empty string, not NULL .
#17
Doesn't this just need a back port? It's fixed in D6.
http://api.drupal.org/api/function/init_theme/6
#18
Committed to 5.x.
Please keep backport patches in the same original issue in the future.
#19
I believe it was part of a bigger patch and due to the huge theming changes, it got overlooked.
#20
Automatically closed -- issue fixed for two weeks with no activity.
#21
This problem still exists with Drupal 5.7, in my case only when using Opera or Konqueror (KDE4) on my site.
Using Firefox did NOT reproduce the error - which is definitly strange.
The patch seem to cure the problem.
#22
@suit4 - This patch was committed to 5.x-dev after 5.7 was released, it will be included in 5.8 and later releases.
#23
asimmonds thanks for the notification!
#24
Just to let you know: I got the same error message in a 5.7 install when I used a custom module where I called
in_array('user role',$user->roles). I forgot to setglobal $user;before. When I did, the message didn't show anymore.#25
I had the very same problem.
Here's the problem as well as the solution :)
http://drupal.org/node/277798
#26
FWIW, I was able to resolve this error message by clearing the views cache.
I think the message itself may be a symptom of a large number of different possible problems...
#27
The change in #10 works as advertised.
BTW .. This is just a symptom of other problems. (in our case views cache).
But it's also a symptom of bad coding habits in drupal.
I've seen this happening in many place. Using arrays/objects/elements without ever checking if it contains data.
In Java you'd get NullPointerExceptions which should ALWAYS be catched, in PHP you'll get these strange errors.
ps. Note to myself: 'Make sure that I do what i've evangelized' :)