From: Bartosz DziewoƄski Date: Sun, 11 May 2014 19:41:10 +0000 (+0200) Subject: SpecialAllpages: Remove fancy index functionality X-Git-Tag: 1.31.0-rc.0~15747 X-Git-Url: http://git.cyclocoop.org/%40spipnet%40?a=commitdiff_plain;h=71fe7c57c69c557e23e82ef7479536709259bc66;p=lhc%2Fweb%2Fwiklou.git SpecialAllpages: Remove fancy index functionality Causes more trouble than it's worth. Bug: 58051 Bug: 65159 Change-Id: If750cad67690df301608951b72f89ae18851e71e --- diff --git a/includes/specials/SpecialAllpages.php b/includes/specials/SpecialAllpages.php index fe49cf2445..11425e9d21 100644 --- a/includes/specials/SpecialAllpages.php +++ b/includes/specials/SpecialAllpages.php @@ -35,30 +35,6 @@ class SpecialAllpages extends IncludableSpecialPage { */ protected $maxPerPage = 345; - /** - * Maximum number of pages to show on single index subpage. - * - * @var int $maxLineCount - */ - protected $maxLineCount = 100; - - /** - * Maximum number of chars to show for an entry. - * - * @var int $maxPageLength - */ - protected $maxPageLength = 70; - - /** - * Maximum number of pages in a hierarchical ("top level") list. - * - * Traversal of the entire page list by spidering the top levels is thought - * to require O(N^3) DB CPU time where N is the number of pages on the wiki. - * See bug 56840. If this limit is exceeded, the behaviour becomes like a - * simple alphabetic pager. - */ - protected $maxTopLevelPages = 50000; - /** * Determines, which message describes the input field 'nsfrom'. * @@ -206,157 +182,7 @@ class SpecialAllpages extends IncludableSpecialPage { $where[] = 'page_title <= ' . $dbr->addQuotes( $to ); } - global $wgMemc; - $key = wfMemcKey( 'allpages', 'ns', $namespace, sha1( $from ), sha1( $to ) ); - $lines = $wgMemc->get( $key ); - - $count = $dbr->estimateRowCount( 'page', '*', $where, __METHOD__ ); - - // Don't show a hierarchical list if the number of pages is very large, - // since generating it will cause a lot of scanning - if ( $count > $this->maxTopLevelPages ) { - $this->showChunk( $namespace, $from, $to, $hideredirects ); - - return; - } - - $maxPerSubpage = intval( $count / $this->maxLineCount ); - $maxPerSubpage = max( $maxPerSubpage, $this->maxPerPage ); - - if ( !is_array( $lines ) ) { - $options = array( 'LIMIT' => 1 ); - $options['ORDER BY'] = 'page_title ASC'; - $firstTitle = $dbr->selectField( 'page', 'page_title', $where, __METHOD__, $options ); - $lastTitle = $firstTitle; - # This array is going to hold the page_titles in order. - $lines = array( $firstTitle ); - # If we are going to show n rows, we need n+1 queries to find the relevant titles. - $done = false; - while ( !$done ) { - // Fetch the last title of this chunk and the first of the next - $chunk = ( $lastTitle === false ) - ? array() - : array( 'page_title >= ' . $dbr->addQuotes( $lastTitle ) ); - $res = $dbr->select( 'page', /* FROM */ - 'page_title', /* WHAT */ - array_merge( $where, $chunk ), - __METHOD__, - array( 'LIMIT' => 2, 'OFFSET' => $maxPerSubpage - 1, 'ORDER BY' => 'page_title ASC' ) - ); - - $s = $dbr->fetchObject( $res ); - if ( $s ) { - array_push( $lines, $s->page_title ); - } else { - // Final chunk, but ended prematurely. Go back and find the end. - $endTitle = $dbr->selectField( 'page', 'MAX(page_title)', - array_merge( $where, $chunk ), - __METHOD__ ); - array_push( $lines, $endTitle ); - $done = true; - } - - $s = $res->fetchObject(); - if ( $s ) { - array_push( $lines, $s->page_title ); - $lastTitle = $s->page_title; - } else { - // This was a final chunk and ended exactly at the limit. - // Rare but convenient! - $done = true; - } - $res->free(); - } - $wgMemc->add( $key, $lines, 3600 ); - } - - // If there are only two or less sections, don't even display them. - // Instead, display the first section directly. - if ( count( $lines ) <= 2 ) { - if ( !empty( $lines ) ) { - $this->showChunk( $namespace, $from, $to, $hideredirects ); - } else { - $output->addHTML( $this->namespaceForm( $namespace, $from, $to, $hideredirects ) ); - } - - return; - } - - # At this point, $lines should contain an even number of elements. - $out .= Xml::openElement( 'table', array( 'class' => 'allpageslist' ) ); - while ( count( $lines ) > 0 ) { - $inpoint = array_shift( $lines ); - $outpoint = array_shift( $lines ); - $out .= $this->showline( $inpoint, $outpoint, $namespace, $hideredirects ); - } - $out .= Xml::closeElement( 'table' ); - $nsForm = $this->namespaceForm( $namespace, $from, $to, $hideredirects ); - - # Is there more? - if ( $this->including() ) { - $out2 = ''; - } else { - if ( isset( $from ) || isset( $to ) ) { - $out2 = Xml::openElement( 'table', array( 'class' => 'mw-allpages-table-form' ) ) . - ' - ' . - $nsForm . - ' - ' . - Linker::link( $this->getPageTitle(), $this->msg( 'allpages' )->escaped(), - array(), array(), 'known' ) . - " - " . - Xml::closeElement( 'table' ); - } else { - $out2 = $nsForm; - } - } - $output->addHTML( $out2 . $out ); - } - - /** - * Show a line of "ABC to DEF" ranges of articles - * - * @param string $inpoint Lower limit of pagenames - * @param string $outpoint Upper limit of pagenames - * @param int $namespace (Default NS_MAIN) - * @param bool $hideRedirects Don't show redirects. Default: false - * @return string - */ - function showline( $inpoint, $outpoint, $namespace = NS_MAIN, $hideRedirects = false ) { - // Use content language since page titles are considered to use content language - global $wgContLang; - - $inpointf = str_replace( '_', ' ', $inpoint ); - $outpointf = str_replace( '_', ' ', $outpoint ); - - // Don't let the length runaway - $inpointf = $wgContLang->truncate( $inpointf, $this->maxPageLength ); - $outpointf = $wgContLang->truncate( $outpointf, $this->maxPageLength ); - - $queryParams = array( - 'from' => $inpoint, - 'to' => $outpoint, - ); - - if ( $namespace ) { - $queryParams['namespace'] = $namespace; - } - if ( $hideRedirects ) { - $queryParams['hideredirects'] = 1; - } - - $url = $this->getPageTitle()->getLocalURL( $queryParams ); - $inlink = Html::element( 'a', array( 'href' => $url ), $inpointf ); - $outlink = Html::element( 'a', array( 'href' => $url ), $outpointf ); - - $out = $this->msg( 'alphaindexline' )->rawParams( - "$inlink", - "$outlink" - )->escaped(); - - return '' . $out . ''; + $this->showChunk( $namespace, $from, $to, $hideredirects ); } /** diff --git a/languages/i18n/en.json b/languages/i18n/en.json index 7a118c7ad2..fa66e75dd4 100644 --- a/languages/i18n/en.json +++ b/languages/i18n/en.json @@ -1699,7 +1699,6 @@ "showhideselectedlogentries": "Change visibility of selected log entries", "allpages": "All pages", "allpages-summary": "", - "alphaindexline": "$1 to $2", "nextpage": "Next page ($1)", "prevpage": "Previous page ($1)", "allpagesfrom": "Display pages starting at:", diff --git a/resources/src/mediawiki.special/mediawiki.special.css b/resources/src/mediawiki.special/mediawiki.special.css index 4ec5ffac96..eb7072ce75 100644 --- a/resources/src/mediawiki.special/mediawiki.special.css +++ b/resources/src/mediawiki.special/mediawiki.special.css @@ -19,9 +19,6 @@ table.mw-allpages-table-form, table.mw-allpages-table-chunk { width: 100%; } -td.mw-allpages-alphaindexline { - text-align: right; -} .mw-allpages-nav { text-align: right; margin-bottom: 1em;