diff --git a/echo.sql b/echo.sql index f9ad4f80f..d69364989 100644 --- a/echo.sql +++ b/echo.sql @@ -15,10 +15,6 @@ CREATE TABLE /*_*/echo_event ( -- If the event doesn't have an agent, both fields are null. event_agent_id int unsigned null, event_agent_ip varchar(39) binary null, - -- Unused, should be removed (T136427) - event_page_namespace int unsigned null, - -- Unused, should be removed (T136427) - event_page_title varchar(255) binary null, -- JSON blob with additional information about the event event_extra BLOB NULL, -- Page ID of the page the event happened on, if any (key to page_id) diff --git a/includes/EchoHooks.php b/includes/EchoHooks.php index 7290d12a5..e2a21268c 100644 --- a/includes/EchoHooks.php +++ b/includes/EchoHooks.php @@ -225,6 +225,14 @@ class EchoHooks { "$dir/db_patches/patch-add-event_page_id-index.sql" ); $updater->dropExtensionIndex( 'echo_notification', 'user_event', "$dir/db_patches/patch-notification-pk.sql" ); + // Can't use addPostDatabaseUpdateMaintenance() here because that would + // run the migration script after dropping the fields + $updater->addExtensionUpdate( [ 'runMaintenance', 'UpdateEchoSchemaForSuppression', + 'extensions/Echo/maintenance/updateEchoSchemaForSuppression.php' ] ); + $updater->dropExtensionField( 'echo_event', 'event_page_namespace', + "$dir/db_patches/patch-drop-echo_event-event_page_namespace.sql" ); + $updater->dropExtensionField( 'echo_event', 'event_page_title', + "$dir/db_patches/patch-drop-echo_event-event_page_title.sql" ); } /** diff --git a/includes/api/ApiEchoNotifications.php b/includes/api/ApiEchoNotifications.php index 22641262b..ae17a127d 100644 --- a/includes/api/ApiEchoNotifications.php +++ b/includes/api/ApiEchoNotifications.php @@ -444,8 +444,6 @@ class ApiEchoNotifications extends ApiQueryBase { $row->event_agent_id = $user->getId(); $row->event_agent_ip = null; $row->event_page_id = null; - $row->event_page_namespace = null; - $row->event_page_title = null; $row->event_extra = serialize( [ 'section' => $section ?: 'all', 'wikis' => $wikis, diff --git a/includes/model/Event.php b/includes/model/Event.php index bec10f91f..573798630 100644 --- a/includes/model/Event.php +++ b/includes/model/Event.php @@ -736,8 +736,6 @@ class EchoEvent extends EchoAbstractEntity implements Bundleable { 'event_variant', 'event_agent_id', 'event_agent_ip', - 'event_page_namespace', - 'event_page_title', 'event_extra', 'event_page_id', 'event_deleted', diff --git a/maintenance/updateEchoSchemaForSuppression.php b/maintenance/updateEchoSchemaForSuppression.php index 1e0a73f1f..e0877c8b5 100644 --- a/maintenance/updateEchoSchemaForSuppression.php +++ b/maintenance/updateEchoSchemaForSuppression.php @@ -39,7 +39,15 @@ class UpdateEchoSchemaForSuppression extends LoggedUpdateMaintenance { public function doDBUpdates() { global $wgEchoCluster; - $reader = new BatchRowIterator( MWEchoDbFactory::getDB( DB_REPLICA ), $this->table, $this->idField, $this->mBatchSize ); + $dbr = MWEchoDbFactory::getDB( DB_REPLICA ); + $dbw = MWEchoDbFactory::getDB( DB_MASTER ); + + if ( !$dbw->fieldExists( 'echo_event', 'event_page_title' ) ) { + $this->output( "No event_page_title field, skipping migration from event_page_title to event_page_id\n" ); + return true; + } + + $reader = new BatchRowIterator( $dbr, $this->table, $this->idField, $this->mBatchSize ); $reader->addConditions( [ "event_page_title IS NOT NULL", "event_page_id" => null, @@ -48,7 +56,7 @@ class UpdateEchoSchemaForSuppression extends LoggedUpdateMaintenance { $updater = new BatchRowUpdate( $reader, - new BatchRowWriter( MWEchoDbFactory::getDB( DB_MASTER ), $this->table, $wgEchoCluster ), + new BatchRowWriter( $dbw, $this->table, $wgEchoCluster ), new EchoSuppressionRowUpdateGenerator ); $updater->setOutput( function ( $text ) {