@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator

Remove a very old Herald garbage collection migration

Summary:
Ref T13048. This migration is from January 2012 and probably only impacted Facebook.

It references `HeraldRepetitionPolicyConfig`, which I'd like to change significantly. I initially just replaced the constant with a literal `0`, but I don't think there's any actual value in retaining this migration nowadays.

The cost of removing this migration is: if you installed Phabricator before January 2012 and haven't upgraded since then, you'll have a few more rows in the `APPLIED` table than necessary. Herald will still work correctly.

Test Plan: Reading.

Reviewers: amckinley

Reviewed By: amckinley

Maniphest Tasks: T13048

Differential Revision: https://secure.phabricator.com/D18924

+5 -36
+5 -36
resources/sql/patches/102.heraldcleanup.php
··· 1 1 <?php 2 2 3 - echo pht('Cleaning up old Herald rule applied rows...')."\n"; 4 - $table = new HeraldRule(); 5 - $table->openTransaction(); 6 - $table->beginReadLocking(); 3 + // Once, this migration deleted some unnecessary rows written by Herald before 4 + // January 2012. These rows don't hurt anything, they just cluttered up the 5 + // database a bit. 7 6 8 - $rules = $table->loadAll(); 9 - foreach ($rules as $key => $rule) { 10 - $first_policy = HeraldRepetitionPolicyConfig::toInt( 11 - HeraldRepetitionPolicyConfig::FIRST); 12 - if ($rule->getRepetitionPolicy() != $first_policy) { 13 - unset($rules[$key]); 14 - } 15 - } 16 - 17 - $conn_w = $table->establishConnection('w'); 18 - 19 - $clause = ''; 20 - if ($rules) { 21 - $clause = qsprintf( 22 - $conn_w, 23 - 'WHERE ruleID NOT IN (%Ld)', 24 - mpull($rules, 'getID')); 25 - } 26 - 27 - echo pht('This may take a moment')."\n"; 28 - do { 29 - queryfx( 30 - $conn_w, 31 - 'DELETE FROM %T %Q LIMIT 1000', 32 - HeraldRule::TABLE_RULE_APPLIED, 33 - $clause); 34 - echo '.'; 35 - } while ($conn_w->getAffectedRows()); 36 - 37 - $table->endReadLocking(); 38 - $table->saveTransaction(); 39 - echo "\n".pht('Done.')."\n"; 7 + // The migration was removed in January 2018 to make maintenance on rule 8 + // repetition policies easier.