From ca32f08966f1b51fcb19460f0996bb0c4048e6fe Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Sat, 3 Dec 2011 13:29:22 +0100 Subject: Update to MediaWiki 1.18.0 * also update ArchLinux skin to chagnes in MonoBook * Use only css to hide our menu bar when printing --- extensions/Renameuser/RenameUserJob.php | 99 +++++++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 extensions/Renameuser/RenameUserJob.php (limited to 'extensions/Renameuser/RenameUserJob.php') diff --git a/extensions/Renameuser/RenameUserJob.php b/extensions/Renameuser/RenameUserJob.php new file mode 100644 index 00000000..6da2c7e6 --- /dev/null +++ b/extensions/Renameuser/RenameUserJob.php @@ -0,0 +1,99 @@ +params['table']; + $column = $this->params['column']; + $oldname = $this->params['oldname']; + $userID = isset( $this->params['userID'] ) ? $this->params['userID'] : null; + $uidColumn = isset( $this->params['uidColumn'] ) ? $this->params['uidColumn'] : null; + $timestampColumn = isset( $this->params['timestampColumn'] ) ? $this->params['timestampColumn'] : null; + $minTimestamp = $this->params['minTimestamp']; + $maxTimestamp = $this->params['maxTimestamp']; + $uniqueKey = isset( $this->params['uniqueKey'] ) ? $this->params['uniqueKey'] : null; + $keyId = isset( $this->params['keyId'] ) ? $this->params['keyId'] : null; + $newname = $this->params['newname']; + $count = $this->params['count']; + + # Conditions like "*_user_text = 'x' + $conds = array( $column => $oldname ); + # If user ID given, add that to condition to avoid rename collisions. + if ( isset( $userID ) ) { + $conds[$uidColumn] = $userID; + } + # Bound by timestamp if given + if ( isset( $timestampColumn ) ) { + $conds[] = "$timestampColumn >= '$minTimestamp'"; + $conds[] = "$timestampColumn <= '$maxTimestamp'"; + # Otherwise, bound by key (B/C) + } elseif ( isset( $uniqueKey ) ) { + $conds[$uniqueKey] = $keyId; + } else { + wfDebug( 'RenameUserJob::run - invalid job row given' ); // this shouldn't happen + return false; + } + # Update a chuck of rows! + $dbw->update( $table, + array( $column => $newname ), + $conds, + __METHOD__ + ); + # Special case: revisions may be deleted while renaming... + if ( $table == 'revision' && isset( $timestampColumn ) ) { + $actual = $dbw->affectedRows(); + # If some revisions were not renamed, they may have been deleted. + # Do a pass on the archive table to get these straglers... + if ( $actual < $count ) { + $dbw->update( 'archive', + array( 'ar_user_text' => $newname ), + array( 'ar_user_text' => $oldname, + 'ar_user' => $userID, + // No user,rev_id index, so use timestamp to bound + // the rows. This can use the user,timestamp index. + "ar_timestamp >= '$minTimestamp'", + "ar_timestamp <= '$maxTimestamp'" ), + __METHOD__ + ); + } + } + # Special case: revisions may be restored while renaming... + if ( $table == 'archive' && isset( $timestampColumn ) ) { + $actual = $dbw->affectedRows(); + # If some revisions were not renamed, they may have been restored. + # Do a pass on the revision table to get these straglers... + if ( $actual < $count ) { + $dbw->update( 'revision', + array( 'rev_user_text' => $newname ), + array( 'rev_user_text' => $oldname, + 'rev_user' => $userID, + // No user,rev_id index, so use timestamp to bound + // the rows. This can use the user,timestamp index. + "rev_timestamp >= '$minTimestamp'", + "rev_timestamp <= '$maxTimestamp'" ), + __METHOD__ + ); + } + } + return true; + } +} -- cgit v1.2.3-54-g00ecf