From a193e28c24bb5f5cbfaa2f936fba16f20ce2da15 Mon Sep 17 00:00:00 2001 From: Jens Frank Date: Sun, 24 Apr 2005 09:31:57 +0000 Subject: [PATCH] BUG#1644 - Fix: "Next #" link is displayed even if there are no more entries. --- includes/SpecialLog.php | 47 +++++++++++++++++++++++++++++------------ 1 file changed, 34 insertions(+), 13 deletions(-) diff --git a/includes/SpecialLog.php b/includes/SpecialLog.php index 4a04482d6d..b98f11629e 100644 --- a/includes/SpecialLog.php +++ b/includes/SpecialLog.php @@ -202,6 +202,7 @@ class LogViewer { * @var LogReader $reader */ var $reader; + var $numResults = 0; /** * @param LogReader &$reader where to get our data from @@ -219,20 +220,25 @@ class LogViewer { global $wgOut; $this->showHeader( $wgOut ); $this->showOptions( $wgOut ); + $result = $this->getLogRows(); $this->showPrevNext( $wgOut ); - $this->showList( $wgOut ); + $this->showList( $wgOut, $result ); $this->showPrevNext( $wgOut ); } - + /** - * Output just the list of entries given by the linked LogReader, - * with extraneous UI elements. Use for displaying log fragments in - * another page (eg at Special:Undelete) - * @param OutputPage $out where to send output + * Load the data from the linked LogReader + * Preload the link cache + * Initialise numResults + * + * Must be called before calling showPrevNext + * + * @return object database result set */ - function showList( &$out ) { + function getLogRows() { global $wgLinkCache; $result = $this->reader->getRows(); + $this->numResults = 0; // Fetch results and form a batch link existence query $batch = new LinkBatch; @@ -247,17 +253,32 @@ class LogViewer { $title = Title::newFromText( $paramArray[0] ); $batch->addObj( $title ); } + $this->numResults++; } $batch->execute( $wgLinkCache ); + return $result; + } + + + /** + * Output just the list of entries given by the linked LogReader, + * with extraneous UI elements. Use for displaying log fragments in + * another page (eg at Special:Undelete) + * @param OutputPage $out where to send output + */ + function showList( &$out, $result ) { // Rewind result pointer and go through it again, making the HTML - $result->seek( 0 ); - $html = "\n\n"; $out->addHTML( $html ); } @@ -382,7 +403,7 @@ class LogViewer { $html = wfViewPrevNext( $offset, $limit, $wgContLang->specialpage( 'Log' ), $bits, - false); + $this->numResults < $limit); $out->addHTML( '

' . $html . '

' ); } } -- 2.20.1