From 07de0fc7be0dcf849d6f99bfc23c0e244b163036 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Tue, 28 Nov 2006 04:31:35 +0000 Subject: [PATCH] Revert special:deletedcontribs for now; it's not ready to go live without the index change so would hold up other work for a few days, and the code's kind of ugly and should get refactored. Would love to see this on a branch for the moment. --- RELEASE-NOTES | 1 - includes/AutoLoader.php | 1 - includes/SpecialDeletedcontribs.php | 290 ------------------ includes/SpecialPage.php | 1 - languages/messages/MessagesEn.php | 4 - .../archives/patch-archive-utindex.sql | 7 - maintenance/tables.sql | 3 +- maintenance/updaters.inc | 15 - 8 files changed, 1 insertion(+), 321 deletions(-) delete mode 100644 maintenance/archives/patch-archive-utindex.sql diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 5e6bb05ce6..b967a76c12 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -224,7 +224,6 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN This is triggered by including &undo=revid in an edit URL. A link to a URL that will undo a given edit is shown on NEW NON-CURRENT revision headers on diff pages. * Fix display of link in "already rolled back" message for image/category pages -* New special page Special:Deletedcontribs for browsing deleted edits made by a user. == Languages updated == diff --git a/includes/AutoLoader.php b/includes/AutoLoader.php index 1916f20d27..f826ec1c2c 100644 --- a/includes/AutoLoader.php +++ b/includes/AutoLoader.php @@ -164,7 +164,6 @@ function __autoload($className) { 'EmailConfirmation' => 'includes/SpecialConfirmemail.php', 'ContribsFinder' => 'includes/SpecialContributions.php', 'DeadendPagesPage' => 'includes/SpecialDeadendpages.php', - 'DeletedContribsFinder' => 'includes/SpecialDeletedcontribs.php', 'DisambiguationsPage' => 'includes/SpecialDisambiguations.php', 'DoubleRedirectsPage' => 'includes/SpecialDoubleRedirects.php', 'EmailUserForm' => 'includes/SpecialEmailuser.php', diff --git a/includes/SpecialDeletedcontribs.php b/includes/SpecialDeletedcontribs.php index 1eae5b904c..e69de29bb2 100644 --- a/includes/SpecialDeletedcontribs.php +++ b/includes/SpecialDeletedcontribs.php @@ -1,290 +0,0 @@ -getUserCond(); - $nscond = $this->getNamespaceCond(); - $use_index = $this->dbr->useIndexClause( $index ); - list( $archive ) = $this->dbr->tableNamesN( 'archive' ); - $sql = "SELECT ar_timestamp " . - " FROM $archive $use_index " . - " WHERE $usercond $nscond" . - " ORDER BY ar_timestamp $dir LIMIT 1"; - - $res = $this->dbr->query( $sql, __METHOD__ ); - $row = $this->dbr->fetchObject( $res ); - if ( $row ) { - return $row->ar_timestamp; - } else { - return false; - } - } - - function getUserCond() { - $condition = ' ar_user_text=' . $this->dbr->addQuotes( $this->username ); - $index = 'usertext_timestamp'; - return array( $index, $condition ); - } - - function getNamespaceCond() { - if ( $this->namespace !== false ) - return ' AND ar_namespace = ' . (int)$this->namespace; - return ''; - } - - # The following functions share a lot of code with each other and with - # their counterparts in ContribsFinder. Some refactoring should help. - - function getPreviousOffsetForPaging() { - list( $index, $usercond ) = $this->getUserCond(); - $nscond = $this->getNamespaceCond(); - - $use_index = $this->dbr->useIndexClause( $index ); - list( $archive ) = $this->dbr->tableNamesN( 'archive' ); - - $sql = "SELECT ar_timestamp FROM $archive $use_index " . - "WHERE ar_timestamp > '" . $this->offset . "' AND " . - $usercond . $nscond; - $sql .= " ORDER BY ar_timestamp ASC"; - $sql = $this->dbr->limitResult( $sql, $this->limit, 0 ); - $res = $this->dbr->query( $sql ); - - $numRows = $this->dbr->numRows( $res ); - if ( $numRows ) { - $this->dbr->dataSeek( $res, $numRows - 1 ); - $row = $this->dbr->fetchObject( $res ); - $offset = $row->ar_timestamp; - } else { - $offset = false; - } - $this->dbr->freeResult( $res ); - return $offset; - } - - function getFirstOffsetForPaging() { - list( $index, $usercond ) = $this->getUserCond(); - $use_index = $this->dbr->useIndexClause( $index ); - list( $archive ) = $this->dbr->tableNamesN( 'archive' ); - $nscond = $this->getNamespaceCond(); - $sql = "SELECT ar_timestamp FROM $archive $use_index " . - "WHERE " . - $usercond . $nscond; - $sql .= " ORDER BY ar_timestamp ASC"; - $sql = $this->dbr->limitResult( $sql, $this->limit, 0 ); - $res = $this->dbr->query( $sql ); - - $numRows = $this->dbr->numRows( $res ); - if ( $numRows ) { - $this->dbr->dataSeek( $res, $numRows - 1 ); - $row = $this->dbr->fetchObject( $res ); - $offset = $row->ar_timestamp; - } else { - $offset = false; - } - $this->dbr->freeResult( $res ); - return $offset; - } - - /* private */ function makeSql() { - $offsetQuery = ''; - - list( $archive ) = $this->dbr->tableNamesN( 'archive' ); - list( $index, $userCond ) = $this->getUserCond(); - - if ( $this->offset ) - $offsetQuery = "AND ar_timestamp <= '{$this->offset}'"; - - $nscond = $this->getNamespaceCond(); - $use_index = $this->dbr->useIndexClause( $index ); - $sql = "SELECT - ar_namespace,ar_title, - ar_rev_id,ar_text_id,ar_timestamp,ar_comment,ar_minor_edit,ar_user,ar_user_text - FROM $archive $use_index - WHERE $userCond $nscond $offsetQuery - ORDER BY ar_timestamp DESC"; - $sql = $this->dbr->limitResult( $sql, $this->limit, 0 ); - return $sql; - } -}; - -/** - * Special page "deleted contributions". - * Shows a list of the deleted contributions of a user. - * - * XXX This is almost and exact duplicate of the code in - * XXX SpecialContributions.php and should be merged with it. - * - * @return none - * @param $par String: (optional) user name of the user for which to show the contributions - */ -function wfSpecialDeletedcontribs( $par = null ) { - global $wgUser, $wgOut, $wgLang, $wgRequest; - - $target = isset( $par ) ? $par : $wgRequest->getVal( 'target' ); - if ( !strlen( $target ) ) { - $wgOut->showErrorPage( 'notargettitle', 'notargettext' ); - return; - } - - $nt = Title::newFromURL( $target ); - if ( !$nt ) { - $wgOut->showErrorPage( 'notargettitle', 'notargettext' ); - return; - } - - $options = array(); - - list( $options['limit'], $options['offset']) = wfCheckLimits(); - $options['offset'] = $wgRequest->getVal( 'offset' ); - /* Offset must be an integral. */ - if ( !strlen( $options['offset'] ) || !preg_match( '/^[0-9]+$/', $options['offset'] ) ) - $options['offset'] = ''; - - $title = SpecialPage::getTitleFor( 'Deletedcontribs' ); - $options['target'] = $target; - - $nt =& Title::makeTitle( NS_USER, $nt->getDBkey() ); - $finder = new DeletedContribsFinder( $nt->getText() ); - $finder->setLimit( $options['limit'] ); - $finder->setOffset( $options['offset'] ); - - if ( ( $ns = $wgRequest->getVal( 'namespace', null ) ) !== null && $ns !== '' ) { - $options['namespace'] = intval( $ns ); - $finder->setNamespace( $options['namespace'] ); - } else { - $options['namespace'] = ''; - } - - if ( $wgRequest->getText( 'go' ) == 'prev' ) { - $offset = $finder->getPreviousOffsetForPaging(); - if ( $offset !== false ) { - $options['offset'] = $offset; - $prevurl = $title->getLocalURL( wfArrayToCGI( $options ) ); - $wgOut->redirect( $prevurl ); - return; - } - } - - if ( $wgRequest->getText( 'go' ) == 'first' ) { - $offset = $finder->getFirstOffsetForPaging(); - if ( $offset !== false ) { - $options['offset'] = $offset; - $prevurl = $title->getLocalURL( wfArrayToCGI( $options ) ); - $wgOut->redirect( $prevurl ); - return; - } - } - - $wgOut->setSubtitle( wfMsgHtml( 'contribsub', contributionsSub( $nt ) ) ); - - $id = User::idFromName( $nt->getText() ); - wfRunHooks( 'SpecialDeletedcontribsBeforeMainOutput', $id ); - - $wgOut->addHTML( contributionsForm( $options) ); - - $contribs = $finder->find(); - - if ( count( $contribs ) == 0) { - $wgOut->addWikiText( wfMsg( 'nocontribs' ) ); - return; - } - - list( $early, $late ) = $finder->getEditLimits(); - $lastts = count( $contribs ) ? $contribs[count( $contribs ) - 1]->ar_timestamp : 0; - $atstart = ( !count( $contribs ) || $late == $contribs[0]->ar_timestamp ); - $atend = ( !count( $contribs ) || $early == $lastts ); - - // These four are defaults - $newestlink = wfMsgHtml( 'sp-contributions-newest' ); - $oldestlink = wfMsgHtml( 'sp-contributions-oldest' ); - $newerlink = wfMsgHtml( 'sp-contributions-newer', $options['limit'] ); - $olderlink = wfMsgHtml( 'sp-contributions-older', $options['limit'] ); - - if ( !$atstart ) { - $stuff = $title->escapeLocalURL( wfArrayToCGI( array( 'offset' => '' ), $options ) ); - $newestlink = "$newestlink"; - $stuff = $title->escapeLocalURL( wfArrayToCGI( array( 'go' => 'prev' ), $options ) ); - $newerlink = "$newerlink"; - } - - if ( !$atend ) { - $stuff = $title->escapeLocalURL( wfArrayToCGI( array( 'go' => 'first' ), $options ) ); - $oldestlink = "$oldestlink"; - $stuff = $title->escapeLocalURL( wfArrayToCGI( array( 'offset' => $lastts ), $options ) ); - $olderlink = "$olderlink"; - } - - $firstlast = "($newestlink | $oldestlink)"; - - $urls = array(); - foreach ( array( 20, 50, 100, 250, 500 ) as $num ) { - $stuff = $title->escapeLocalURL( wfArrayToCGI( array( 'limit' => $num ), $options ) ); - $urls[] = "".$wgLang->formatNum( $num ).""; - } - $bits = implode( $urls, ' | ' ); - - $prevnextbits = $firstlast .' '. wfMsgHtml( 'viewprevnext', $newerlink, $olderlink, $bits ); - - $wgOut->addHTML( "

{$prevnextbits}

\n" ); - - $wgOut->addHTML( "\n" ); - $wgOut->addHTML( "

{$prevnextbits}

\n" ); -} - - -/** - * Generates each row in the deleted contributions list. - * - * @todo This would probably look a lot nicer in a table. - */ -function dcListEdit( $sk, $row ) { - $fname = 'dcListEdit'; - wfProfileIn( $fname ); - - global $wgLang, $wgUser, $wgRequest; - static $messages, $undelete; - if( !isset( $messages ) ) { - foreach( explode( ' ', 'undel minoreditletter' ) as $msg ) { - $messages[$msg] = wfMsgExt( $msg, array( 'escape') ); - } - } - if( !isset( $undelete ) ) { - $undelete =& SpecialPage::getTitleFor( 'Undelete' ); - } - - $page = Title::makeTitle( $row->ar_namespace, $row->ar_title )->getPrefixedText(); - - $ts = wfTimestamp( TS_MW, $row->ar_timestamp ); - $d = $wgLang->timeanddate( $ts, true ); - - $link = $sk->makeKnownLinkObj( $undelete, $page, "target=$page×tamp=$ts" ); - $undellink = '(' . $sk->makeKnownLinkObj( $undelete, $messages['undel'], "target=$page" ) . ')'; - - if( $row->ar_minor_edit ) { - $mflag = '' . $messages['minoreditletter'] . ' '; - } else { - $mflag = ''; - } - - $comment = $sk->commentBlock( $row->ar_comment ); - - $ret = "
  • {$d}{$mflag} {$link} {$undellink} {$comment}
  • "; - wfProfileOut( $fname ); - return $ret; -} - -?> diff --git a/includes/SpecialPage.php b/includes/SpecialPage.php index 7b590d9898..e8db18b742 100644 --- a/includes/SpecialPage.php +++ b/includes/SpecialPage.php @@ -127,7 +127,6 @@ class SpecialPage 'Log' => array( 'SpecialPage', 'Log' ), 'Blockip' => array( 'SpecialPage', 'Blockip', 'block' ), 'Undelete' => array( 'SpecialPage', 'Undelete', 'deletedhistory' ), - 'Deletedcontribs' => array( 'SpecialPage', 'Deletedcontribs', 'deletedhistory' ), 'Import' => array( 'SpecialPage', "Import", 'import' ), 'Lockdb' => array( 'SpecialPage', 'Lockdb', 'siteadmin' ), 'Unlockdb' => array( 'SpecialPage', 'Unlockdb', 'siteadmin' ), diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index de4189fbb3..6514ff5b00 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -1741,10 +1741,6 @@ revision may have been restored or removed from the archive.", Consult the [[Special:Log/delete|deletion log]] for a record of recent deletions and restorations.", -# Deleted contributions -'deletedcontribs' => 'Deleted contributions', -'undel' => 'undelete', - # Namespace form on various pages 'namespace' => 'Namespace:', 'invert' => 'Invert selection', diff --git a/maintenance/archives/patch-archive-utindex.sql b/maintenance/archives/patch-archive-utindex.sql deleted file mode 100644 index aa7d2c577d..0000000000 --- a/maintenance/archives/patch-archive-utindex.sql +++ /dev/null @@ -1,7 +0,0 @@ --- Add an index to archive on ar_user_text, ar_timestamp --- --- Added 2006-11-27 --- - - ALTER TABLE /*$wgDBprefix*/archive -ADD INDEX usertext_timestamp (ar_user_text, ar_timestamp); \ No newline at end of file diff --git a/maintenance/tables.sql b/maintenance/tables.sql index 1f133c1d6e..d210179657 100644 --- a/maintenance/tables.sql +++ b/maintenance/tables.sql @@ -351,8 +351,7 @@ CREATE TABLE /*$wgDBprefix*/archive ( -- row upon undeletion. ar_text_id int(8) unsigned, - KEY name_title_timestamp (ar_namespace,ar_title,ar_timestamp), - KEY usertext_timestamp (ar_user_text,ar_timestamp) + KEY name_title_timestamp (ar_namespace,ar_title,ar_timestamp) ) TYPE=InnoDB; diff --git a/maintenance/updaters.inc b/maintenance/updaters.inc index 18075ffc62..f319cb4dd9 100644 --- a/maintenance/updaters.inc +++ b/maintenance/updaters.inc @@ -821,19 +821,6 @@ function do_backlinking_indices_update() { } } -function do_archive_indices_update() { - global $wgDatabase; - echo( "Checking for additional archive indices...\n" ); - - $info = $wgDatabase->indexInfo( 'archive', 'usertext_timestamp', __METHOD__ ); - if( !$info ) { - echo( "...index on ( ar_user_text, ar_timestamp ) not found; creating\n" ); - dbsource( archive( 'patch-archive-utindex.sql' ) ); - } else { - echo( "...index on ( ar_user_text, ar_timestamp ) seems to be ok\n" ); - } -} - function do_all_updates( $doShared = false ) { global $wgNewTables, $wgNewFields, $wgRenamedTables, $wgSharedDB, $wgDatabase, $wgDBtype; @@ -902,8 +889,6 @@ function do_all_updates( $doShared = false ) { do_backlinking_indices_update(); flush(); - do_archive_indices_update(); flush(); - initialiseMessages(); flush(); } -- 2.20.1