GTM is overriding values from $GLOBAL['conf'] during cron run

During the execution of cron process, GTM is overriding the $GLOBAL['conf'] values, impacting and creating issues for the execution of other cron tasks. This issue was discovered in one of the non-production environments of our client. We also have i18n module enabled, creating two Realms: "Global" and "Language".

Before the execution of 'google_tag_cron()' function, In $GLOBAL['conf'] variable we have the the default value of the Apache Solr server URL set. After the 'google_tag_cron()' the value of Solr URL and other variables in $GLOBAL['conf'] were set to NULL.

This issue happens in the function _google_tag_assets_create() (includes/admin.inc, line 247). In the line 255 the execution of 'variable_realm_switch($realm_name, $key_name);' without passing the last paramater to indicate to NOT rebuild the $realm_name is missing, causing the overriding of values in the $GLOBAL['conf'] variable.

As the function _google_tag_assets_create() has the only intend of saves snippet files and data layer classes based on current setting (reading the Realms values, and NOT rebuilding them), the function call in the line 255 should be called in this way:
variable_realm_switch($realm_name, $key_name, FALSE);
It will not force the rebuild of whole current realm values. When the overriden of default values happen, other cron jobs are impacted, since they depends on the values stered in $GLOBAL['conf'] variable.

Ways to reproduce this bug:
Drupal Version: 7.67
GTM Module (google_tag): 7.x-1.4
Internationalization module (i18n): 7.x-1.26
Variable Realm (variable_realm): 7.x-2.5

Small piece of code to check the issue:

Check the values from $GLOBAL['conf'] before and after the google_tag_cron() runnng this small piece of code using drush:

drush ev '
global $conf; 
var_export($conf); 
echo "\nDEBUG:: Calling google_tag_cron()\n"; 
google_tag_cron(); 
echo "\nDEBUG:: function called!\n"; 
echo "\nDEBUG: Now printing the global conf variable again...\n"; 
var_export($conf);
echo "\n";
'

Comments

lrcarvalho created an issue. See original summary.

lrcarvalho’s picture

  • solotandem committed d661fdd on 7.x-1.x
    Issue #3077226 by lrcarvalho Do not override $GLOBAL['conf'] during cron...
solotandem’s picture

Title: GTM is overriding values from $GLOBAL['conf'] during cron run » Do not override $GLOBAL['conf'] during cron run
Version: 7.x-1.4 » 7.x-1.x-dev
Assigned: lrcarvalho » solotandem
Priority: Major » Normal
Status: Active » Fixed

Thank you for the detailed analysis, steps to reproduce, and code to test.

Status: Fixed » Closed (fixed)

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

pq’s picture

Unfortunately this update appears to have broken the ability to have distinct config per realm.

I've added a new issue for this: #3086295: Translated configuration via variable_realm no longer works