* Speed up Special:UncategorizedPages and Special:Deadendpages (no longer marked...
authorAndrew Garrett <werdna@users.mediawiki.org>
Tue, 11 Sep 2007 08:10:28 +0000 (08:10 +0000)
committerAndrew Garrett <werdna@users.mediawiki.org>
Tue, 11 Sep 2007 08:10:28 +0000 (08:10 +0000)
* RELEASE-NOTES comments forgotten in a previous commit.

RELEASE-NOTES
includes/LinksUpdate.php
includes/SpecialDeadendpages.php
includes/SpecialUncategorizedpages.php

index c7e08a0..fcbbecd 100644 (file)
@@ -19,6 +19,9 @@ Those wishing to use the latest code instead of a branch release can obtain
 it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
 
 === Configuration changes in 1.12 ===
+* The permission key required to edit another user's css/js subpage is now
+  editusercssjs, rather than editinterface, as it was previously. This permission
+  is assigned by default to the sysop group.
 
 === New features in 1.12 ===
 * Add a warning for non-descriptive filenames at Special:Upload
@@ -45,7 +48,9 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
 * (bug 11266) Set fallback language for Fulfulde (ff) to French
 * (bug 11179) Include image version deletion comment in public log
 * (bug 11158) Fix escaping in API HTML-formatted JSON
-
+* Speed up Special:UncategorizedPages and Special:Deadendpages (no longer marked
+  as slow queries). They now add blank ('','') entries for pages without ANY links
+  or categories.
 
 === API changes in 1.12 ===
 
index 9bcd9d6..1958d74 100644 (file)
@@ -52,6 +52,10 @@ class LinksUpdate {
                $this->mExternals = $parserOutput->getExternalLinks();
                $this->mCategories = $parserOutput->getCategories();
 
+               # Insert (0,'') entries if there are none of a given type of link (page and category links only)
+               $this->mLinks = $this->addNullEntries( $this->mLinks, array( 0 => array( '' => 0 ) ) );
+               $this->mCategories = $this->addNullEntries( $this->mCategories );
+
                # Convert the format of the interlanguage links
                # I didn't want to change it in the ParserOutput, because that array is passed all 
                # the way back to the skin, so either a skin API break would be required, or an 
@@ -68,6 +72,21 @@ class LinksUpdate {
                wfRunHooks( 'LinksUpdateConstructed', array( &$this ) );
        }
 
+       /**
+        * Add "no links" entries to the parser-output.
+        * @param $links array The links array to add null entries to.
+        * @param $replace array What to replace it with if $links is empty.
+        * @return array The links array, after being modified.
+        */
+       function addNullEntries( $links, $replace = array( '' => '' ) )
+       {
+               if ( count( $links ) == 0 ) {
+                       $links = $replace;
+               }
+
+               return $links;
+       }
+
        /**
         * Update link tables with outgoing links from an updated article
         */
@@ -322,6 +341,7 @@ class LinksUpdate {
                        # array_diff_key() was introduced in PHP 5.1, there is a compatibility function
                        # in GlobalFunctions.php
                        $diffs = isset( $existing[$ns] ) ? array_diff_key( $dbkeys, $existing[$ns] ) : $dbkeys;
+
                        foreach ( $diffs as $dbk => $id ) {
                                $arr[] = array(
                                        'pl_from'      => $this->mId,
index 0d94161..2ee23e2 100644 (file)
@@ -18,13 +18,8 @@ class DeadendPagesPage extends PageQueryPage {
                return wfMsgExt( 'deadendpagestext', array( 'parse' ) );
        }
 
-       /**
-        * LEFT JOIN is expensive
-        *
-        * @return true
-        */
        function isExpensive( ) {
-               return 1;
+               return false;
        }
 
        function isSyndicated() { return false; }
@@ -43,10 +38,12 @@ class DeadendPagesPage extends PageQueryPage {
                $dbr = wfGetDB( DB_SLAVE );
                list( $page, $pagelinks ) = $dbr->tableNamesN( 'page', 'pagelinks' );
                return "SELECT 'Deadendpages' as type, page_namespace AS namespace, page_title as title, page_title AS value " .
-       "FROM $page LEFT JOIN $pagelinks ON page_id = pl_from " .
-       "WHERE pl_from IS NULL " .
+       "FROM $page,$pagelinks " .
+       "WHERE page_id = pl_from " .
        "AND page_namespace = 0 " .
-       "AND page_is_redirect = 0";
+       "AND page_is_redirect = 0 " .
+       "AND pl_title = '' " . 
+       "AND pl_namespace = 0";
        }
 }
 
index b26f6d9..4419663 100644 (file)
@@ -20,7 +20,7 @@ class UncategorizedPagesPage extends PageQueryPage {
        }
 
        function isExpensive() {
-               return true;
+               return false;
        }
        function isSyndicated() { return false; }
 
@@ -33,12 +33,11 @@ class UncategorizedPagesPage extends PageQueryPage {
                        "
                        SELECT
                                $name as type,
-                               page_namespace AS namespace,
-                               page_title AS title,
-                               page_title AS value
-                       FROM $page
-                       LEFT JOIN $categorylinks ON page_id=cl_from
-                       WHERE cl_from IS NULL AND page_namespace={$this->requestedNamespace} AND page_is_redirect=0
+                               page.page_namespace AS namespace,
+                               page.page_title AS title,
+                               page.page_title AS value
+                       FROM $page,$categorylinks
+                       WHERE page_id=cl_from AND page_namespace={$this->requestedNamespace} AND page_is_redirect=0 AND cl_to=''
                        ";
        }
 }