aboutsummaryrefslogtreecommitdiffstats
path: root/maintenance/rebuildrecentchanges.php
diff options
context:
space:
mode:
authorBartosz Dziewoński <matma.rex@gmail.com>2015-12-29 02:16:10 +0100
committerBartosz Dziewoński <matma.rex@gmail.com>2016-01-21 23:02:54 +0100
commit59f5c5fdd78cfc46d7db73075f23abccaad3ac1f (patch)
tree0ab4073e4f05622f469260e0a2ab3d42271af071 /maintenance/rebuildrecentchanges.php
parenta36c567fa636af4a7c96cdeff521b64d6f291f22 (diff)
downloadmediawikicore-59f5c5fdd78cfc46d7db73075f23abccaad3ac1f.tar.gz
mediawikicore-59f5c5fdd78cfc46d7db73075f23abccaad3ac1f.zip
rebuildrecentchanges.php: Don't create duplicate entries for upload logs
There are a few cases where we generate both a page revision and a log entry for a single action (upload; in the future, maybe also move, protect), but only one recent changes entry (matching the log entry). Bug: T116809 Change-Id: Ib95a6cb57a942a0758091ff2db9d29f3c0048598
Diffstat (limited to 'maintenance/rebuildrecentchanges.php')
-rw-r--r--maintenance/rebuildrecentchanges.php41
1 files changed, 41 insertions, 0 deletions
diff --git a/maintenance/rebuildrecentchanges.php b/maintenance/rebuildrecentchanges.php
index b6421f347bf9..34560fd4cb08 100644
--- a/maintenance/rebuildrecentchanges.php
+++ b/maintenance/rebuildrecentchanges.php
@@ -41,6 +41,7 @@ class RebuildRecentchanges extends Maintenance {
$this->rebuildRecentChangesTablePass2();
$this->rebuildRecentChangesTablePass3();
$this->rebuildRecentChangesTablePass4();
+ $this->rebuildRecentChangesTablePass5();
$this->purgeFeeds();
$this->output( "Done.\n" );
}
@@ -282,6 +283,46 @@ class RebuildRecentchanges extends Maintenance {
}
/**
+ * Rebuild pass 5: Delete duplicate entries where we generate both a page revision and a log entry
+ * for a single action (upload only, at the moment, but potentially also move, protect, ...).
+ */
+ private function rebuildRecentChangesTablePass5() {
+ $dbw = wfGetDB( DB_MASTER );
+
+ $this->output( "Removing duplicate revision and logging entries...\n" );
+
+ $res = $dbw->select(
+ array( 'logging', 'log_search' ),
+ array( 'ls_value', 'ls_log_id' ),
+ array(
+ 'ls_log_id = log_id',
+ 'ls_field' => 'associated_rev_id',
+ 'log_type' => 'upload',
+ ),
+ __METHOD__
+ );
+ foreach ( $res as $obj ) {
+ $rev_id = $obj->ls_value;
+ $log_id = $obj->ls_log_id;
+
+ // Mark the logging row as having an associated rev id
+ $dbw->update(
+ 'recentchanges',
+ /*SET*/ array( 'rc_this_oldid' => $rev_id ),
+ /*WHERE*/ array( 'rc_logid' => $log_id ),
+ __METHOD__
+ );
+
+ // Delete the revision row
+ $dbw->delete(
+ 'recentchanges',
+ /*WHERE*/ array( 'rc_this_oldid' => $rev_id, 'rc_logid' => 0 ),
+ __METHOD__
+ );
+ }
+ }
+
+ /**
* Purge cached feeds in $messageMemc
*/
private function purgeFeeds() {