1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-09-20 01:08:50 +02:00

Minor, fix this patch so it applies after channel got deleted from the event table.

Test plan: Applied the patch explicitly with `--apply`.
This commit is contained in:
epriestley 2013-02-25 21:22:38 -08:00
parent 32d23254c9
commit 0f22854823

View file

@ -11,33 +11,46 @@ $event_table->beginReadLocking();
$channel_table->beginReadLocking();
$events = new LiskMigrationIterator($event_table);
$conn_w = $channel_table->establishConnection('w');
foreach ($events as $event) {
if ($event->getChannelID()) {
continue;
}
$matched = $channel_table->loadOneWhere(
"channelName = %s AND serviceName = %s AND serviceType = %s",
$event->getChannel(),
$event_row = queryfx_one(
$conn_w,
'SELECT channel FROM %T WHERE id = %d',
$event->getTable(),
$event->getChannelID());
$event_channel = $event_row['channel'];
$matched = queryfx_one(
$conn_w,
'SELECT * FROM %T WHERE
channelName = %s AND serviceName = %s AND serviceType = %s',
$event_channel,
'',
'');
if (!$matched) {
$matched = id(new PhabricatorChatLogChannel())
->setChannelName($event->getChannel())
->setChannelName($event_channel)
->setServiceType('')
->setServiceName('')
->setViewPolicy(PhabricatorPolicies::POLICY_USER)
->setEditPolicy(PhabricatorPolicies::POLICY_USER)
->save();
$matched_id = $matched->getID();
} else {
$matched_id = $matched['id'];
}
queryfx(
$event->establishConnection('w'),
'UPDATE %T SET channelID = %d WHERE id = %d',
$event->getTableName(),
$matched->getID(),
$matched_id,
$event->getID());
}