mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/DiscussionTools
synced 2024-11-11 17:02:28 +00:00
ThreadItemStore: Ignore duplicates caused by duplicate executions
For some unknown reason our updates are being processed more than once
at the same time. Ignore or work around the "duplicate entry" errors
caused by that.
Bug: T323080
Bug: T341811
Change-Id: Iaae1dc2d5ed5bf4ac6760fb1d39dc21f2af89e9a
(cherry picked from commit a783b9371f
)
This commit is contained in:
parent
a9217efa79
commit
0f9fa35896
|
@ -499,7 +499,8 @@ class ThreadItemStore {
|
|||
'itp_oldest_revision_id' => $rev->getId(),
|
||||
'itp_newest_revision_id' => $rev->getId(),
|
||||
],
|
||||
$method
|
||||
$method,
|
||||
[ 'IGNORE' ]
|
||||
);
|
||||
} else {
|
||||
$oldestTime = ( new MWTimestamp( $itemPagesRow->oldest_rev_timestamp ) )->getTimestamp( TS_MW );
|
||||
|
@ -554,14 +555,15 @@ class ThreadItemStore {
|
|||
'itr_headinglevel' => $item->isPlaceholderHeading() ? null : $item->getHeadingLevel(),
|
||||
] : [] );
|
||||
|
||||
$itemRevisionsConds = [
|
||||
'itr_itemid_id' => $itemIdsIds[ $item->getId() ],
|
||||
'itr_items_id' => $itemsIds[ $item->getId() ],
|
||||
'itr_revision_id' => $rev->getId(),
|
||||
];
|
||||
$itemRevisionsId = $dbw->newSelectQueryBuilder()
|
||||
->from( 'discussiontools_item_revisions' )
|
||||
->field( 'itr_id' )
|
||||
->where( [
|
||||
'itr_itemid_id' => $itemIdsIds[ $item->getId() ],
|
||||
'itr_items_id' => $itemsIds[ $item->getId() ],
|
||||
'itr_revision_id' => $rev->getId(),
|
||||
] )
|
||||
->where( $itemRevisionsConds )
|
||||
->caller( $method )
|
||||
->fetchField();
|
||||
if ( $itemRevisionsId === false ) {
|
||||
|
@ -591,15 +593,29 @@ class ThreadItemStore {
|
|||
$method
|
||||
);
|
||||
$itemRevisionsId = $itemRevisionsUpdateId;
|
||||
$didInsert = true;
|
||||
} else {
|
||||
$dbw->insert(
|
||||
'discussiontools_item_revisions',
|
||||
$newOrUpdateRevRow,
|
||||
$method
|
||||
$itemRevisionsId = $this->findOrInsertIdButTryHarder(
|
||||
static function ( $dbw ) use ( $itemRevisionsConds, $method ) {
|
||||
return $dbw->newSelectQueryBuilder()
|
||||
->from( 'discussiontools_item_revisions' )
|
||||
->field( 'itr_id' )
|
||||
->where( $itemRevisionsConds )
|
||||
->caller( $method )
|
||||
->fetchField();
|
||||
},
|
||||
static function ( $dbw ) use ( $newOrUpdateRevRow, $method ) {
|
||||
$dbw->insert(
|
||||
'discussiontools_item_revisions',
|
||||
$newOrUpdateRevRow,
|
||||
$method,
|
||||
[ 'IGNORE' ]
|
||||
);
|
||||
return $dbw->insertId();
|
||||
},
|
||||
$didInsert
|
||||
);
|
||||
$itemRevisionsId = $dbw->insertId();
|
||||
}
|
||||
$didInsert = true;
|
||||
}
|
||||
|
||||
$itemRevisionsIds[ $item->getId() ] = $itemRevisionsId;
|
||||
|
|
Loading…
Reference in a new issue