From e6a6b33567cfa6d23904cff720912693fc412ceb Mon Sep 17 00:00:00 2001 From: umherirrender Date: Sat, 29 Sep 2012 12:25:31 +0200 Subject: [PATCH] (bug 34960) drop unused fields rc_moved_to_ns/rc_moved_to_title Change-Id: I68e8c0bb23f185c0f996a8905f6d437db3080aa1 --- RELEASE-NOTES-1.21 | 1 + includes/RecentChange.php | 19 -------- includes/api/ApiQueryRecentChanges.php | 11 ----- includes/installer/MysqlUpdater.php | 1 + includes/installer/SqliteUpdater.php | 1 + maintenance/archives/patch-rc_moved.sql | 4 ++ .../sqlite/archives/patch-rc_moved.sql | 46 +++++++++++++++++++ maintenance/tables.sql | 4 -- maintenance/updateSearchIndex.php | 16 ++----- 9 files changed, 56 insertions(+), 47 deletions(-) create mode 100644 maintenance/archives/patch-rc_moved.sql create mode 100644 maintenance/sqlite/archives/patch-rc_moved.sql diff --git a/RELEASE-NOTES-1.21 b/RELEASE-NOTES-1.21 index 53e3fd5012..63be7bab42 100644 --- a/RELEASE-NOTES-1.21 +++ b/RELEASE-NOTES-1.21 @@ -19,6 +19,7 @@ production. * (bug 40353) SpecialDoubleRedirect should support interwiki redirects. * (bug 40352) fixDoubleRedirects.php should support interwiki redirects. * (bug 9237) SpecialBrokenRedirect should not list interwiki redirects. +* (bug 34960) Drop unused fields rc_moved_to_ns and rc_moved_to_title from recentchanges table. === API changes in 1.21 === * (bug 35693) ApiQueryImageInfo now suppresses errors when unserializing metadata. diff --git a/includes/RecentChange.php b/includes/RecentChange.php index 332d0390d2..debec69faf 100644 --- a/includes/RecentChange.php +++ b/includes/RecentChange.php @@ -162,17 +162,6 @@ class RecentChange { return $this->mTitle; } - /** - * @return bool|Title - */ - public function getMovedToTitle() { - if( $this->mMovedToTitle === false ) { - $this->mMovedToTitle = Title::makeTitle( $this->mAttribs['rc_moved_to_ns'], - $this->mAttribs['rc_moved_to_title'] ); - } - return $this->mMovedToTitle; - } - /** * Get the User object of the person who performed this change. * @@ -421,8 +410,6 @@ class RecentChange { 'rc_this_oldid' => $newId, 'rc_last_oldid' => $oldId, 'rc_bot' => $bot ? 1 : 0, - 'rc_moved_to_ns' => 0, - 'rc_moved_to_title' => '', 'rc_ip' => self::checkIPAddress( $ip ), 'rc_patrolled' => intval($patrol), 'rc_new' => 0, # obsolete @@ -481,8 +468,6 @@ class RecentChange { 'rc_this_oldid' => $newId, 'rc_last_oldid' => 0, 'rc_bot' => $bot ? 1 : 0, - 'rc_moved_to_ns' => 0, - 'rc_moved_to_title' => '', 'rc_ip' => self::checkIPAddress( $ip ), 'rc_patrolled' => intval($patrol), 'rc_new' => 1, # obsolete @@ -570,8 +555,6 @@ class RecentChange { 'rc_this_oldid' => 0, 'rc_last_oldid' => 0, 'rc_bot' => $user->isAllowed( 'bot' ) ? $wgRequest->getBool( 'bot', true ) : 0, - 'rc_moved_to_ns' => 0, - 'rc_moved_to_title' => '', 'rc_ip' => self::checkIPAddress( $ip ), 'rc_patrolled' => 1, 'rc_new' => 0, # obsolete @@ -624,8 +607,6 @@ class RecentChange { 'rc_this_oldid' => $row->rev_id, 'rc_last_oldid' => isset($row->rc_last_oldid) ? $row->rc_last_oldid : 0, 'rc_bot' => 0, - 'rc_moved_to_ns' => 0, - 'rc_moved_to_title' => '', 'rc_ip' => '', 'rc_id' => $row->rc_id, 'rc_patrolled' => $row->rc_patrolled, diff --git a/includes/api/ApiQueryRecentChanges.php b/includes/api/ApiQueryRecentChanges.php index 7ae4f371ab..84c2332347 100644 --- a/includes/api/ApiQueryRecentChanges.php +++ b/includes/api/ApiQueryRecentChanges.php @@ -214,8 +214,6 @@ class ApiQueryRecentChanges extends ApiQueryGeneratorBase { 'rc_title', 'rc_cur_id', 'rc_type', - 'rc_moved_to_ns', - 'rc_moved_to_title', 'rc_deleted' ) ); @@ -321,12 +319,6 @@ class ApiQueryRecentChanges extends ApiQueryGeneratorBase { * @access public */ public function extractRowInfo( $row ) { - /* If page was moved somewhere, get the title of the move target. */ - $movedToTitle = false; - if ( isset( $row->rc_moved_to_title ) && $row->rc_moved_to_title !== '' ) { - $movedToTitle = Title::makeTitle( $row->rc_moved_to_ns, $row->rc_moved_to_title ); - } - /* Determine the title of the page that has been changed. */ $title = Title::makeTitle( $row->rc_namespace, $row->rc_title ); @@ -359,9 +351,6 @@ class ApiQueryRecentChanges extends ApiQueryGeneratorBase { /* Create a new entry in the result for the title. */ if ( $this->fld_title ) { ApiQueryBase::addTitleInfo( $vals, $title ); - if ( $movedToTitle ) { - ApiQueryBase::addTitleInfo( $vals, $movedToTitle, 'new_' ); - } } /* Add ids, such as rcid, pageid, revid, and oldid to the change's info. */ diff --git a/includes/installer/MysqlUpdater.php b/includes/installer/MysqlUpdater.php index 037af7b002..98e13866eb 100644 --- a/includes/installer/MysqlUpdater.php +++ b/includes/installer/MysqlUpdater.php @@ -217,6 +217,7 @@ class MysqlUpdater extends DatabaseUpdater { // 1.21 array( 'dropField', 'site_stats', 'ss_admins', 'patch-drop-ss_admins.sql' ), + array( 'dropField', 'recentchanges', 'rc_moved_to_title', 'patch-rc_moved.sql' ), ); } diff --git a/includes/installer/SqliteUpdater.php b/includes/installer/SqliteUpdater.php index 8813b858f3..95a61c19b2 100644 --- a/includes/installer/SqliteUpdater.php +++ b/includes/installer/SqliteUpdater.php @@ -96,6 +96,7 @@ class SqliteUpdater extends DatabaseUpdater { // 1.21 array( 'dropField', 'site_stats', 'ss_admins', 'patch-drop-ss_admins.sql' ), + array( 'dropField', 'recentchanges', 'rc_moved_to_title', 'patch-rc_moved.sql' ), ); } diff --git a/maintenance/archives/patch-rc_moved.sql b/maintenance/archives/patch-rc_moved.sql new file mode 100644 index 0000000000..2fa1de6b49 --- /dev/null +++ b/maintenance/archives/patch-rc_moved.sql @@ -0,0 +1,4 @@ +-- rc_moved_to_ns and rc_moved_to_title is no longer used, delete the fields + +ALTER TABLE /*$wgDBprefix*/recentchanges DROP COLUMN rc_moved_to_ns, + DROP COLUMN rc_moved_to_title; diff --git a/maintenance/sqlite/archives/patch-rc_moved.sql b/maintenance/sqlite/archives/patch-rc_moved.sql new file mode 100644 index 0000000000..70248d542a --- /dev/null +++ b/maintenance/sqlite/archives/patch-rc_moved.sql @@ -0,0 +1,46 @@ +-- rc_moved_to_ns and rc_moved_to_title is no longer used, delete the fields + +CREATE TABLE /*_*/recentchanges_tmp ( + rc_id int NOT NULL PRIMARY KEY AUTO_INCREMENT, + rc_timestamp varbinary(14) NOT NULL default '', + rc_cur_time varbinary(14) NOT NULL default '', + rc_user int unsigned NOT NULL default 0, + rc_user_text varchar(255) binary NOT NULL, + rc_namespace int NOT NULL default 0, + rc_title varchar(255) binary NOT NULL default '', + rc_comment varchar(255) binary NOT NULL default '', + rc_minor tinyint unsigned NOT NULL default 0, + rc_bot tinyint unsigned NOT NULL default 0, + rc_new tinyint unsigned NOT NULL default 0, + rc_cur_id int unsigned NOT NULL default 0, + rc_this_oldid int unsigned NOT NULL default 0, + rc_last_oldid int unsigned NOT NULL default 0, + rc_type tinyint unsigned NOT NULL default 0, + rc_patrolled tinyint unsigned NOT NULL default 0, + rc_ip varbinary(40) NOT NULL default '', + rc_old_len int, + rc_new_len int, + rc_deleted tinyint unsigned NOT NULL default 0, + rc_logid int unsigned NOT NULL default 0, + rc_log_type varbinary(255) NULL default NULL, + rc_log_action varbinary(255) NULL default NULL, + rc_params blob NULL +) /*$wgDBTableOptions*/; + +INSERT INTO /*_*/recentchanges_tmp + SELECT rc_id, rc_timestamp, rc_cur_time, rc_user, rc_user_text, rc_namespace, rc_title, rc_comment, + rc_minor, rc_bot, rc_new, rc_cur_id, rc_this_oldid, rc_last_oldid, rc_type, rc_patrolled, rc_ip, + rc_old_len, rc_new_len, rc_deleted, rc_logid, rc_log_type, rc_log_action, rc_params + FROM /*_*/recentchanges; + +DROP TABLE /*_*/recentchanges; + +ALTER TABLE /*_*/recentchanges_tmp RENAME TO /*_*/recentchanges; + +CREATE INDEX /*i*/rc_timestamp ON /*_*/recentchanges (rc_timestamp); +CREATE INDEX /*i*/rc_namespace_title ON /*_*/recentchanges (rc_namespace, rc_title); +CREATE INDEX /*i*/rc_cur_id ON /*_*/recentchanges (rc_cur_id); +CREATE INDEX /*i*/new_name_timestamp ON /*_*/recentchanges (rc_new,rc_namespace,rc_timestamp); +CREATE INDEX /*i*/rc_ip ON /*_*/recentchanges (rc_ip); +CREATE INDEX /*i*/rc_ns_usertext ON /*_*/recentchanges (rc_namespace, rc_user_text); +CREATE INDEX /*i*/rc_user_text ON /*_*/recentchanges (rc_user_text, rc_timestamp); diff --git a/maintenance/tables.sql b/maintenance/tables.sql index 1ddc89d2a8..f66ef06d62 100644 --- a/maintenance/tables.sql +++ b/maintenance/tables.sql @@ -1042,10 +1042,6 @@ CREATE TABLE /*_*/recentchanges ( -- The type of change entry (RC_EDIT,RC_NEW,RC_LOG) rc_type tinyint unsigned NOT NULL default 0, - -- These may no longer be used, with the new move log. - rc_moved_to_ns tinyint unsigned NOT NULL default 0, - rc_moved_to_title varchar(255) binary NOT NULL default '', - -- If the Recent Changes Patrol option is enabled, -- users may mark edits as having been reviewed to -- remove a warning flag on the RC list. diff --git a/maintenance/updateSearchIndex.php b/maintenance/updateSearchIndex.php index 2a71e7edc0..ac78484785 100644 --- a/maintenance/updateSearchIndex.php +++ b/maintenance/updateSearchIndex.php @@ -96,9 +96,9 @@ class UpdateSearchIndex extends Maintenance { $end = $dbw->timestamp( $end ); $page = $dbw->tableName( 'page' ); - $sql = "SELECT rc_cur_id,rc_type,rc_moved_to_ns,rc_moved_to_title FROM $recentchanges + $sql = "SELECT rc_cur_id FROM $recentchanges JOIN $page ON rc_cur_id=page_id AND rc_this_oldid=page_latest - WHERE rc_timestamp BETWEEN '$start' AND '$end' + WHERE rc_type != " . RC_LOG . " AND rc_timestamp BETWEEN '$start' AND '$end' "; $res = $dbw->query( $sql, __METHOD__ ); @@ -108,17 +108,7 @@ class UpdateSearchIndex extends Maintenance { } public function searchIndexUpdateCallback( $dbw, $row ) { - if ( $row->rc_type == RC_MOVE || $row->rc_type == RC_MOVE_OVER_REDIRECT ) { - # Rename searchindex entry - $titleObj = Title::makeTitle( $row->rc_moved_to_ns, $row->rc_moved_to_title ); - $title = $titleObj->getPrefixedDBkey(); - $this->output( "$title..." ); - $u = new SearchUpdate( $row->rc_cur_id, $title, false ); - $u->doUpdate(); - $this->output( "\n" ); - } elseif ( $row->rc_type !== RC_LOG ) { - $this->updateSearchIndexForPage( $dbw, $row->rc_cur_id ); - } + $this->updateSearchIndexForPage( $dbw, $row->rc_cur_id ); } } -- 2.20.1