The following updates returned messages

image module

Update #7002
Failed: DatabaseSchemaObjectExistsException: Невозможно добавить поле %able.<em class="placeholder">field_image_width</em>: поле уже существует. в функции DatabaseSchema_mysql->addField() (строка 323 в файле /home/www/simbiozcomua/simbiozcomua/www/new/includes/database/mysql/schema.inc).

I `d add chech into image.install and all looks fine after that

with patch

# drush -ydv updatedb
Bootstrap to phase 0. [0.03 sec, 2.7 MB]                             [bootstrap]
Drush bootstrap phase : _drush_bootstrap_drush() [0.04 sec, 2.92 MB] [bootstrap]
Bootstrap to phase 2. [0.11 sec, 7.25 MB]                                                                          [bootstrap]
Drush bootstrap phase : _drush_bootstrap_drupal_root() [0.11 sec, 7.26 MB]                                         [bootstrap]
Initialized Drupal 7.9 root directory at # [0.14 sec, 8.85 MB]              [notice]
Drush bootstrap phase : _drush_bootstrap_drupal_site() [0.14 sec, 8.85 MB]                                         [bootstrap]
Initialized Drupal site default at sites/default [0.14 sec, 8.86 MB]                                                  [notice]
Found command: updatedb (commandfile=core) [0.27 sec, 9.48 MB]                                                     [bootstrap]
Initializing drush commandfile: drush_make [0.27 sec, 9.49 MB]                                                     [bootstrap]
Initializing drush commandfile: drush_make_d_o [0.28 sec, 9.49 MB]                                                 [bootstrap]
Initializing drush commandfile: user [0.28 sec, 9.49 MB]                                                           [bootstrap]
Drush bootstrap phase : _drush_bootstrap_drupal_configuration() [1.96 sec, 22.89 MB]                               [bootstrap]
Drush bootstrap phase : _drush_bootstrap_drupal_database() [1.96 sec, 22.89 MB]                                    [bootstrap]
Successfully connected to the Drupal database. [1.96 sec, 22.89 MB]                                                [bootstrap]
Drush bootstrap phase : _drush_bootstrap_drupal_full() [1.96 sec, 22.89 MB]                                        [bootstrap]
The following updates are pending:

image module : 
  7002 -   Add width and height columns to image field schema and populate. 

Do you wish to run all pending updates? (y/n): y
Running: /usr/local/bin/php /usr/local/bin/drush.php --php='/usr/local/bin/php'                                      [command]
--root='#' --uri='http://default' updatedb-batch-process '95' --backend 
2>&1 [4.48 sec, 49.7 МБ]
Bootstrap to phase 0. [39.89 sec, 49.77 МБ]                                                                      [bootstrap]
Drush bootstrap phase : _drush_bootstrap_drush() [39.89 sec, 49.77 МБ]                                           [bootstrap]
Bootstrap to phase 2. [39.89 sec, 49.77 МБ]                                                                      [bootstrap]
Drush bootstrap phase : _drush_bootstrap_drupal_root() [39.89 sec, 49.77 МБ]                                     [bootstrap]
Initialized Drupal 7.9 root directory at # [39.89 sec, 49.77 МБ]          [notice]
Drush bootstrap phase : _drush_bootstrap_drupal_site() [39.89 sec, 49.77 МБ]                                     [bootstrap]
Initialized Drupal site default at sites/default [39.89 sec, 49.77 МБ]                                              [notice]
Found command: updatedb-batch-process (commandfile=core) [39.89 sec, 49.78 МБ]                                   [bootstrap]
Initializing drush commandfile: drush_make [39.89 sec, 49.78 МБ]                                                 [bootstrap]
Initializing drush commandfile: drush_make_d_o [39.89 sec, 49.78 МБ]                                             [bootstrap]
Initializing drush commandfile: user [39.89 sec, 49.78 МБ]                                                       [bootstrap]
Drush bootstrap phase : _drush_bootstrap_drupal_configuration() [39.89 sec, 49.78 МБ]                            [bootstrap]
Drush bootstrap phase : _drush_bootstrap_drupal_database() [39.89 sec, 49.78 МБ]                                 [bootstrap]
Successfully connected to the Drupal database. [39.89 sec, 49.78 МБ]                                             [bootstrap]
Drush bootstrap phase : _drush_bootstrap_drupal_full() [39.9 sec, 49.79 МБ]                                      [bootstrap]
Executing image_update_7002 [39.9 sec, 49.79 МБ]                                                                    [notice]
Executing image_update_7002 [39.9 sec, 49.79 МБ]                                                                    [notice]
Executing image_update_7002 [39.9 sec, 49.79 МБ]                                                                    [notice]
Executing image_update_7002 [39.9 sec, 49.79 МБ]                                                                    [notice]
Executing image_update_7002 [39.9 sec, 49.79 МБ]                                                                    [notice]
Executing image_update_7002 [39.9 sec, 49.79 МБ]                                                                    [notice]
Executing image_update_7002 [39.9 sec, 49.8 МБ]                                                                     [notice]
Executing image_update_7002 [39.9 sec, 49.8 МБ]                                                                     [notice]
Command dispatch complete [39.9 sec, 49.8 МБ]                                                                       [notice]
Peak memory usage was 50.36 МБ [39.9 sec, 49.8 МБ]                                                                [memory]
Finished performing updates. [39.9 sec, 49.73 МБ]                                                                [ok]
Command dispatch complete [39.9 sec, 49.7 МБ]                                                                       [notice]
 Timer  Cum (sec)  Count  Avg (msec) 
 page   39.576     1      39576.28   

Peak memory usage was 51.53 МБ [39.91 sec, 49.7 МБ]   
CommentFileSizeAuthor
image_install_7002_field_bug.patch758 bytespodarok
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

andypost’s picture

Priority: Critical » Major

Prabably this could happen when one field used in different entities

allella’s picture

Summary of Problem

Same issue here after upgrading from 7.8 to 7.9.

We have an image field that was used by multiple content types. The field name is field_image, and thus there is a corresponding tables named field_data_field_image and field_revision_field_image.

The image module's 7002 update did not run properly and never added the corresponding field_image_width and field_image_height columns to the aforementioned field tables. Thus the following error occurred.

PDOException: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'field_image_width' in 'field list': INSERT INTO {field_data_field_image} (entity_type, entity_id, revision_id, bundle, delta, language, field_image_fid, field_image_alt, field_image_title, field_image_width, field_image_height) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6, :db_insert_placeholder_7, :db_insert_placeholder_8, :db_insert_placeholder_9, :db_insert_placeholder_10); Array ( [:db_insert_placeholder_0] => node [:db_insert_placeholder_1] => 5340 [:db_insert_placeholder_2] => 34252 [:db_insert_placeholder_3] => article [:db_insert_placeholder_4] => 0 [:db_insert_placeholder_5] => und [:db_insert_placeholder_6] => 26700 [:db_insert_placeholder_7] => [:db_insert_placeholder_8] => [:db_insert_placeholder_9] => 2592 [:db_insert_placeholder_10] => 1458 ) in field_sql_storage_field_storage_write() (line 448 of /sites/example.com/public_html/modules/field/modules/field_sql_storage/field_sql_storage.module).

Solution

First, modify the system table to make Drupal think it has never run update 7002 for the image module, by setting the last update value to that of the previous update, which was 7001.

UPDATE `system` SET `schema_version` = '7001' WHERE `system`.`filename` = 'modules/image/image.module';

Apply the patch above in comment #1 from the Drupal root directory, like this

wget --no-check-certificate https://drupal.org/files/image_install_7002_field_bug.patch
git apply -v image_install_7002_field_bug.patch

Then run update.php (or drush updb) and the update should succeeded and add the missing width and height fields, along with the actual width and height values of any existing images.

jbrown’s picture

Status: Needs review » Reviewed & tested by the community

I've been unable to reproduce this, but the problem seems to be that if update 7002 does not complete for whatever reason, it needs to be started again from the beginning. However, this does not work because the db columns have already been added.

The patch in #0 fixes this problem by only adding the column if it does not already exist. This means the update can be run over and over again without any problems. (I have verified this)

So I think this is a good idea!

dup: #1335312: foo_width field already exist image field upgrade error ?

jbrown’s picture

Title: Upgrading from 7.8 to 7.9 image field error (multiple fields) » If image_update_7002() does not complete on the first attempt it throws a db error when re-run
Anonymous’s picture

Status: Reviewed & tested by the community » Needs work

i think we need to try a bit harder to find out how to reproduce this, so we can fix the underlying bug. i'm going to have a play with the suggestion in #1.

jbrown’s picture

It uses the batch api, so if you have a lot of images and you close the browser window after the update has started then it would be impossible to complete the upgrade.

Anonymous’s picture

ok, still looking, but i'm not sure we want to support "oh, it broke". that's why we tell people to do backups.

i'm mostly interested in a) verifying there's not an underlying bug, and/or b) making sure this works even for large data sets.

catch’s picture

Issue tags: +D7 upgrade path

We should not make this re-entrant, it is bad enough trying to maintain a working upgrade path that runs once, let alone twice, and like beejeebus says that's what backups are for.

Fixing the underlying bug and/or issues with large data sets sounds good though.

podarok’s picture

how to reproduce?

create more than one content types with shared field image between em in drupal 7.x< 7.9
after that - generate a few nodes for every content types (devel_generate FE)

upgrade to 7.9

run drush updatedb

here is a bug $)
without 7002 we have no possibility to add those nodes - error with schema

apply #1

run drush updatedb
schema fixed without errors

I`ll wait for RTBC

podarok’s picture

Title: If image_update_7002() does not complete on the first attempt it throws a db error when re-run » image_update_7002() does not complete on shared image field with multiple content types

changing title due #9

Anonymous’s picture

awesome, trying that now, if we can reproduce with that, we should be able to turn this in to tests. or something.

podarok’s picture

what kind of tests we can write for that?
Can QA infrastructure install previous version of drupal and make upgrade path ?
if Yes - then it is possible to write something like checking image_install_7002 before and after for making possible all the tables upgraded without skipped data tables

#0 already tested on huge site with 6 content types with shared image field on them

allella’s picture

I concur with the assessment of #9, so it does appear to be a bug.

Patch #0 worked for a site with an image field shared across two content types, but only by faking out the update.php to re-run 7002, as described in #2.

In addition to patch #0, should there be an update 7003 that checks if the width and height fields still don't exist and then runs the 7002 code only if they are still missing?

Thanks

jbrown’s picture

Title: image_update_7002() does not complete on shared image field with multiple content types » Reports of image_update_7002() not completing (unable to reproduce)
Status: Needs work » Active

I can't reproduce this. I have created multiple image fields, put them into multiple content types and vocabularies, created enough content so the batch api has to take a second pass and tried it with both drush and running update.php manually.

Is it possible that people are using an old version of drush?

Is there an error output the first time the update is attempted?

Is drush timing out because a pass is taking too long?

Anonymous’s picture

yeah, i can't reproduce this either.

i created a bunch of content types, made sure that multiple pairs of them shared some image fields, used drush devel and created 5000 nodes, and couldn't get the fail.

is it possible someone who does see this could post a db dump? it's hard to move forward without that.

podarok’s picture

#13

creating 7003 not good, cause 7002 generate error and stops update

#14 and #15
ok
I`ll try to upload sql dump with my config for making possible to reproduce a bug

podarok’s picture

Status: Active » Closed (works as designed)

8((
I can`t reproduce my own bug
got backup and update to 7.9 without any problems at all

in #0 there was web update.php with error in batch api stopped due to javascript error (possibly browser 8( ) and restarting batch from semiupgraded 7002 generate error described by me in #0

patch #0 fix all my tables without errors and site now works well

Now I`d try several times to reproduce a bug "without success" - batch working well to the end and 7002 upgrade my tables with status OK

Possibly someone catch similar error - please reopen this issue with reproduce path

sorry...

Quarantine’s picture

I'm posting here to say that I'm encountering the same problem as well after updating to 7.9 and then 7.10, but I'm unable to tell you how to reproduce it.

I saw this in my logs - not sure if it'll help any since I don't understand it much:

DatabaseSchemaObjectExistsException: Cannot add field field_data_field_image.field_image_width: field already exists. in DatabaseSchema_mysql->addField() (line 323 of E:\htdocs\jeuxtapose\includes\database\mysql\schema.inc).

I can offer you my db dump but I'll only be able to give it to you in private.