From: Brad Jorsch Date: Tue, 12 Nov 2019 15:08:24 +0000 (-0500) Subject: cleanupUsersWithNoId.php: Handle missing fields X-Git-Tag: 1.34.2~8 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/banques/Category:D?a=commitdiff_plain;h=c6732fe6f7d09137088212a82e930b9fb44ab66e;p=lhc%2Fweb%2Fwiklou.git 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) --- 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;