summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathan Haug2010-12-09 21:47:14 +0000
committerNathan Haug2010-12-09 21:47:14 +0000
commitf8a5bd87ee8bff489c6be1c13d6fc369291a421d (patch)
tree71348cafe7760a6c3b2d6d4d68b1f784c9af7d4b
parent4251bfe6d74f2c9eca1182e13634fdd77a73b2bc (diff)
#993698: Infinite loop during update.php 6001 (D5->D6 migration).
-rw-r--r--filefield.install20
1 files changed, 14 insertions, 6 deletions
diff --git a/filefield.install b/filefield.install
index f4d3578..9cafe28 100644
--- a/filefield.install
+++ b/filefield.install
@@ -295,21 +295,28 @@ function filefield_update_6104() {
*/
function _filefield_update_6001_move_operation($field, &$context) {
// Setup the first through
- if (!isset($context['sandbox']['progress'])) {
+ if (!isset($context['sandbox']['processed_files'])) {
$db_info = content_database_info($field);
$context['sandbox']['db_info'] = $db_info;
$context['sandbox']['table'] = $db_info['table'];
$context['sandbox']['col_data'] = $db_info['columns']['data']['column'];
$context['sandbox']['col_desc'] = $db_info['columns']['description']['column'];
$context['sandbox']['max'] = db_result(db_query("SELECT COUNT(*) FROM {". $db_info['table'] ."}"));
- $context['sandbox']['progress'] = 0;
$context['sandbox']['current_node'] = 0;
+ $context['sandbox']['processed_files'] = array();
}
// Work our way through the field values 50 rows at a time.
$limit = 50;
- $result = db_query_range("SELECT * FROM {{$context['sandbox']['table']}} WHERE vid > %d ORDER BY nid ASC", $context['sandbox']['current_node'], 0, $limit);
+ $result = db_query_range("SELECT * FROM {{$context['sandbox']['table']}} WHERE vid >= %d ORDER BY vid ASC", $context['sandbox']['current_node'], 0, $limit);
while ($row = db_fetch_array($result)) {
+ // Do not process the same file twice. This may happen when a node's files
+ // are split across two separate batch update HTTP requests.
+ $delta = isset($row['delta']) ? $row['delta'] : 0;
+ if (isset($context['sandbox']['processed_files'][$row['vid'] . '_' . $delta])) {
+ continue;
+ }
+
// Try to unserialize the data column.
if (!empty($row[$context['sandbox']['col_data']])) {
$data = unserialize($row[$context['sandbox']['col_data']]);
@@ -325,14 +332,15 @@ function _filefield_update_6001_move_operation($field, &$context) {
db_query("UPDATE {{$context['sandbox']['table']}} SET {$context['sandbox']['col_data']} = '%s' WHERE vid = %d", serialize($data), $row['vid']);
// Update our progress information.
- $context['sandbox']['progress']++;
+ $context['sandbox']['processed_files'][$row['vid'] . '_' . $delta] = TRUE;
$context['sandbox']['current_node'] = $row['vid'];
}
// Inform the batch engine that we are not finished,
// and provide an estimation of the completion level we reached.
- if ($context['sandbox']['progress'] != $context['sandbox']['max']) {
- $context['finished'] = $context['sandbox']['progress'] / $context['sandbox']['max'];
+ $processed_count = count($context['sandbox']['processed_files']);
+ if ($processed_count != $context['sandbox']['max']) {
+ $context['finished'] = $processed_count / $context['sandbox']['max'];
}
}