diff options
author | Luke Shumaker <lukeshu@sbcglobal.net> | 2016-05-01 15:32:59 -0400 |
---|---|---|
committer | Luke Shumaker <lukeshu@sbcglobal.net> | 2016-05-01 15:32:59 -0400 |
commit | 6dc1997577fab2c366781fd7048144935afa0012 (patch) | |
tree | 8918d28c7ab4342f0738985e37af1dfc42d0e93a /includes/specials/SpecialAllPages.php | |
parent | 150f94f051128f367bc89f6b7e5f57eb2a69fc62 (diff) | |
parent | fa89acd685cb09cdbe1c64cbb721ec64975bbbc1 (diff) |
Merge commit 'fa89acd'
# Conflicts:
# .gitignore
# extensions/ArchInterWiki.sql
Diffstat (limited to 'includes/specials/SpecialAllPages.php')
-rw-r--r-- | includes/specials/SpecialAllPages.php | 83 |
1 files changed, 37 insertions, 46 deletions
diff --git a/includes/specials/SpecialAllPages.php b/includes/specials/SpecialAllPages.php index 74b1f7bb..c4a67c0c 100644 --- a/includes/specials/SpecialAllPages.php +++ b/includes/specials/SpecialAllPages.php @@ -25,6 +25,7 @@ * Implements Special:Allpages * * @ingroup SpecialPage + * @todo Rewrite using IndexPager */ class SpecialAllPages extends IncludableSpecialPage { @@ -179,6 +180,7 @@ class SpecialAllPages extends IncludableSpecialPage { $toList = $this->getNamespaceKeyAndText( $namespace, $to ); $namespaces = $this->getContext()->getLanguage()->getNamespaces(); $n = 0; + $prevTitle = null; if ( !$fromList || !$toList ) { $out = $this->msg( 'allpagesbadtitle' )->parseAsBlock(); @@ -191,15 +193,13 @@ class SpecialAllPages extends IncludableSpecialPage { list( , $toKey, $to ) = $toList; $dbr = wfGetDB( DB_SLAVE ); - $conds = array( - 'page_namespace' => $namespace, - 'page_title >= ' . $dbr->addQuotes( $fromKey ) - ); - + $filterConds = array( 'page_namespace' => $namespace ); if ( $hideredirects ) { - $conds['page_is_redirect'] = 0; + $filterConds['page_is_redirect'] = 0; } + $conds = $filterConds; + $conds[] = 'page_title >= ' . $dbr->addQuotes( $fromKey ); if ( $toKey !== "" ) { $conds[] = 'page_title <= ' . $dbr->addQuotes( $toKey ); } @@ -234,6 +234,35 @@ class SpecialAllPages extends IncludableSpecialPage { } else { $out = ''; } + + if ( $fromKey !== '' && !$this->including() ) { + # Get the first title from previous chunk + $prevConds = $filterConds; + $prevConds[] = 'page_title < ' . $dbr->addQuotes( $fromKey ); + $prevKey = $dbr->selectField( + 'page', + 'page_title', + $prevConds, + __METHOD__, + array( 'ORDER BY' => 'page_title DESC', 'OFFSET' => $this->maxPerPage - 1 ) + ); + + if ( $prevKey === false ) { + # The previous chunk is not complete, need to link to the very first title + # available in the database + $prevKey = $dbr->selectField( + 'page', + 'page_title', + $prevConds, + __METHOD__, + array( 'ORDER BY' => 'page_title' ) + ); + } + + if ( $prevKey !== false ) { + $prevTitle = Title::makeTitle( $namespace, $prevKey ); + } + } } if ( $this->including() ) { @@ -241,44 +270,6 @@ class SpecialAllPages extends IncludableSpecialPage { return; } - if ( $from == '' ) { - // First chunk; no previous link. - $prevTitle = null; - } else { - # Get the last title from previous chunk - $dbr = wfGetDB( DB_SLAVE ); - $res_prev = $dbr->select( - 'page', - 'page_title', - array( 'page_namespace' => $namespace, 'page_title < ' . $dbr->addQuotes( $from ) ), - __METHOD__, - array( 'ORDER BY' => 'page_title DESC', - 'LIMIT' => $this->maxPerPage, 'OFFSET' => ( $this->maxPerPage - 1 ) - ) - ); - - # Get first title of previous complete chunk - if ( $dbr->numrows( $res_prev ) >= $this->maxPerPage ) { - $pt = $dbr->fetchObject( $res_prev ); - $prevTitle = Title::makeTitle( $namespace, $pt->page_title ); - } else { - # The previous chunk is not complete, need to link to the very first title - # available in the database - $options = array( 'LIMIT' => 1 ); - if ( !$dbr->implicitOrderby() ) { - $options['ORDER BY'] = 'page_title'; - } - $reallyFirstPage_title = $dbr->selectField( 'page', 'page_title', - array( 'page_namespace' => $namespace ), __METHOD__, $options ); - # Show the previous link if it s not the current requested chunk - if ( $from != $reallyFirstPage_title ) { - $prevTitle = Title::makeTitle( $namespace, $reallyFirstPage_title ); - } else { - $prevTitle = null; - } - } - } - $self = $this->getPageTitle(); $topLinks = array( @@ -287,7 +278,7 @@ class SpecialAllPages extends IncludableSpecialPage { $bottomLinks = array(); # Do we put a previous link ? - if ( $prevTitle && $pt = $prevTitle->getText() ) { + if ( $prevTitle ) { $query = array( 'from' => $prevTitle->getText() ); if ( $namespace ) { @@ -300,7 +291,7 @@ class SpecialAllPages extends IncludableSpecialPage { $prevLink = Linker::linkKnown( $self, - $this->msg( 'prevpage', $pt )->escaped(), + $this->msg( 'prevpage', $prevTitle->getText() )->escaped(), array(), $query ); |