2012-01-25 20:53:39 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
echo "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'));
|
|
|
|
}
|
|
|
|
|
2014-06-09 20:36:49 +02:00
|
|
|
echo 'This may take a moment';
|
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();
|
|
|
|
echo "\nDone.\n";
|