diff options
author | webchick <webchick@24967.no-reply.drupal.org> | 2012-10-29 18:55:12 -0700 |
---|---|---|
committer | webchick <webchick@24967.no-reply.drupal.org> | 2012-10-29 18:55:12 -0700 |
commit | 766e06742c2f90d372be6f08826622526637df2e (patch) | |
tree | be044da5ae7cd86c3479317f894f447af7889919 | |
parent | dafe7ae2e4eb004ee302f8ee28c3c038dd7d5619 (diff) | |
download | brdo-766e06742c2f90d372be6f08826622526637df2e.tar.gz brdo-766e06742c2f90d372be6f08826622526637df2e.tar.bz2 |
Issue #1586542 by BTMash, carwin, xjm, gwulo: Fixed d6 to d7 upgrade stuck at update #7061.
-rw-r--r-- | modules/simpletest/tests/upgrade/drupal-6.upload.database.php | 31 | ||||
-rw-r--r-- | modules/system/system.install | 20 |
2 files changed, 51 insertions, 0 deletions
diff --git a/modules/simpletest/tests/upgrade/drupal-6.upload.database.php b/modules/simpletest/tests/upgrade/drupal-6.upload.database.php index c7f032ecb..46ebe2cb0 100644 --- a/modules/simpletest/tests/upgrade/drupal-6.upload.database.php +++ b/modules/simpletest/tests/upgrade/drupal-6.upload.database.php @@ -416,3 +416,34 @@ db_insert('upload')->fields(array( 'weight' => '0', )) ->execute(); + +// Add series of entries for invalid node vids to the {upload} table. +for ($i = 30; $i < 250; $i += 2) { + db_insert('upload')->fields(array( + 'fid', + 'nid', + 'vid', + 'description', + 'list', + 'weight', + )) + // Invalid fid, invalid vid. + ->values(array( + 'fid' => $i, + 'nid' => '40', + 'vid' => 24 + $i, + 'description' => 'crazy-basename.png', + 'list' => '1', + 'weight' => '0', + )) + // Valid fid, invalid vid. + ->values(array( + 'fid' => 2, + 'nid' => '40', + 'vid' => 24 + $i + 1, + 'description' => 'crazy-basename.png', + 'list' => '1', + 'weight' => '0', + )) + ->execute(); +} diff --git a/modules/system/system.install b/modules/system/system.install index df0db710c..b70d64f32 100644 --- a/modules/system/system.install +++ b/modules/system/system.install @@ -2729,6 +2729,26 @@ function system_update_7061(&$sandbox) { } if (!isset($sandbox['progress'])) { + // Delete stale rows from {upload} where the fid is not in the {files} table. + db_delete('upload') + ->notExists( + db_select('files', 'f') + ->fields('f', array('fid')) + ->where('f.fid = {upload}.fid') + ) + ->execute(); + + // Delete stale rows from {upload} where the vid is not in the + // {node_revision} table. The table has already been renamed in + // node_update_7001(). + db_delete('upload') + ->notExists( + db_select('node_revision', 'nr') + ->fields('nr', array('vid')) + ->where('nr.vid = {upload}.vid') + ) + ->execute(); + // Retrieve a list of node revisions that have uploaded files attached. // DISTINCT queries are expensive, especially when paged, so we store the // data in its own table for the duration of the update. |