I had a fix for this bug sitting in my working copy for over a week without getting...
[lhc/web/wiklou.git] / includes / SpecialDeadendpages.php
index aaec95a..9b18bb5 100644 (file)
@@ -1,59 +1,66 @@
-<?
+<?php
+/**
+ *
+ * @package MediaWiki
+ * @subpackage SpecialPage
+ */
 
-function wfSpecialDeadendpages()
-{
-    global $wgUser, $wgOut, $wgLang, $wgTitle;
-    $fname = "wfSpecialDeadendpages";
-    
-    # Cache
-    $vsp = $wgLang->getValidSpecialPages();
-    $log = new LogPage( $vsp["Deadendpages"] );
-    $log->mUpdateRecentChanges = false;
-    
-    global $wgMiserMode;
-    if ( $wgMiserMode ) {
-       $log->showAsDisabledPage();
-       return;
+/**
+ *
+ */
+require_once( "QueryPage.php" );
+
+/**
+ *
+ * @package MediaWiki
+ * @subpackage SpecialPage
+ */
+class DeadendPagesPage extends PageQueryPage {
+
+       function getName( ) {
+               return "Deadendpages";
+       }
+
+       /**
+        * LEFT JOIN is expensive
+        *
+        * @return true
+        */
+       function isExpensive( ) {
+               return 1;
+       }
+
+       /**
+        * @return false
+        */
+       function sortDescending() {
+               return false;
+       }
+       
+    /**
+        * @return string an sqlquery
+        */
+       function getSQL() {
+               $dbr =& wfGetDB( DB_SLAVE );
+               extract( $dbr->tableNames( 'cur', 'links' ) );
+               return "SELECT 'Deadendpages' as type, cur_namespace AS namespace, cur_title as title, cur_title AS value " . 
+       "FROM $cur LEFT JOIN $links ON cur_id = l_from " .
+       "WHERE l_from IS NULL " .
+       "AND cur_namespace = 0 " .
+       "AND cur_is_redirect = 0";
     }
+}
+
+/**
+ * Constructor
+ */
+function wfSpecialDeadendpages() {
     
     list( $limit, $offset ) = wfCheckLimits();
 
-    # Note: title is only the same as l_from for main namespace, 
-    # but that's what we want, anyways
-
-    # XXX: Left joins are losey
-    
-    $sql = "SELECT cur_title " . 
-      "FROM cur LEFT JOIN links ON cur_title = l_from " .
-      "WHERE l_from IS NULL " .
-      "AND cur_namespace = 0 " .
-      "ORDER BY cur_title " . 
-      "LIMIT {$offset}, {$limit}";
-    
-    $res = wfQuery( $sql, DB_READ, $fname );
-    
-    $sk = $wgUser->getSkin();
-    
-    $top = wfShowingResults( $offset, $limit );
-    $wgOut->addHTML( "<p>{$top}\n" );
-    
-    $sl = wfViewPrevNext( $offset, $limit,
-                         $wgLang->specialPage( "Deadendpages" ) );
-    $wgOut->addHTML( "<br>{$sl}\n" );
-    
-    $s = "<ol start=" . ( $offset + 1 ) . ">";
-    while ( $obj = wfFetchObject( $res ) ) {
-       $link = $sk->makeKnownLink( $obj->cur_title, "" );
-       $s .= "<li>{$link}</li>\n";
-    }
-    wfFreeResult( $res );
-    $s .= "</ol>";
-    $wgOut->addHTML( $s );
-    $wgOut->addHTML( "<p>{$sl}\n" );
+    $depp = new DeadendPagesPage();
     
-    # Saving cache
-    if ( $offset > 0 OR $limit < 50 ) return ; #Not suitable
-       $log->replaceContent( $s );
+    return $depp->doQuery( $offset, $limit );
 }
 
 ?>