Notice: Trying to get property of non-object in drupal-6.5\includes\theme.maintenance.inc on line 250
Notice: Undefined property: stdClass::$language in drupal-6.5\themes\garland\maintenance-page.tpl.php on line 16

when mysql is off and error_reporting = E_ALL in php.ini..

note: this is displayed by the server not as a Drupal error message..

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Dave Reid’s picture

Wait...mysql is off?

Pasqualle’s picture

yes, the mysql server was turned off when I saw the php notice on the maintenance page.. I did not tested further, if it is necessary to reproduce the bug..

Dave Reid’s picture

I can duplicate this error. It's because Drupal can't connect to the database (I changed my database connection info in settings.php to an invalid database), so Drupal is not really at fault. You still get the Drupal maintenance page right? I guess we could be a little better at not showing non-fatal errors.

Dave Reid’s picture

Found a fix...patch coming shortly.

Dave Reid’s picture

Title: PHP notice: Trying to get property of non-object » PHP notice on _db_error_page
Version: 6.5 » 7.x-dev
Assigned: Unassigned » Dave Reid
Status: Active » Reviewed & tested by the community
FileSize
614 bytes
655 bytes

The function _db_error_page does not call drupal_init_language, which is causing the PHP notice on global $language. If you take a look at install_main and update.php, they both do a bootstrap to DRUPAL_BOOSTRAP_CONFIGURATION, and call drupal_init_language() right before the call to drupal_maintenance_theme(). We need to do the same thing on _db_error_page to prevent this PHP notice.

Steps to reproduce this error:
- Have a valid, already installed Drupal ready
- Change your settings.php to an invalid database
- The db error page shows PHP notice

Attached are very little patches for D7 and D6. I have confirmed that in D6 this fixes the bug, there is some logic error in D7 that instead of showing a db down page, it goes back to install.php (which calls drupal_init_language). This should be RTBC.

Dave Reid’s picture

Version: 7.x-dev » 6.x-dev

I should leave this on 6.x since that's where this can be fixed first, then we can worry about 7.x

Dave Reid’s picture

Ideally there should just be a drupal_init_language call made in _drupal_maintenance_theme since we need to do it every time we call drupal_maintenance_theme, but that should probably be a separate issue.

Pasqualle’s picture

tested on D6.5
the notice is gone after the patch..

Dave Reid’s picture

Marking as RTBC. Can't really test this...

dvessel’s picture

Dave, you shouldn't mark it RTBC for your own patch.

I did test it though and it works though so RTBC by me.

Ideally there should just be a drupal_init_language call made in _drupal_maintenance_theme since we need to do it every time we call drupal_maintenance_theme, but that should probably be a separate issue.

No, that wouldn't be right since the maintenance page could already have been through a bootstrap when updating and the late phases of the initial install. They all funnel through that same function. Your current patch is fine.

Dave Reid’s picture

Sorry dvessel. Sometimes I get a little trigger-happy. :)

Gábor Hojtsy’s picture

Version: 6.x-dev » 7.x-dev

Committed to Drupal 6. Moving to Drupal 7.

Dries’s picture

Status: Reviewed & tested by the community » Fixed

Committed to CVS HEAD as well. Thanks.

Anonymous’s picture

Status: Fixed » Closed (fixed)

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