Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Per http://api.drupal.org/api/drupal/core%21includes%21update.inc/function/u... this is a valid function. The patch is in #1948588: Google Analytics 8 upgrade
Fatal error: Call to undefined function update_variables_to_config() in modules\google_analytics\google_analytics.install on line 13
/**
* Implements hook_install().
*/
function google_analytics_install() {
// Migrate settings from previous Google Analytics version.
update_variables_to_config('google_analytics.settings', array(
'googleanalytics_account' => 'account',
'googleanalytics_cache' => 'cache',
'googleanalytics_codesnippet_before' => 'codesnippet.before',
'googleanalytics_codesnippet_after' => 'codesnippet.after',
'googleanalytics_cross_domains' => 'cross_domains',
//'googleanalytics_custom_var' => 'custom_var',
'googleanalytics_domain_mode' => 'domain_mode',
'googleanalytics_js_scope' => 'js_scope',
'googleanalytics_last_cache' => 'last_cache',
'googleanalytics_pages' => 'visibility.pages',
'googleanalytics_roles' => 'visibility.roles',
'googleanalytics_site_search' => 'track.site_search',
'googleanalytics_trackadsense' => 'track.adsense',
'googleanalytics_trackdoubleclick' => 'track.doubleclick',
'googleanalytics_tracker_anonymizeip' => 'privacy.anonymizeip',
'googleanalytics_trackfiles' => 'track.files',
'googleanalytics_trackfiles_extensions' => 'track.files_extensions',
'googleanalytics_trackmailto' => 'track.mailto',
'googleanalytics_trackoutbound' => 'track.outbound',
'googleanalytics_translation_set' => 'translation_set',
'googleanalytics_visibility_pages' => 'visibility.pages_enabled',
'googleanalytics_visibility_roles' => 'visibility.roles_enabled',
'googleanalytics_privacy_donottrack' => 'privacy.donottrack',
));
// Remove the 'googleanalytics' directory and cached files.
file_unmanaged_delete_recursive('public://googleanalytics');
// Remove backup variables if exist. No migration required.
update_variable_del('googleanalytics_codesnippet_after_backup_6300');
update_variable_del('googleanalytics_codesnippet_before_backup_6300');
update_variable_del('googleanalytics_segmentation');
}
Comments
Comment #1
swentel CreditAttribution: swentel commentedYou're calling it in hook_install(), you need to run this in hook_update_n.
Comment #2
hass CreditAttribution: hass commentedI must run it in hook_install(). This cannot run in hook_update_x().
Module name has been changed.
Comment #3
swentel CreditAttribution: swentel commentedAh, rename ... update.inc is not loaded during hook_install() ... you can load it in the meantime for testing, which is not ideal of course.
Tagging to get more eyes on this.
Comment #4
catchrequire_once() seems plenty if the module is renamed.
Comment #5
hass CreditAttribution: hass commentedAdded require_once for now. Thanks guys.
At the very minimum this needs to be documented in the API documentation if this is not something that
hook_install()
should support.Comment #6
mtiftRunning this in hook_install() rather than hook_update_n() because of a module name change seems like an edge case to me. I'd say it works as designed.
Comment #6.0
mtifta