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.
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.
Comment | File | Size | Author |
---|---|---|---|
#36 | 829920-avoid-zero-34.patch | 1.21 KB | pwolanin |
#19 | 829920-no-zero-18.patch | 794 bytes | pwolanin |
#13 | 829920_filefielddivbyzero.patch | 621 bytes | YesCT |
Comments
Comment #1
YesCT CreditAttribution: YesCT commentedme too
line 166:
error:
warning: Division by zero in /home/..../sites/all/modules/filefield/filefield_meta/filefield_meta.install on line 166.
Comment #2
quicksketchThe tags column did not exist before 3.4. My guess is you had previously installed a development version or tried out a patch?
Comment #3
YesCT CreditAttribution: YesCT commentedalso, I had so many messages exactly like that that I got:
an out of memory fatal error during the upgrade.php
Comment #4
hargobindI'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.
Comment #5
YesCT CreditAttribution: YesCT commentedoriginal 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)...
Comment #6
YesCT CreditAttribution: YesCT commentedcross post
Comment #7
mieg CreditAttribution: mieg commentedThe 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.
...
Comment #8
ITMonkey CreditAttribution: ITMonkey commentedSubscribing - 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!
Comment #9
Carsten Müller CreditAttribution: Carsten Müller commentedsame error
warning: Division by zero in ..../sites/all/modules/contrib/filefield/filefield_meta/filefield_meta.install on line 166.
Comment #10
sj26 CreditAttribution: sj26 commentedChange line 166 to:
and she's all good, mate.
Comment #11
lordzik CreditAttribution: lordzik commentedI get the same error.
Change from #10 seems to work.
Comment #12
k74 CreditAttribution: k74 commentedI 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
Comment #13
YesCT CreditAttribution: YesCT commentedadded code to check for div by zero.
Comment #14
Anonymous (not verified) CreditAttribution: Anonymous commentedThe same problem here ... the patch seems to fix the problem
Comment #15
ITMonkey CreditAttribution: ITMonkey commentedI'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?
Comment #16
yngens CreditAttribution: yngens commentedsame error. patch did not help. filefield 6.x-3.4 is buggy.
Comment #17
bennos CreditAttribution: bennos commentedpatch for the "division by zero" error worked.
the duplicate column error is alive, but the coloumn is created.
Comment #18
bcobin CreditAttribution: bcobin commentedSame here - had to roll back to 3.3. Subscribing - hoping that 3.5 will correct inconsistencies caused by upgrade to 3.4... thanks!
Comment #19
pwolanin CreditAttribution: pwolanin commentedHere's an even simpler patch to avoid the divide by zero error.
Comment #20
solserpiente CreditAttribution: solserpiente commentedThanks a lot pwolanin!! Your patch is working for me
Comment #21
Hobbes-2 CreditAttribution: Hobbes-2 commentedSubscribe
Comment #22
flickerfly CreditAttribution: flickerfly commented#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.
Comment #23
cheeop CreditAttribution: cheeop commentedI 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?
Comment #24
MacMladen CreditAttribution: MacMladen commentedAs all here noted, I will sum it up:
These should be changed and I believe it will be fine
Comment #25
j0nathan CreditAttribution: j0nathan commentedsubscribing
Comment #26
cheeop CreditAttribution: cheeop commentedThank 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?
Comment #27
mxa055 CreditAttribution: mxa055 commentedprobably 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
Comment #28
Scott M. Sanders CreditAttribution: Scott M. Sanders commentedSubscribe, yikes.
Comment #29
Oghnia CreditAttribution: Oghnia commentedafter doing all of this the file descriptions are gone and I can't re-enter them... DAMN
Comment #30
bradjones1Did 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.
Comment #31
Anonymous (not verified) CreditAttribution: Anonymous commentedThis worked on my site!
www.stevenjaycohen.com
Thanks!
Comment #32
cheeop CreditAttribution: cheeop commentedSorry, 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.
Comment #33
pwolanin CreditAttribution: pwolanin commentedIn 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.:
but in general that should not be needed.
Comment #34
Scott M. Sanders CreditAttribution: Scott M. Sanders commentedOK, #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.)
Comment #36
pwolanin CreditAttribution: pwolanin commentedhere's a combined patch that puts it all in the setup block
Comment #37
pwolanin CreditAttribution: pwolanin commentedcommitted the patch in #36 after talking to quicksketch. quick bugfix release coming.
Comment #38
quicksketchThanks pwolanin. The 3.5 version is now out. Please try it and confirm that it has solved the problem.
Comment #39
Scott M. Sanders CreditAttribution: Scott M. Sanders commented3.5 works fine on both my sites where I had tried 3.4 and another site where I still had 3.3. :)
Comment #40
Fidelix CreditAttribution: Fidelix commentedTested on 5 installations.
3.5 is fixed. Thank you all!
Comment #41
cheeop CreditAttribution: cheeop commented3.5 fixed it for me, thanks.
Comment #42
arviaja CreditAttribution: arviaja commentedWhen 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.
Comment #43
Scott M. Sanders CreditAttribution: Scott M. Sanders commentedIs any remnant of this inadvertently causing ImageField to not save data?
http://drupal.org/node/833000
Comment #44
Scott M. Sanders CreditAttribution: Scott M. Sanders commentedJust FYI, disabling FileField Meta 3.5 does allow ImageField to save data again.
Comment #45
yngens CreditAttribution: yngens commentedI 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.