mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-18 19:40:55 +01:00
8bbee92139
Summary: Ref T13072. Further modularize build messages by applying each one in a separate transaction type. This makes it easier to add new types of messages (although I have no particular plans to do this, offhand) and reduces the amount of switch-boilerplate. This will probably also simplify validating "harbormaster.sendmessage". Test Plan: - Applied all commands. - Ran migration, saw transactions render properly Subscribers: PHID-OPKG-gm6ozazyms6q6i22gyam Maniphest Tasks: T13072 Differential Revision: https://secure.phabricator.com/D21690
34 lines
864 B
PHP
34 lines
864 B
PHP
<?php
|
|
|
|
// See T13072. Turn the old "process a command" transaction into modular
|
|
// transactions that each handle one particular type of command.
|
|
|
|
$xactions_table = new HarbormasterBuildTransaction();
|
|
$xactions_conn = $xactions_table->establishConnection('w');
|
|
$row_iterator = new LiskRawMigrationIterator(
|
|
$xactions_conn,
|
|
$xactions_table->getTableName());
|
|
|
|
$map = array(
|
|
'"pause"' => 'message/pause',
|
|
'"abort"' => 'message/abort',
|
|
'"resume"' => 'message/resume',
|
|
'"restart"' => 'message/restart',
|
|
);
|
|
|
|
foreach ($row_iterator as $row) {
|
|
if ($row['transactionType'] !== 'harbormaster:build:command') {
|
|
continue;
|
|
}
|
|
|
|
$raw_value = $row['newValue'];
|
|
|
|
if (isset($map[$raw_value])) {
|
|
queryfx(
|
|
$xactions_conn,
|
|
'UPDATE %R SET transactionType = %s WHERE id = %d',
|
|
$xactions_table,
|
|
$map[$raw_value],
|
|
$row['id']);
|
|
}
|
|
}
|