Problem/Motivation

Updating from 1.4 to 2.1 does not work. Going to /update.php page throws error:

Fatal error: Class 'GTMSettings' not found in .../sites/all/modules/contrib/google_tag/google_tag.install on line 91

I don't have access to Drush.

Truncating cache tables do not work.

Directly related to a closed issue which I was not able to open: #3101773: Cannot install the module

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Comments

mindaugasd created an issue. See original summary.

mindaugasd’s picture

morbiD’s picture

Version: 7.x-2.1 » 7.x-2.x-dev

Same issue here. I can't run update.php due to the fatal error and I can't use drush to fix it on shared hosting.

I managed to get update.php to respond by using registry_rebuild. However, I then couldn't proceed because update.php was failing the requirement, "The snippet parent directory is not set".

Furthermore, the requirement error directs you to configure a snippet directory in the module settings, but trying to do so results in a PDOException because the new gtag_config table doesn't exist in the database yet.

I ended up having to revert to the 1.x branch, uninstall the module, then install the 2.x branch and reconfigure it from scratch.

Looking at the hook_requirements() code in the .install file, I see the following relevant lines:

if ($phase == 'runtime' || $phase == 'update' || $phase == 'install') {
  $directory = $phase == 'install' ? 'public:/' : \GTMSettings::getInstance()->get('uri');
  if (empty($directory)) {
    $requirements['google_tag_snippet_parent_directory'] = array(
      'severity' => REQUIREMENT_ERROR,
    );

So it seems that a default value is used for the snippet directory during a fresh install, but not during an update from 1.x to 2.x.

That means the update won't run because the snippet directory isn't set, and the snippet directory can't be set because the update won't run, making it impossible to update!

solotandem’s picture

Category: Bug report » Support request
Priority: Critical » Normal

If my memory serves me, the same claim has been raised in other issues, but has always come down to deployment procedures.

As part of the deployment process after a code base change, the following steps should be run as the website user:

  • clear caches
  • update database

If these are done, then there should be no errors. The website user should have permission to create directories. The cache clear will reset menu items, etc, and recognize the PHP classes. DB update will create the tag config table.

Once again, I tested the workflow of update from 1.4 to 2.1. Following the above steps, no errors. On an otherwise bare site with two languages plus domain enabled, four snippet directories were created with 3 or 6 snippet files each.

@morbiD I agree that without a cache clear you will end up in an unstable state. But again, that points to error in deployment, not a bug in this module.