Get the following errors after database upgrade from 3.3 to 3.4

user warning: Duplicate column name 'tags' query: update_sql /* bennos : update_sql */ ALTER TABLE filefield_meta ADD `tags` TEXT DEFAULT NULL in /var/www/version2/includes/database.mysql-common.inc on line 298.
warning: Division by zero in /var/www/version2/sites/all/modules/filefield/filefield_meta/filefield_meta.install on line 166.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

YesCT’s picture

Title: Error on Upgrade to 3.4 » Error on Upgrade to 3.4 warning: Division by zero filefield_meta.install on line 166

me too
line 166:

  // Update our progress indicator.
  $ret['#finished'] = $context['sandbox']['progress'] / $context['sandbox']['total'];

error:
warning: Division by zero in /home/..../sites/all/modules/filefield/filefield_meta/filefield_meta.install on line 166.

quicksketch’s picture

Title: Error on Upgrade to 3.4 warning: Division by zero filefield_meta.install on line 166 » Error on Upgrade to 3.4
Category: bug » support

The tags column did not exist before 3.4. My guess is you had previously installed a development version or tried out a patch?

YesCT’s picture

Title: Error on Upgrade to 3.4 » Error on Upgrade to 3.4 warning: Division by zero filefield_meta.install on line 166
Category: support » bug

also, I had so many messages exactly like that that I got:
an out of memory fatal error during the upgrade.php

hargobind’s picture

Priority: Normal » Critical

I'm seeing this too. Changing the issue to Critical since this update probably affects many sites and will probably stall the update process which then prevents other modules from being updated.

Out of 1260 records in my filefield_meta table, the audio_format column for every record is empty. Line 148 contains the query that sets $context['sandbox']['total'] which is where the divide by zero on line 166 happens.

I'm not sure what the purpose of this update is, so I can't correctly suggest a fix, other than to add a check to bypass the update if the value of "total" is zero.

YesCT’s picture

Priority: Critical » Normal

original poster had two warnings, one about tags, and another about div by zero (sorry I didnt notice that when I changed the title to be just about div by zero)...

YesCT’s picture

Priority: Normal » Critical

cross post

mieg’s picture

The problem occurs when $context['sandbox']['total'] equals zero. I added below three lines and the update worked for me for a couple of sites. Anybody willing to test this?

...
db_add_field($ret, 'filefield_meta', 'tags', array('type' => 'text'));
}

if ($context['sandbox']['total'] == 0) {
$ret['#finished'] = 1;
return $ret;
}

// Select and process 200 files at a time.
...

ITMonkey’s picture

Subscribing - My 256MiB ran out during a drush updatedb with the above error.

mieg - I'll be willing to test if no-one else has by 4pm, going to be pretty tied up until then!

Carsten Müller’s picture

same error
warning: Division by zero in ..../sites/all/modules/contrib/filefield/filefield_meta/filefield_meta.install on line 166.

sj26’s picture

Change line 166 to:

$ret['#finished'] = ($context['sandbox']['total'] > 0) ? $context['sandbox']['progress'] / $context['sandbox']['total'] : 1.0;

and she's all good, mate.

lordzik’s picture

I get the same error.

Change from #10 seems to work.

k74’s picture

I have this error on upgrade from 3.3 to 3.4:

Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 20396253 bytes) in /public_html/includes/database.mysqli.inc on line 323

YesCT’s picture

Status: Active » Needs review
FileSize
621 bytes

added code to check for div by zero.

Anonymous’s picture

The same problem here ... the patch seems to fix the problem

ITMonkey’s picture

I've manually applied the code change (I'd already started changing the code so it was easier than reverting and running the patch)

I ran drush pm-update and got the following errors:

WD php: Duplicate column name 'tags' [error]
query: ALTER TABLE filefield_meta ADD `tags` TEXT DEFAULT NULL in
/var/www/htdocs/LBH/includes/database.mysql-common.inc on line 298.
ALTER TABLE {filefield_meta} ADD `tags` TEXT DEFAULT NULL [error]
Duplicate column name 'tags' [error]
query: ALTER TABLE filefield_meta ADD `tags` TEXT DEFAULT NULL in
/var/www/htdocs/LBH/includes/database.mysql-common.inc on line 298.
An error occurred at function : drush_core_updatedb_batch_process [error]
Finished performing updates. [ok]
An error occurred at function : drush_core_updatedb [error]
The following updates are pending:

filefield_meta module
6100 - Add the tags column.

Do you wish to run all pending updates? (y/n): y
An error occurred at function : drush_pm_post_pm_update [error]

Could someone just clarify that these errors are only because I was running the update for a second time?

yngens’s picture

same error. patch did not help. filefield 6.x-3.4 is buggy.

bennos’s picture

patch for the "division by zero" error worked.

the duplicate column error is alive, but the coloumn is created.

bcobin’s picture

Same here - had to roll back to 3.3. Subscribing - hoping that 3.5 will correct inconsistencies caused by upgrade to 3.4... thanks!

pwolanin’s picture

FileSize
794 bytes

Here's an even simpler patch to avoid the divide by zero error.

solserpiente’s picture

Thanks a lot pwolanin!! Your patch is working for me

Hobbes-2’s picture

Subscribe

flickerfly’s picture

Status: Needs review » Reviewed & tested by the community

#19 worked for me also. I received an error about duplicate rows on upgrade, but I'm sure that's because it ran the same upgrade multiple times. The second time I ran 'drush updatedb' it reported no updates required.

Looks like #19 resolves the bug.

Since that's two affirmatives, I'm marking rtbc.

cheeop’s picture

I went 3.3 -> 3.4, got the div by zero error. I re-downloaded the module file to make sure I had a good copy, re-uploaded to server, re-extracted, and re-update.phped, but same error.

I then tried to regress to 3.3, but am getting a different error.

user warning: Duplicate column name 'audio_format' query: ALTER TABLE filefield_meta ADD `audio_format` VARCHAR(10) NOT NULL DEFAULT '' in /home/mysite/public_html/includes/database.mysql-common.inc on line 298.

and a series of errors that look like this:
Failed: ALTER TABLE {filefield_meta} ADD `audio_format` VARCHAR(10) NOT NULL DEFAULT ''

I do not know how to apply the patch. What is the best way for me to get the site back up and running ASAP?

MacMladen’s picture

As all here noted, I will sum it up:

  1. division by zero should be avoided by checking it, I like #10 solution
  2. Also, there should be check if 'tags' column exists before adding it (for previous semi successful attempt)

These should be changed and I believe it will be fine

j0nathan’s picture

subscribing

cheeop’s picture

Thank you MacMladen. I Re-extracted the module, tried #10, and re-ran update.php. Now I get:

user warning: Duplicate column name 'tags' query: ALTER TABLE filefield_meta ADD `tags` TEXT DEFAULT NULL in /home/mysite/public_html/includes/database.mysql-common.inc on line 298.

and

The following queries were executed
filefield_meta module
Update #6100
Failed: ALTER TABLE {filefield_meta} ADD `tags` TEXT DEFAULT NULL

I am sorry I don't understand how to check if tags column exists. Can you please advise?

mxa055’s picture

probably sth like...

IF EXISTS (SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME=’table’ AND column_name=’qwerty’) BEGIN SELECT * FROM table ORDER BY qwerty END

Scott M. Sanders’s picture

Subscribe, yikes.

Oghnia’s picture

after doing all of this the file descriptions are gone and I can't re-enter them... DAMN

bradjones1’s picture

Did you back up your database beforehand? Also, the new "tags" column shouldn't be destructive in its creation - unless someone has a better picture of how it's coded? Looks like it's just running id3 to grab a snapshot of the metadata and add it to the filefield_meta table.

Anonymous’s picture

The problem occurs when $context['sandbox']['total'] equals zero. I added below three lines and the update worked for me for a couple of sites. Anybody willing to test this?

...

db_add_field($ret, 'filefield_meta', 'tags', array('type' => 'text'));
}

if ($context['sandbox']['total'] == 0) {
$ret['#finished'] = 1;
return $ret;
}

// Select and process 200 files at a time.

This worked on my site!

www.stevenjaycohen.com

Thanks!

cheeop’s picture

Sorry, I am still not sure what to do now that I have my current errors:

Drupal database update
user warning: Duplicate column name 'tags' query: ALTER TABLE filefield_meta ADD `tags` TEXT DEFAULT NULL in /home/cheeop/public_html/includes/database.mysql-common.inc on line 298.

and

The following queries were executed
filefield_meta module
Update #6100
Failed: ALTER TABLE {filefield_meta} ADD `tags` TEXT DEFAULT NULL

Can someone please advise as to exactly what steps I should take next?

Thank you.

pwolanin’s picture

In general you expect error messages if you run an update twice. If for some reason this is likely to have happened to people, then the right API funciton to check is: http://api.drupal.org/api/function/db_column_exists/6, e.g.:

diff -u -p -r1.9 filefield_meta.install
--- filefield_meta/filefield_meta.install	16 Jun 2010 22:06:44 -0000	1.9
+++ filefield_meta/filefield_meta.install	17 Jun 2010 18:15:19 -0000
@@ -147,8 +147,9 @@ function filefield_meta_update_6100(&$co
     $context['sandbox']['progress'] = 0;
     $context['sandbox']['total'] = db_result(db_query("SELECT COUNT(*) FROM {files} f INNER JOIN {filefield_meta} fm ON f.fid = fm.fid WHERE fm.audio_format <> ''"));
     $context['sandbox']['current_fid'] = 0;
-
-    db_add_field($ret, 'filefield_meta', 'tags', array('type' => 'text'));
+    if (!db_column_exists('filefield_meta', 'tags')) {
+      db_add_field($ret, 'filefield_meta', 'tags', array('type' => 'text'));
+    }
   }
 
   // Select and process 200 files at a time.

but in general that should not be needed.

Scott M. Sanders’s picture

OK, #33 makes the most sense.

Just open filefield_meta.install in an editor, find line 151, and insert the 3 + lines after. :)

(Just don't include the + when you do.)

pwolanin’s picture

FileSize
1.21 KB

here's a combined patch that puts it all in the setup block

pwolanin’s picture

Status: Reviewed & tested by the community » Fixed

committed the patch in #36 after talking to quicksketch. quick bugfix release coming.

quicksketch’s picture

Thanks pwolanin. The 3.5 version is now out. Please try it and confirm that it has solved the problem.

Scott M. Sanders’s picture

3.5 works fine on both my sites where I had tried 3.4 and another site where I still had 3.3. :)

Fidelix’s picture

Tested on 5 installations.

3.5 is fixed. Thank you all!

cheeop’s picture

3.5 fixed it for me, thanks.

arviaja’s picture

When I try to upgrade the filefield meta module from 3.4 to 3.5 I get the memory allocation error. This is odd though since I've allocated 32M in php.ini and the script actually only asks for 16M.

Scott M. Sanders’s picture

Is any remnant of this inadvertently causing ImageField to not save data?
http://drupal.org/node/833000

Scott M. Sanders’s picture

Just FYI, disabling FileField Meta 3.5 does allow ImageField to save data again.

yngens’s picture

I confirm disabling filefield meta solves the problem, but I need both to work for my project. So this solutions should be deemed as temporary workaround.

Status: Fixed » Closed (fixed)

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