mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-04 20:52:43 +01:00
8fab8d8a18
Summary: Ref T13244. See PHI1055. (Earlier, see D20091 and PHI1047.) Previously, we expanded the Owners package autoreview rules from "Yes/No" to several "Review (Blocking) If Non-Owner Author Not Subscribed via Package" kinds of rules. The sky didn't fall and this feature didn't turn into "Herald-in-Owners", so I'm comfortable doing something similar to the "Audit" rules. PHI1055 is a request for a way to configure slightly different audit behavior, and expanding the options seems like a good approach to satisfy the use case. Prepare to add more options by moving everything into a class that defines all the behavior of different states, and converting the "0/1" boolean column to a text column. Test Plan: - Created several packages, some with and some without auditing. - Inspected database for: package state; and associated transactions. - Ran the migrations. - Inspected database to confirm that state and transactions migrated correctly. - Reviewed transaction logs. - Created and edited packages and audit state. - Viewed the "Package List" element in Diffusion. - Pulled package information with `owners.search`, got sensible results. - Edited package audit status with `owners.edit`. Reviewers: amckinley Reviewed By: amckinley Subscribers: PHID-OPKG-gm6ozazyms6q6i22gyam Maniphest Tasks: T13244 Differential Revision: https://secure.phabricator.com/D20124
41 lines
979 B
PHP
41 lines
979 B
PHP
<?php
|
|
|
|
$table = new PhabricatorOwnersPackageTransaction();
|
|
$conn = $table->establishConnection('w');
|
|
$iterator = new LiskRawMigrationIterator($conn, $table->getTableName());
|
|
|
|
// Migrate "Auditing State" transactions for Owners Packages from old values
|
|
// (which were "0" or "1", as JSON integer literals, without quotes) to new
|
|
// values (which are JSON strings, with quotes).
|
|
|
|
foreach ($iterator as $row) {
|
|
if ($row['transactionType'] !== 'owners.auditing') {
|
|
continue;
|
|
}
|
|
|
|
$old_value = (int)$row['oldValue'];
|
|
$new_value = (int)$row['newValue'];
|
|
|
|
if (!$old_value) {
|
|
$old_value = 'none';
|
|
} else {
|
|
$old_value = 'audit';
|
|
}
|
|
|
|
if (!$new_value) {
|
|
$new_value = 'none';
|
|
} else {
|
|
$new_value = 'audit';
|
|
}
|
|
|
|
$old_value = phutil_json_encode($old_value);
|
|
$new_value = phutil_json_encode($new_value);
|
|
|
|
queryfx(
|
|
$conn,
|
|
'UPDATE %R SET oldValue = %s, newValue = %s WHERE id = %d',
|
|
$table,
|
|
$old_value,
|
|
$new_value,
|
|
$row['id']);
|
|
}
|