Changeset View
Changeset View
Standalone View
Standalone View
src/applications/maniphest/editor/ManiphestTransactionEditor.php
Show First 20 Lines • Show All 465 Lines • ▼ Show 20 Lines | private static function disperseBlock( | ||||
// this bulk update as an "INSERT ... ON DUPLICATE KEY UPDATE" unless we | // this bulk update as an "INSERT ... ON DUPLICATE KEY UPDATE" unless we | ||||
// provide default values for ALL of the columns that don't have defaults. | // provide default values for ALL of the columns that don't have defaults. | ||||
// This is gross, but we may be moving enough rows that individual | // This is gross, but we may be moving enough rows that individual | ||||
// queries are unreasonably slow. An alternate construction which might | // queries are unreasonably slow. An alternate construction which might | ||||
// be worth evaluating is to use "CASE". Another approach is to disable | // be worth evaluating is to use "CASE". Another approach is to disable | ||||
// strict mode for this query. | // strict mode for this query. | ||||
$default_str = qsprintf($conn, '%s', ''); | |||||
$default_int = qsprintf($conn, '%d', 0); | |||||
$extra_columns = array( | $extra_columns = array( | ||||
'phid' => '""', | 'phid' => $default_str, | ||||
'authorPHID' => '""', | 'authorPHID' => $default_str, | ||||
'status' => '""', | 'status' => $default_str, | ||||
'priority' => 0, | 'priority' => $default_int, | ||||
'title' => '""', | 'title' => $default_str, | ||||
'description' => '""', | 'description' => $default_str, | ||||
'dateCreated' => 0, | 'dateCreated' => $default_int, | ||||
'dateModified' => 0, | 'dateModified' => $default_int, | ||||
'mailKey' => '""', | 'mailKey' => $default_str, | ||||
'viewPolicy' => '""', | 'viewPolicy' => $default_str, | ||||
'editPolicy' => '""', | 'editPolicy' => $default_str, | ||||
'ownerOrdering' => '""', | 'ownerOrdering' => $default_str, | ||||
'spacePHID' => '""', | 'spacePHID' => $default_str, | ||||
'bridgedObjectPHID' => '""', | 'bridgedObjectPHID' => $default_str, | ||||
'properties' => '""', | 'properties' => $default_str, | ||||
'points' => 0, | 'points' => $default_int, | ||||
'subtype' => '""', | 'subtype' => $default_str, | ||||
); | ); | ||||
$defaults = implode(', ', $extra_columns); | |||||
$sql = array(); | $sql = array(); | ||||
$offset = 0; | $offset = 0; | ||||
// Often, we'll have more room than we need in the range. Distribute the | // Often, we'll have more room than we need in the range. Distribute the | ||||
// tasks evenly over the whole range so that we're less likely to end up | // tasks evenly over the whole range so that we're less likely to end up | ||||
// with tasks spaced exactly the minimum distance apart, which may | // with tasks spaced exactly the minimum distance apart, which may | ||||
// get shifted again later. We have one fewer space to distribute than we | // get shifted again later. We have one fewer space to distribute than we | ||||
// have tasks. | // have tasks. | ||||
Show All 11 Lines | foreach ($rows as $row) { | ||||
// of where it is ending up so we can return the new subpriority. | // of where it is ending up so we can return the new subpriority. | ||||
$id = $row['id']; | $id = $row['id']; | ||||
if ($id == $task_id) { | if ($id == $task_id) { | ||||
$result = $subpriority; | $result = $subpriority; | ||||
} | } | ||||
$sql[] = qsprintf( | $sql[] = qsprintf( | ||||
$conn, | $conn, | ||||
'(%d, %Q, %f)', | '(%d, %LQ, %f)', | ||||
$id, | $id, | ||||
$defaults, | $extra_columns, | ||||
$subpriority); | $subpriority); | ||||
$offset++; | $offset++; | ||||
} | } | ||||
foreach (PhabricatorLiskDAO::chunkSQL($sql) as $chunk) { | foreach (PhabricatorLiskDAO::chunkSQL($sql) as $chunk) { | ||||
queryfx( | queryfx( | ||||
$conn, | $conn, | ||||
'INSERT INTO %T (id, %Q, subpriority) VALUES %LQ | 'INSERT INTO %T (id, %LC, subpriority) VALUES %LQ | ||||
ON DUPLICATE KEY UPDATE subpriority = VALUES(subpriority)', | ON DUPLICATE KEY UPDATE subpriority = VALUES(subpriority)', | ||||
$task->getTableName(), | $task->getTableName(), | ||||
implode(', ', array_keys($extra_columns)), | array_keys($extra_columns), | ||||
$chunk); | $chunk); | ||||
} | } | ||||
return $result; | return $result; | ||||
} | } | ||||
protected function validateAllTransactions( | protected function validateAllTransactions( | ||||
PhabricatorLiskDAO $object, | PhabricatorLiskDAO $object, | ||||
▲ Show 20 Lines • Show All 469 Lines • Show Last 20 Lines |