From: Brion Vibber Date: Wed, 29 Jun 2005 00:59:38 +0000 (+0000) Subject: * (bug 2591) Check for end, fix limits on Whatlinkshere X-Git-Tag: 1.5.0beta2~140 X-Git-Url: http://git.cyclocoop.org/%24action?a=commitdiff_plain;h=79a076c5f7d4017ba2e759a1e1043886211a6704;p=lhc%2Fweb%2Fwiklou.git * (bug 2591) Check for end, fix limits on Whatlinkshere --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index f6d5635c34..be4fbe9d01 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -414,6 +414,7 @@ Various bugfixes, small features, and a few experimental things: * (bug 2595) Show "Earlier" and "Latest" links on history go to the first/last page in the article history pager. * Don't show empty-page text in 'Show changes' on new page +* (bug 2591) Check for end, fix limits on Whatlinkshere === Caveats === diff --git a/includes/SpecialWhatlinkshere.php b/includes/SpecialWhatlinkshere.php index 81e8faa666..4d5bfa0564 100644 --- a/includes/SpecialWhatlinkshere.php +++ b/includes/SpecialWhatlinkshere.php @@ -34,11 +34,7 @@ function wfSpecialWhatlinkshere($par = NULL) { $wgOut->addHTML('< '.$sk->makeKnownLinkObj($nt, '', 'redirect=no' )."
\n"); - $specialTitle = Title::makeTitle( NS_SPECIAL, 'Whatlinkshere' ); - $wgOut->addHTML( wfViewPrevNext( $offset, $limit, $specialTitle, 'target=' . urlencode( $target ) ) ); - wfShowIndirectLinks( 0, $nt, $limit, $offset ); - $wgOut->addHTML( wfViewPrevNext( $offset, $limit, $specialTitle, 'target=' . urlencode( $target ) ) ); } /** @@ -54,11 +50,11 @@ function wfShowIndirectLinks( $level, $target, $limit, $offset = 0 ) { $dbr =& wfGetDB( DB_READ ); - if ( $level == 0 ) { - $limitSql = $dbr->limitResult( $limit, $offset ); - } else { - $limitSql = "LIMIT $limit"; - } + // Read one extra row as an at-end check + $queryLimit = $limit + 1; + $limitSql = ( $level == 0 ) + ? "$offset,$queryLimit" + : $queryLimit; $res = $dbr->select( array( 'pagelinks', 'page' ), array( 'page_id', 'page_namespace', 'page_title', 'page_is_redirect' ), @@ -67,22 +63,41 @@ function wfShowIndirectLinks( $level, $target, $limit, $offset = 0 ) { 'pl_namespace' => $target->getNamespace(), 'pl_title' => $target->getDbKey() ), $fname, - $limitSql ); + array( 'LIMIT' => $limitSql ) ); if ( 0 == $dbr->numRows( $res ) ) { if ( 0 == $level ) { - $wgOut->addHTML( wfMsg( 'nolinkshere' ) ); + $wgOut->addWikiText( wfMsg( 'nolinkshere' ) ); } return; } if ( 0 == $level ) { - $wgOut->addHTML( wfMsg( 'linkshere' ) ); + $wgOut->addWikiText( wfMsg( 'linkshere' ) ); } $sk = $wgUser->getSkin(); $isredir = ' (' . wfMsg( 'isredirect' ) . ")\n"; + if( $dbr->numRows( $res ) == 0 ) { + return; + } + $atend = ( $dbr->numRows( $res ) <= $limit ); + + if( $level == 0 ) { + $specialTitle = Title::makeTitle( NS_SPECIAL, 'Whatlinkshere' ); + $prevnext = wfViewPrevNext( $offset, $limit, $specialTitle, + 'target=' . urlencode( $target->getPrefixedDbKey() ), + $atend ); + $wgOut->addHTML( $prevnext ); + } + $wgOut->addHTML( '\n" ); + + if( $level == 0 ) { + $wgOut->addHTML( $prevnext ); + } } ?>