Steffen
Well-known member
- Affected version
- 2.3.0 RC5
XF\Install\Upgrade\Version2030055::step2()
takes roughly 30 minutes for 1.2 million attachment_data rows. Can't this step be simplified as follows?
Diff:
--- a/src/XF/Install/Upgrade/2030055-230rc5.php
+++ b/src/XF/Install/Upgrade/2030055-230rc5.php
@@ -20,44 +20,12 @@ class Version2030055 extends AbstractUpgrade
});
}
- public function step2(int $position, array $stepData)
+ public function step2(): void
{
- if (!isset($stepData['max']))
- {
- $stepData['max'] = $this->db()->fetchOne('
- SELECT MAX(data_id)
- FROM xf_attachment_data
- ');
- }
- $data = $this->db()->fetchPairs(
- $this->db()->limit('
- SELECT data_id, file_hash
- FROM xf_attachment_data
- WHERE data_id > ?
- AND file_key = \'\'
- ORDER BY data_id
- ', 500),
- [$position]
- );
- if (!$data)
- {
- return true;
- }
-
- $next = 0;
-
- foreach ($data AS $id => $hash)
- {
- $next = $id;
-
- $this->executeUpgradeQuery("
- UPDATE xf_attachment_data
- SET file_key = ?
- WHERE data_id = ?
- ", [$hash, $id]);
- }
-
- return [$next, "{$next} / {$stepData['max']}", $stepData];
+ $this->executeUpgradeQuery("
+ UPDATE xf_attachment_data
+ SET file_key = file_hash
+ ");
}
public function step3(): void