currently I can not pin down the source of this error, but sometimes I receive errors (in this case 'just' of type notice) during cron runs related to locale.module. Due to my setup this message is sent to me from the server.

I woder, if this notice can be avoided by setting error_reporting correctly or rewriting line 175 in locale.module to

    if (is_object($cache)){
    	$locale_t = unserialize($cache->data);
    }

Notice text is:
Notice: Trying to get property of non-object in /srv/www/vhosts/mydomain.org/httpdocs/modules/locale/locale.module on line 175
Call Stack # Time Memory Function Location
1 0.0025 36984 {main}( ) ../cron.php:0
2 0.0227 238880 drupal_bootstrap( ) ../cron.php:10
3 0.1098 736008 _drupal_bootstrap( ) ../bootstrap.inc:822
4 0.1387 1246032 _drupal_bootstrap_full( ) ../bootstrap.inc:885
5 0.3523 2798664 module_load_all( ) ../common.inc:1856
6 1.3224 15393256 drupal_load( ) ../module.inc:14
7 1.3527 15934672 include_once( ) ../bootstrap.inc:512
8 1.3527 15934744 t( ) ../subscriptions.module:19
9 1.3527 15934808 locale( ) ../common.inc:732
10 1.3544 15936592 locale_refresh_cache( ) ../locale.module:172
11 2.3549 16724544 cache_set( ) ../locale.module:234
12 2.3584 16725064 db_query( ) ../cache.inc:95
13 2.3705 17561888 _db_query( ) ../database.inc:200
14 2.3960 18130296 trigger_error ( ) ../database.mysqli.inc:151
15 2.3965 18494768 error_handler( ) ../database.mysqli.inc:151
16 2.4044 18859800 t( ) ../common.inc:560
17 2.4044 18859864 locale( ) ../common.inc:732

Comments

gábor hojtsy’s picture

Project: Drupal core » Subscriptions
Version: 5.3 » 5.x-1.x-dev
Component: language system » Code

Well, I looked through the revisions of subscriptions module and it seems that the DRUPAL-5--1 branch and the DRUPAL-5--2 branch does not include the kind of code which cases this error, but the DRUPAL-5 branches HEAD does still.

http://cvs.drupal.org/viewvc.py/drupal/contributions/modules/subscriptio...

The problem is on the 19th line of subscriptions module, not in locale module. Most Drupal API functions, like t() should not be used before the Drupal system is properly set up (is bootstrapped). Using t() in a define() call in the global scope tries to use t() before the backend system is properly loaded, and can cause performance problems additionaly to these bugs because of how the cache is not available at the time and you can easily end up with a constantly growing locale table because of this misuse.

The subscriptions module maintainers should act on this. Assigned the issue to them (although I don't find a perfectly suitable release version).

gábor hojtsy’s picture

Title: locale.module throws errors on cron run » t() usage in global scope define()

Better title.

salvis’s picture

I don't find a perfectly suitable release version

5.x-1.x-dev is the right one, 1.62.2.45 is in there...

salvis’s picture

Any of the 5.x-1.x maintainers care to fix this?

bdragon’s picture

Status: Active » Closed (duplicate)

5.x-2.0 is a complete rewrite, therefore any bugs in it are new. All prior releases will be obsolete when 5.x-2.0 final is out. Closing references to bugs in prior releases for this reason. Please help test 5.x-2.0 betas. Thank you! (Actually, this is a dupe of another issue I closed)