jenkins-bot has submitted this change and it was merged.
Change subject: Add maintenance script to update page IDs of topic-resolved
notifications
..
Add maintenance script to update page IDs of topic-resolved notifications
Change topic titles to board titles.
Bug: T137501
Change-Id: I5bef3ce6017a6f02668d7d83ec0f01762af2a16c
---
A maintenance/FlowUpdateResolvedNotifTitles.php
1 file changed, 94 insertions(+), 0 deletions(-)
Approvals:
Sbisson: Looks good to me, approved
jenkins-bot: Verified
diff --git a/maintenance/FlowUpdateResolvedNotifTitles.php
b/maintenance/FlowUpdateResolvedNotifTitles.php
new file mode 100644
index 000..57ed708
--- /dev/null
+++ b/maintenance/FlowUpdateResolvedNotifTitles.php
@@ -0,0 +1,94 @@
+mDescription = "Update the titles of flow-topic-resolved
Echo events to point to boards instead of topics";
+
+ $this->setBatchSize( 500 );
+ }
+
+ public function getUpdateKey() {
+ return __CLASS__;
+ }
+
+ public function doDBUpdates() {
+ $dbFactory = MWEchoDbFactory::newFromDefault();
+ $dbw = $dbFactory->getEchoDb( DB_MASTER );
+ $dbr = $dbFactory->getEchoDb( DB_SLAVE );
+ // We can't join echo_event with page, because those tables can
be on different
+ // DB clusters. If we had been able to do that, we could have
added
+ // wHERE page_namespace=NS_TOPIC, but instead we have to
examine all rows
+ // and skip the non-NS_TOPIC ones.
+ $iterator = new BatchRowIterator(
+ $dbr,
+ 'echo_event',
+ 'event_id',
+ $this->mBatchSize
+ );
+ $iterator->addConditions( array(
+ 'event_type' => 'flow-topic-resolved',
+ 'event_page_id IS NOT NULL',
+ ) );
+ $iterator->setFetchColumns( array( 'event_page_id' ) );
+
+ $storage = Container::get( 'storage.workflow' );
+
+ $this->output( "Retitling flow-topic-resolved events...\n" );
+
+ $processed = 0;
+ foreach ( $iterator as $batch ) {
+ foreach ( $batch as $row ) {
+ $topicTitle = Title::newFromId(
$row->event_page_id );
+ if ( $topicTitle->getNamespace() !== NS_TOPIC )
{
+ continue;
+ }
+ $boardTitle = null;
+ try {
+ $uuid =
WorkflowLoaderFactory::uuidFromTitle( $topicTitle );
+ $workflow = $storage->get( $uuid );
+ if ( $workflow ) {
+ $boardTitle =
$workflow->getOwnerTitle();
+ }
+ } catch ( Exception $e ) {}
+ if ( $boardTitle ) {
+ $dbw->update(
+ 'echo_event',
+ array( 'event_page_id' =>
$boardTitle->getArticleId() ),
+ array( 'event_id' =>
$row->event_id )
+ );
+ $processed += $dbw->affectedRows();
+ } else {
+ $this->output( "Could not find board
for topic: " . $topicTitle->getPrefixedText() . "\n" );
+ }
+ }
+
+ $this->output( "Updated $processed events.\n" );
+ $dbFactory->waitForSlaves();
+ }
+
+ return true;
+ }
+}
+
+$maintClass = 'FlowUpdateResolvedNotifTitles';
+require_once ( RUN_MAINTENANCE_IF_MAIN );
--
To view, visit https://gerrit.wikimedia.org/r/295435
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I5bef3ce6017a6f02668d7d83ec0f01762af2a16c
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/Flow
Gerrit-Branch: master
Gerrit-Owner: Catrope
Gerrit-Reviewer: Catrope
Gerrit-Reviewer: Matthias Mullie
Gerrit-Reviewer: Sbisson
Gerrit-Reviewer: jenkins-bot <>
___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits