2012-01-25 20:53:39 +01:00
|
|
|
<?php
|
|
|
|
|
2015-05-22 09:27:56 +02:00
|
|
|
echo pht('Cleaning up old Herald rule applied rows...')."\n";
|
2013-01-17 02:55:39 +01:00
|
|
|
$table = new HeraldRule();
|
|
|
|
$table->openTransaction();
|
|
|
|
$table->beginReadLocking();
|
2012-01-25 20:53:39 +01:00
|
|
|
|
2013-01-17 02:55:39 +01:00
|
|
|
$rules = $table->loadAll();
|
2012-01-25 20:53:39 +01:00
|
|
|
foreach ($rules as $key => $rule) {
|
|
|
|
$first_policy = HeraldRepetitionPolicyConfig::toInt(
|
|
|
|
HeraldRepetitionPolicyConfig::FIRST);
|
|
|
|
if ($rule->getRepetitionPolicy() != $first_policy) {
|
|
|
|
unset($rules[$key]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-17 02:55:39 +01:00
|
|
|
$conn_w = $table->establishConnection('w');
|
2012-01-25 20:53:39 +01:00
|
|
|
|
|
|
|
$clause = '';
|
|
|
|
if ($rules) {
|
|
|
|
$clause = qsprintf(
|
|
|
|
$conn_w,
|
|
|
|
'WHERE ruleID NOT IN (%Ld)',
|
|
|
|
mpull($rules, 'getID'));
|
|
|
|
}
|
|
|
|
|
2015-05-22 09:27:56 +02:00
|
|
|
echo pht('This may take a moment')."\n";
|
2012-01-25 20:53:39 +01:00
|
|
|
do {
|
|
|
|
queryfx(
|
|
|
|
$conn_w,
|
|
|
|
'DELETE FROM %T %Q LIMIT 1000',
|
|
|
|
HeraldRule::TABLE_RULE_APPLIED,
|
|
|
|
$clause);
|
2014-06-09 20:36:49 +02:00
|
|
|
echo '.';
|
2012-01-25 20:53:39 +01:00
|
|
|
} while ($conn_w->getAffectedRows());
|
|
|
|
|
2013-01-17 02:55:39 +01:00
|
|
|
$table->endReadLocking();
|
|
|
|
$table->saveTransaction();
|
2015-05-22 09:27:56 +02:00
|
|
|
echo "\n".pht('Done.')."\n";
|