From a160006defd02442cd3fa0f098094385ebb8fcf1 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Sat, 13 Nov 2010 01:48:14 +0000 Subject: - Patch #966238 by cosmicdreams, bfroehle, catch, mfb, carlos8f, marcingy: system_update_7061() stops migrating data if upload.fid is not found in files table, resulting in data loss. --- modules/simpletest/tests/upgrade/upgrade.upload.test | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'modules/simpletest/tests/upgrade/upgrade.upload.test') diff --git a/modules/simpletest/tests/upgrade/upgrade.upload.test b/modules/simpletest/tests/upgrade/upgrade.upload.test index efbff1114..761d6558d 100644 --- a/modules/simpletest/tests/upgrade/upgrade.upload.test +++ b/modules/simpletest/tests/upgrade/upgrade.upload.test @@ -20,6 +20,8 @@ class UploadUpgradePathTestCase extends UpgradePathTestCase { drupal_get_path('module', 'simpletest') . '/tests/upgrade/drupal-6.upload.database.php', ); parent::setUp(); + // Set a small batch size to test multiple iterations of the batch. + $this->variable_set('upload_update_batch_size', 2); $this->uninstallModulesExcept(array('upload')); } @@ -36,8 +38,11 @@ class UploadUpgradePathTestCase extends UpgradePathTestCase { $query->fieldCondition('upload'); $entities = $query->execute(); $revisions = $entities['node']; - // Node revisions 50-52 should have uploaded files. - $this->assertTrue((isset($revisions[50]) && isset($revisions[51]) && isset($revisions[52])), 'Nodes with uploaded files now contain filefield data.'); + // Node revision 50 should not have uploaded files, as the entry in {files} + // is corrupted. + $this->assertFalse((isset($revisions[50])), 'Nodes with missing files do not contain filefield data.'); + // Node revisions 51-53 should have uploaded files. + $this->assertTrue((isset($revisions[51]) && isset($revisions[52]) && isset($revisions[53])), 'Nodes with uploaded files now contain filefield data.'); // The test database lists uploaded filenames in the body of each node with // uploaded files attached. Make sure all files are there in the same order. foreach ($revisions as $vid => $revision) { @@ -58,9 +63,7 @@ class UploadUpgradePathTestCase extends UpgradePathTestCase { foreach ($files as $file) { $filenames[] = $file['filename']; } - - $diff = array_diff($filenames, $recorded_filenames); - $this->assertTrue(empty($diff), 'The uploaded files are present in the same order after the upgrade.'); + $this->assertIdentical($filenames, $recorded_filenames, 'The uploaded files are present in the same order after the upgrade.'); } } } -- cgit v1.2.3