mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-18 19:40:55 +01: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:
parent
32d23254c9
commit
0f22854823
1 changed files with 18 additions and 5 deletions
|
@ -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());
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue