Fix logic error in IMS check introduced in r72940. Was sending 304 even for modified...
[mediawiki.git] / includes / specials / SpecialShortpages.php
blob989e4c07ba8f0c7d3622b9cdd2220592c2dd8140
1 <?php
2 /**
3 * Implements Special:Shortpages
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
20 * @file
21 * @ingroup SpecialPage
24 /**
25 * SpecialShortpages extends QueryPage. It is used to return the shortest
26 * pages in the database.
28 * @ingroup SpecialPage
30 class ShortPagesPage extends QueryPage {
32 function getName() {
33 return 'Shortpages';
36 /**
37 * This query is indexed as of 1.5
39 function isExpensive() {
40 return true;
43 function isSyndicated() {
44 return false;
47 function getSQL() {
48 global $wgContentNamespaces;
50 $dbr = wfGetDB( DB_SLAVE );
51 $page = $dbr->tableName( 'page' );
52 $name = $dbr->addQuotes( $this->getName() );
54 $forceindex = $dbr->useIndexClause("page_len");
56 if ($wgContentNamespaces)
57 $nsclause = "page_namespace IN (" . $dbr->makeList($wgContentNamespaces) . ")";
58 else
59 $nsclause = "page_namespace = " . NS_MAIN;
61 return
62 "SELECT $name as type,
63 page_namespace as namespace,
64 page_title as title,
65 page_len AS value
66 FROM $page $forceindex
67 WHERE $nsclause AND page_is_redirect=0";
70 function preprocessResults( $db, $res ) {
71 # There's no point doing a batch check if we aren't caching results;
72 # the page must exist for it to have been pulled out of the table
73 if( $this->isCached() ) {
74 $batch = new LinkBatch();
75 foreach ( $res as $row ) {
76 $batch->add( $row->namespace, $row->title );
78 $batch->execute();
79 if ( $db->numRows( $res ) > 0 ) {
80 $db->dataSeek( $res, 0 );
85 function sortDescending() {
86 return false;
89 function formatResult( $skin, $result ) {
90 global $wgLang, $wgContLang;
91 $dm = $wgContLang->getDirMark();
93 $title = Title::makeTitleSafe( $result->namespace, $result->title );
94 if ( !$title ) {
95 return '<!-- Invalid title ' . htmlspecialchars( "{$result->namespace}:{$result->title}" ). '-->';
97 $hlink = $skin->linkKnown(
98 $title,
99 wfMsgHtml( 'hist' ),
100 array(),
101 array( 'action' => 'history' )
103 $plink = $this->isCached()
104 ? $skin->link( $title )
105 : $skin->linkKnown( $title );
106 $size = wfMessage( 'nbytes', $wgLang->formatNum( $result->value ) )->escaped();
108 return $title->exists()
109 ? "({$hlink}) {$dm}{$plink} {$dm}[{$size}]"
110 : "<del>({$hlink}) {$dm}{$plink} {$dm}[{$size}]</del>";
115 * constructor
117 function wfSpecialShortpages() {
118 list( $limit, $offset ) = wfCheckLimits();
120 $spp = new ShortPagesPage();
122 return $spp->doQuery( $offset, $limit );