SpecialAllpages: Remove fancy index functionality
authorBartosz Dziewoński <matma.rex@gmail.com>
Sun, 11 May 2014 19:41:10 +0000 (21:41 +0200)
committerOri.livneh <ori@wikimedia.org>
Sun, 11 May 2014 23:27:00 +0000 (23:27 +0000)
Causes more trouble than it's worth.

Bug: 58051
Bug: 65159
Change-Id: If750cad67690df301608951b72f89ae18851e71e

includes/specials/SpecialAllpages.php
languages/i18n/en.json
resources/src/mediawiki.special/mediawiki.special.css

index fe49cf2..11425e9 100644 (file)
@@ -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' ) ) .
-                                       '<tr>
-                                                       <td>' .
-                                       $nsForm .
-                                       '</td>
-                                                       <td class="mw-allpages-nav">' .
-                                       Linker::link( $this->getPageTitle(), $this->msg( 'allpages' )->escaped(),
-                                               array(), array(), 'known' ) .
-                                       "</td>
-                                               </tr>" .
-                                       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</td><td>",
-                       "</td><td>$outlink"
-               )->escaped();
-
-               return '<tr><td class="mw-allpages-alphaindexline">' . $out . '</td></tr>';
+               $this->showChunk( $namespace, $from, $to, $hideredirects );
        }
 
        /**
index 7a118c7..fa66e75 100644 (file)
        "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:",
index 4ec5ffa..eb7072c 100644 (file)
@@ -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;