Revert r25768, r25771
authorBrion Vibber <brion@users.mediawiki.org>
Tue, 11 Sep 2007 15:03:54 +0000 (15:03 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Tue, 11 Sep 2007 15:03:54 +0000 (15:03 +0000)
I really don't like inserting bogus entries into the link tables, that looks fragile and generally horrifying.

RELEASE-NOTES
includes/LinksUpdate.php
includes/SpecialDeadendpages.php
includes/SpecialUncategorizedpages.php
maintenance/archives/create_null_links_entries.sql [deleted file]
maintenance/createNullLinksRows.php [deleted file]

index 72e2958..f44595c 100644 (file)
@@ -19,9 +19,6 @@ 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
@@ -51,9 +48,6 @@ 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.
 * Fixed notice when accessing special page without read permission and whitelist
   is not defined
 
index 1958d74..9bcd9d6 100644 (file)
@@ -52,10 +52,6 @@ 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 
@@ -72,21 +68,6 @@ 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
         */
@@ -341,7 +322,6 @@ 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 2ee23e2..0d94161 100644 (file)
@@ -18,8 +18,13 @@ class DeadendPagesPage extends PageQueryPage {
                return wfMsgExt( 'deadendpagestext', array( 'parse' ) );
        }
 
+       /**
+        * LEFT JOIN is expensive
+        *
+        * @return true
+        */
        function isExpensive( ) {
-               return false;
+               return 1;
        }
 
        function isSyndicated() { return false; }
@@ -38,12 +43,10 @@ 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,$pagelinks " .
-       "WHERE page_id = pl_from " .
+       "FROM $page LEFT JOIN $pagelinks ON page_id = pl_from " .
+       "WHERE pl_from IS NULL " .
        "AND page_namespace = 0 " .
-       "AND page_is_redirect = 0 " .
-       "AND pl_title = '' " . 
-       "AND pl_namespace = 0";
+       "AND page_is_redirect = 0";
        }
 }
 
index 4419663..b26f6d9 100644 (file)
@@ -20,7 +20,7 @@ class UncategorizedPagesPage extends PageQueryPage {
        }
 
        function isExpensive() {
-               return false;
+               return true;
        }
        function isSyndicated() { return false; }
 
@@ -33,11 +33,12 @@ class UncategorizedPagesPage extends PageQueryPage {
                        "
                        SELECT
                                $name as type,
-                               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=''
+                               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
                        ";
        }
 }
diff --git a/maintenance/archives/create_null_links_entries.sql b/maintenance/archives/create_null_links_entries.sql
deleted file mode 100755 (executable)
index 369c3e6..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
--- Update pagelinks and categorylinks with null entries ('','') for
--- pages with no pagelinks or categorylinks
--- Change made 2007-09-11 by Andrew Garrett <firstname at epstone dot net>
-
-INSERT INTO /*$wgDBprefix*/pagelinks (pl_from,pl_namespace,pl_title)
-SELECT         page_id,0,''
-       FROM /*$wgDBprefix*/page
-       LEFT JOIN /*$wgDBprefix*/pagelinks ON page_id=pl_from
-       WHERE pl_from IS NULL;
-
-INSERT INTO /*$wgDBprefix*/categorylinks (cl_from,cl_sortkey,cl_to)
-SELECT         page_id,'',0
-       FROM /*$wgDBprefix*/page
-       LEFT JOIN /*$wgDBprefix*/categorylinks ON page_id=cl_from
-       WHERE cl_from IS NULL;
diff --git a/maintenance/createNullLinksRows.php b/maintenance/createNullLinksRows.php
deleted file mode 100644 (file)
index 5c82846..0000000
+++ /dev/null
@@ -1,94 +0,0 @@
-<?
-
-require( 'commandLine.inc' );
-
-$db_master = wfGetDB( DB_MASTER );
-$db_slave = wfGetDB( DB_SLAVE );
-
-## Do pagelinks update
-
-echo "Updating pagelinks with null rows.\n";
-
-$count = 0;
-
-list( $page, $pagelinks ) = $db_slave->tableNamesN( 'page', 'pagelinks' );
-
-$pl_query = "SELECT page_id
-       FROM $page
-       LEFT JOIN $pagelinks ON page_id=pl_from
-       WHERE pl_from IS NULL";
-
-$res = $db_slave->query( $pl_query, 'createNullLinksRows' );
-
-$buffer = array();
-
-while ($row = $db_slave->fetchObject( $res ))
-{
-       $buffer[] = array( 'pl_from' => $row->page_id, 'pl_namespace' => 0, 'pl_title' => '' );
-
-       $count++;
-
-       if (count($buffer) > 100)
-       {
-               #Batch-insert
-
-               echo "$count pages..\n";
-
-               $db_master->insert( 'pagelinks', $buffer, 'createNullLinksRows', array('IGNORE') );
-
-               wfWaitForSlaves(10);
-
-               $buffer = array();
-       }
-}
-
-# Insert the rest
-
-echo "$count pages..\n";
-
-$db_master->insert( 'pagelinks', $buffer, 'createNullLinksRows', array('IGNORE') );
-
-wfWaitForSlaves(10);
-
-## Do categorylinks update
-
-$buffer = array();
-
-echo "Updating categorylinks with null rows.\n";
-
-list( $page, $categorylinks ) = $db_slave->tableNamesN( 'page', 'categorylinks' );
-
-$pl_query = "SELECT page_id
-       FROM $page
-       LEFT JOIN $categorylinks ON page_id=cl_from
-       WHERE cl_from IS NULL";
-
-$res = $db_slave->query( $pl_query, 'createNullLinksRows' );
-
-$buffer = array();
-
-while ($row = $db_slave->fetchObject( $res ))
-{
-       $buffer[] = array( 'cl_from' => $row->page_id, 'cl_to' => 0, 'cl_sortkey' => '' );
-
-       if (count($buffer) > 100)
-       {
-               #Batch-insert
-
-               echo "$count pages..\n";
-
-               $db_master->insert( 'categorylinks', $buffer, 'createNullLinksRows', array('IGNORE') );
-
-               wfWaitForSlaves(10);
-
-               $buffer = array();
-       }
-}
-
-echo "$count pages..\n";
-
-$db_master->insert( 'categorylinks', $buffer, 'createNullLinksRows', array('IGNORE') );
-
-$buffer = array();
-
-echo "Done!\n";