* Documentation
authorÆvar Arnfjörð Bjarmason <avar@users.mediawiki.org>
Fri, 16 Sep 2005 15:07:07 +0000 (15:07 +0000)
committerÆvar Arnfjörð Bjarmason <avar@users.mediawiki.org>
Fri, 16 Sep 2005 15:07:07 +0000 (15:07 +0000)
* Fixes for when $this->isCached() is true

includes/SpecialMostlinked.php

index c792638..89ee223 100644 (file)
@@ -1,14 +1,18 @@
 <?php
 /**
+ * A special page to show pages ordered by the number of pages linking to them
  *
  * @package MediaWiki
  * @subpackage SpecialPage
+ *
+ * @author Ævar Arnfjörð Bjarmason <avarab@gmail.com>
+ * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
  */
 
-require_once ( 'QueryPage.php' ) ;
+/* */
+require_once 'QueryPage.php';
 
 /**
- *
  * @package MediaWiki
  * @subpackage SpecialPage
  */
@@ -18,6 +22,9 @@ class MostlinkedPage extends QueryPage {
        function isExpensive() { return true; }
        function isSyndicated() { return false; }
 
+       /**
+        * Note: Getting page_namespace only works if $this->isCached() is false
+        */
        function getSQL() {
                $dbr =& wfGetDB( DB_SLAVE );
                extract( $dbr->tableNames( 'pagelinks', 'page' ) );
@@ -26,7 +33,7 @@ class MostlinkedPage extends QueryPage {
                                pl_namespace AS namespace,
                                pl_title AS title,
                                COUNT(*) AS value,
-                               -- FIXME: The presence of this is a bug
+                               
                                page_namespace
                        FROM $pagelinks
                        LEFT JOIN $page ON pl_namespace=page_namespace AND pl_title=page_title
@@ -39,13 +46,17 @@ class MostlinkedPage extends QueryPage {
 
                $nt = Title::makeTitle( $result->namespace, $result->title );
                $text = $wgContLang->convert( $nt->getPrefixedText() );
-               if ( is_null( $result->page_namespace ) )
-                       $plink = $skin->makeBrokenLink( $nt->getPrefixedText(), $text );
-               else
+               
+               if ( $this->isCached() )
                        $plink = $skin->makeKnownLink( $nt->getPrefixedText(), $text );
+               else {
+                       $plink = is_null( $result->page_namespace )
+                               ? $skin->makeBrokenLink( $nt->getPrefixedText(), $text )
+                               : $skin->makeKnownLink( $nt->getPrefixedText(), $text );
+               }
                
-               $nl = wfMsg( "nlinks", $result->value );
-               $nlink = $skin->makeKnownLink( $wgContLang->specialPage( "Whatlinkshere" ), $nl, "target=" . $nt->getPrefixedURL() );
+               $nl = wfMsg( 'nlinks', $result->value );
+               $nlink = $skin->makeKnownLink( $wgContLang->specialPage( 'Whatlinkshere' ), $nl, 'target=' . $nt->getPrefixedURL() );
 
                return "{$plink} ({$nlink})";
        }