This morning I tried to update from 2.2 to the 3.8 security release. After performing the update the following error was generated (changed my sites name to example below to be safe):
Invalid argument supplied for foreach() common.inc:7204 [warning]
array_keys() expects parameter 1 to be array, null given common.inc:7224 [warning]
WD menu: PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 [error]
Table 'example.flag' doesn't exist: SELECT f.fid AS fid,
f.entity_type AS entity_type, f.name AS name, f.title AS title, f.global AS
global, f.options AS options, fn.type AS type
FROM
{flag} f
LEFT OUTER JOIN {flag_types} fn ON fn.fid = f.fid; Array
(
)
in flag_get_flags() (line 1945 of
/var/www/example/profiles/commons/modules/contrib/flag/flag.module).
exception 'PDOException' with message 'SQLSTATE[42S02]: Base table or view not [error]
found: 1146 Table 'example.flag' doesn't exist' in
/var/www/example/includes/database/database.inc:2204

I looked at my local and indeed there is no flag table, but there is a flags table. I checked my production site, which has not been updated to 3.8, and there is no flag table but there is a flags table. I checked another production site that uses the flag module (2.2) and again there is a flags table but no flag table. Not certain how to proceed.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

bwporter created an issue. See original summary.

drupal-son’s picture

Hi,

Exactly same issue when trying to apply the Flag security update from 2.2 to 3.8 version.

There are no updates db pending when running /update.php.

I have the error message: "The website encountered an unexpected error. Please try again later."

Any suggestions?

Thanks.

ankur.addweb’s picture

FileSize
35.24 KB
26.08 KB

I upgraded flag module from 2.2 to the 3.8 and it works well. Upon running upgrade.php I get list of updates. Please see attached screenshot. Upgrade also runs smoothly. Screenshot attached for same.

version 2.2 had flags table and version 3.8 has flag table. This table name change happens on upgrade 7301 as mentioned in flag.install and upgrade screen as well.

Can you please confirm that upgrade has run properly ?

bwporter’s picture

Hi darshi,

I tried running drush updb, I got the following result: No database updates required
So I looked at flag.install, and function flag_update_7301() is in the file.
I tried to run that update using:
drush php-eval 'module_load_install('flag');flag_update_7301();'
It errors out, the stack trace gave me this information:
exception 'DatabaseSchemaObjectExistsException' with message 'Cannot rename flag_content to flagging: table flagging already exists.'
Next I remarked out //db_rename_table('flag_content', 'flagging'); function flag_update_7301() and ran the update, it renamed flags to flag.

I guess I will need to run the remaining updates the same way. I am doing this work in my local environment, I do not want to change my production environment in this way.

Any ideas?

Thank you,

Brian.

joachim’s picture

> exception 'DatabaseSchemaObjectExistsException' with message 'Cannot rename flag_content to flagging: table flagging already exists.'

How long have you had the flagging table? Did you previously install Flag 3.x, or previously try an update?

When you first tried the update, were you also updating other modules?

ankur.addweb’s picture

hi bwporter,

It seems that your initial upgrade was partially run that is why you already have flagging table exists. That or you previously install Flag 3.x, or previously try an update as @joachim suggested.

Can you try this from scratch again? Start from 2.2 and let us know if you have any issue.

Thanks

bwporter’s picture

Hi joachim and darshi,

Thank you for helping with this issue. I looked at the site on my dev/test server and my production server (which I have not updated yet). I can confirm we are using flag version 7.x-2.2. Looking at the database tables (on dev and prod) I see the tables flags, flag_content, and flagging - which surprised me, as the update attempts to rename flag_content to flagging, right?

Also, I just remembered this is a Drupal Commons install, so perhaps the Commons distribution did some custom work with Flag or created a flagging table?

As an update, I was able to get my local up and running without error after manually running the database updates as described above. Since this is just my local I'll delete the site and re-clone the repo. I'll let you know how it works out. And thank you both very much again for helping with this issue.

Brian.

bwporter’s picture

Hi joachim and darshi,

I deleted my local site, cloned the repo and copied down the database. After updating the module from 2.2 to 3.9 I ran into the same issues as above. I was puzzled by the table flagging existing in the database with version 2.2 so I examined our git log to look for changes to the module. Sure enough, the module was updated over a year ago to the 7.x-3.x branch, then a month later the 3.x version of the module was deleted from the code (not uninstalled) and the 2.2 version added back. Since not uninstalled, the database schema was not changed from the 3.x update(s).

So, the problem I have reported is a problem we caused ourselves, not an issue with your update. I apologize for wasting your time, and I thank you again for your help.

Brian.

joachim’s picture

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

Thanks for reporting back, and good luck with the clean up!

drupal-son’s picture

Hi, I just upgraded flag from 2.2 to 3.9 with no issues.
I reported an issue above from 2.2 to 3.8.
Not sure if the hotfix from 3.8 to 3.9 fixed the issue.
I didn't see any updates ran onto db.

Thanks anyway.

Ariel

helmo’s picture