mirror of
https://we.phorge.it/source/phorge.git
synced 2024-10-19 15:18:51 +02:00
e10fdbe77e
Summary: Patches often read from slaves (possibly stale data) and use that information to write on master. It causes problems when applying more patches quickly after each other because data created in previous patch may not be replicated yet. Test Plan: $ bin/storage upgrade Reviewers: epriestley Reviewed By: epriestley CC: aran, Korvin Differential Revision: https://secure.phabricator.com/D4483
51 lines
1.3 KiB
PHP
51 lines
1.3 KiB
PHP
<?php
|
|
|
|
echo "Checking for rules that can be converted to 'personal'. ";
|
|
$table = new HeraldRule();
|
|
$table->openTransaction();
|
|
$table->beginReadLocking();
|
|
|
|
$rules = $table->loadAll();
|
|
|
|
foreach ($rules as $rule) {
|
|
if ($rule->getRuleType() !== HeraldRuleTypeConfig::RULE_TYPE_PERSONAL) {
|
|
$actions = $rule->loadActions();
|
|
$can_be_personal = true;
|
|
foreach ($actions as $action) {
|
|
$target = $action->getTarget();
|
|
if (is_array($target)) {
|
|
if (count($target) > 1) {
|
|
$can_be_personal = false;
|
|
break;
|
|
} else {
|
|
$targetPHID = head($target);
|
|
if ($targetPHID !== $rule->getAuthorPHID()) {
|
|
$can_be_personal = false;
|
|
break;
|
|
}
|
|
}
|
|
} else if ($target) {
|
|
if ($target !== $rule->getAuthorPHID()) {
|
|
$can_be_personal = false;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
if ($can_be_personal) {
|
|
$rule->setRuleType(HeraldRuleTypeConfig::RULE_TYPE_PERSONAL);
|
|
queryfx(
|
|
$rule->establishConnection('w'),
|
|
'UPDATE %T SET ruleType = %s WHERE id = %d',
|
|
$rule->getTableName(),
|
|
$rule->getRuleType(),
|
|
$rule->getID());
|
|
|
|
echo "Setting rule '" . $rule->getName() . "' to personal. ";
|
|
}
|
|
}
|
|
}
|
|
|
|
$table->endReadLocking();
|
|
$table->saveTransaction();
|
|
echo "Done.\n";
|