https://www.mediawiki.org/wiki/Special:Code/MediaWiki/112954
Revision: 112954
Author: ialex
Date: 2012-03-03 18:02:21 +0000 (Sat, 03 Mar 2012)
Log Message:
-----------
* Removed check for invalid object in formatResult(), Title::makeTitle() always
returns an object
* Don't call Title::exists() when result is not cached since the page must
exist, and this was issuing a database query per row
* Reorder some variables for better clarity
* Don't execute the LinkBatch if there are now rows
* Call methods directly on ResultWrapper instead of DatabaseBase in
preprocessResults()
* Use local context to get message
Modified Paths:
--------------
trunk/phase3/includes/specials/SpecialShortpages.php
Modified: trunk/phase3/includes/specials/SpecialShortpages.php
===================================================================
--- trunk/phase3/includes/specials/SpecialShortpages.php 2012-03-03
17:33:26 UTC (rev 112953)
+++ trunk/phase3/includes/specials/SpecialShortpages.php 2012-03-03
18:02:21 UTC (rev 112954)
@@ -61,16 +61,17 @@
function preprocessResults( $db, $res ) {
# There's no point doing a batch check if we aren't caching
results;
# the page must exist for it to have been pulled out of the
table
- if( $this->isCached() ) {
- $batch = new LinkBatch();
- foreach ( $res as $row ) {
- $batch->add( $row->namespace, $row->title );
- }
- $batch->execute();
- if ( $db->numRows( $res ) > 0 ) {
- $db->dataSeek( $res, 0 );
- }
+ if ( !$this->isCached() || !$res->numRows() ) {
+ return;
}
+
+ $batch = new LinkBatch();
+ foreach ( $res as $row ) {
+ $batch->add( $row->namespace, $row->title );
+ }
+ $batch->execute();
+
+ $res->seek( 0 );
}
function sortDescending() {
@@ -81,23 +82,26 @@
$dm = $this->getLanguage()->getDirMark();
$title = Title::makeTitle( $result->namespace, $result->title );
- if ( !$title ) {
- return '<!-- Invalid title ' . htmlspecialchars(
"{$result->namespace}:{$result->title}" ). '-->';
- }
+
$hlink = Linker::linkKnown(
$title,
- wfMsgHtml( 'hist' ),
+ $this->msg( 'hist' )->escaped(),
array(),
array( 'action' => 'history' )
);
- $plink = $this->isCached()
- ? Linker::link( $title )
- : Linker::linkKnown( $title );
+ $hlinkInParentheses = $this->msg( 'parentheses' )->rawParams(
$hlink )->escaped();
+
+ if ( $this->isCached() ) {
+ $plink = Linker::link( $title );
+ $exists = $title->exists();
+ } else {
+ $plink = Linker::linkKnown( $title );
+ $exists = true;
+ }
+
$size = $this->msg( 'nbytes' )->numParams( $result->value
)->escaped();
- $hlinkInParentheses = $this->msg( 'parentheses' )->rawParams(
$hlink )->escaped();
-
- return $title->exists()
+ return $exists
? "${hlinkInParentheses} {$dm}{$plink}
{$dm}[{$size}]"
: "<del>${hlinkInParentheses} {$dm}{$plink}
{$dm}[{$size}]</del>";
}
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs