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.

CommentFileSizeAuthor
#17 init_theme_notice.patch848 bytesdvessel

Comments

Wesley Tanaka’s picture

It appears that theme_get_function (where init_theme() is getting called) is passed 'placeholder'?

Wesley Tanaka’s picture

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);
}
jeffabailey’s picture

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.

jeffabailey’s picture

Oh... and I am getting this error with the release version of drupal 5.0.

hawkdrupal’s picture

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.

TinTin_Pinguin’s picture

Version: 5.0-rc2 » 5.1
Priority: Minor » Normal

The "Undefined property: stdClass::$theme" error message appear when activating the textimage plugin.
When this is desabled, no error.

TinTin_Pinguin’s picture

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.

andjules’s picture

+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

couloir007’s picture

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.

cgfoz’s picture

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

wim leers’s picture

The change in #10 works as advertised.

c960657’s picture

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

  1. init_theme() called at [/home/dr/www/drupal/includes/theme.inc:188]
  2. theme_get_function(placeholder) called at [/home/dr/www/drupal/includes/theme.inc:167]
  3. theme(placeholder, user notice) called at [/home/dr/www/drupal/includes/common.inc:752]
  4. t(%message in %file on line %line., Array ([%error] => user notice,[%message] => This is a dummy error,[%file] => /home/dr/www/drupal/sites/all/modules/foobar/foobar.module,[%line] => 27)) called at [/home/dr/www/drupal/includes/common.inc:564]
  5. error_handler(1024, This is a dummy error, /home/dr/www/drupal/sites/all/modules/foobar/foobar.module, 27, Array ([user] => stdClass Object ([uid] => 0,[hostname] => 192.168.10.188,[roles] => Array ([1] => anonymous user),[session] => messages|a:1:{s:5:"error";a:1:{i:0;s:114:"user notice: This is a dummy error in /home/dr/www/drupal/sites/all/modules/foobar/foobar.module on line 27.";}},[cache] => 0)))
  6. trigger_error(This is a dummy error) called at [/home/dr/www/drupal/sites/all/modules/foobar/foobar.module:27]
  7. foobar_debug()
  8. call_user_func_array(foobar_debug, Array ()) called at [/home/dr/www/drupal/includes/menu.inc:418]
  9. menu_execute_active_handler() called at [/home/dr/www/drupal/index.php:15]

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.

sir_kula’s picture

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.

chx’s picture

Status: Active » Closed (won't fix)

Since when 5.X is notice free?

c960657’s picture

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).

chx’s picture

Version: 5.1 » 5.x-dev
Status: Closed (won't fix) » Active

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 .

dvessel’s picture

Status: Active » Needs review
StatusFileSize
new848 bytes

Doesn't this just need a back port? It's fixed in D6.

http://api.drupal.org/api/function/init_theme/6

drumm’s picture

Status: Needs review » Fixed

Committed to 5.x.

Please keep backport patches in the same original issue in the future.

dvessel’s picture

I believe it was part of a bigger patch and due to the huge theming changes, it got overlooked.

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.

suit4’s picture

Status: Closed (fixed) » Needs review

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.

asimmonds’s picture

Status: Needs review » Closed (fixed)

@suit4 - This patch was committed to 5.x-dev after 5.7 was released, it will be included in 5.8 and later releases.

suit4’s picture

asimmonds thanks for the notification!

yan’s picture

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 set global $user; before. When I did, the message didn't show anymore.

angad_singh’s picture

I had the very same problem.

Here's the problem as well as the solution :)

http://drupal.org/node/277798

kingandy’s picture

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...

demeester_roel’s picture

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' :)

tharakan’s picture

Version: 5.x-dev » 7.15
Status: Closed (fixed) » Needs work

The issue seems similar to what demeester_roel mentioned above (in #27) .i.e using uninitialized variables without checking for their values / assigning them any values first.

Notice: Undefined property: stdClass::$owner in _drupal_theme_initialize() (line 208 of C:\Users\Robins_2\Documents\EasyPHP-12.1\www\drupal-7.15\includes\theme.inc).

This is the first page load (ever) of any drupal system on this system. It has the following:

PHP Version 5.4.6
Apache Version Apache/2.4.2 (Win32) PHP/5.4.6
Loaded Modules core mod_win32 mpm_winnt http_core mod_so mod_access_compat mod_actions mod_alias mod_allowmethods mod_asis mod_auth_basic mod_authn_core mod_authn_file mod_authz_core mod_authz_groupfile mod_authz_host mod_authz_user mod_autoindex mod_cgi mod_dir mod_env mod_include mod_isapi mod_log_config mod_mime mod_negotiation mod_rewrite mod_setenvif mod_php5

Version: 7.15 » 7.x-dev

Core issues are now filed against dev versions. More information about choosing a version

Status: Needs work » 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.