From c6732fe6f7d09137088212a82e930b9fb44ab66e Mon Sep 17 00:00:00 2001 From: Brad Jorsch Date: Tue, 12 Nov 2019 10:08:24 -0500 Subject: [PATCH] cleanupUsersWithNoId.php: Handle missing fields The maintenance script might be run to clean up users with no ID in the `revision` table even after the other tables have had the ID and name fields removed (in favor of the actor ID fields). Handle this situation so as to not error out. Bug: T238043 Change-Id: Ie84dab4218d816106bf4b0e61f020148730220f0 (cherry picked from commit f5b78e9c313d8c54cffe61cc24fe82367b023d31) --- maintenance/cleanupUsersWithNoId.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/maintenance/cleanupUsersWithNoId.php b/maintenance/cleanupUsersWithNoId.php index f7fd9d5260..5232f913bd 100644 --- a/maintenance/cleanupUsersWithNoId.php +++ b/maintenance/cleanupUsersWithNoId.php @@ -131,13 +131,18 @@ class CleanupUsersWithNoId extends LoggedUpdateMaintenance { return; } + $dbw = $this->getDB( DB_MASTER ); + if ( !$dbw->fieldExists( $table, $idField ) || + !$dbw->fieldExists( $table, $nameField ) + ) { + $this->output( "Skipping $table, fields $idField and/or $nameField do not exist\n" ); + return; + } + $primaryKey = (array)$primaryKey; $pkFilter = array_flip( $primaryKey ); - $this->output( - "Beginning cleanup of $table\n" - ); + $this->output( "Beginning cleanup of $table\n" ); - $dbw = $this->getDB( DB_MASTER ); $next = '1=1'; $countAssigned = 0; $countPrefixed = 0; -- 2.20.1