r25778 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r25777‎ | r25778 | r25779 >
Date:15:03, 11 September 2007
Author:brion
Status:old
Tags:
Comment:
Revert r25768, r25771
I really don't like inserting bogus entries into the link tables, that looks fragile and generally horrifying.
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/LinksUpdate.php (modified) (history)
  • /trunk/phase3/includes/SpecialDeadendpages.php (modified) (history)
  • /trunk/phase3/includes/SpecialUncategorizedpages.php (modified) (history)
  • /trunk/phase3/maintenance/archives/create_null_links_entries.sql (deleted) (history)
  • /trunk/phase3/maintenance/createNullLinksRows.php (deleted) (history)

Diff [purge]

Index: trunk/phase3/maintenance/createNullLinksRows.php
@@ -1,94 +0,0 @@
2 -<?
3 -
4 -require( 'commandLine.inc' );
5 -
6 -$db_master = wfGetDB( DB_MASTER );
7 -$db_slave = wfGetDB( DB_SLAVE );
8 -
9 -## Do pagelinks update
10 -
11 -echo "Updating pagelinks with null rows.\n";
12 -
13 -$count = 0;
14 -
15 -list( $page, $pagelinks ) = $db_slave->tableNamesN( 'page', 'pagelinks' );
16 -
17 -$pl_query = "SELECT page_id
18 - FROM $page
19 - LEFT JOIN $pagelinks ON page_id=pl_from
20 - WHERE pl_from IS NULL";
21 -
22 -$res = $db_slave->query( $pl_query, 'createNullLinksRows' );
23 -
24 -$buffer = array();
25 -
26 -while ($row = $db_slave->fetchObject( $res ))
27 -{
28 - $buffer[] = array( 'pl_from' => $row->page_id, 'pl_namespace' => 0, 'pl_title' => '' );
29 -
30 - $count++;
31 -
32 - if (count($buffer) > 100)
33 - {
34 - #Batch-insert
35 -
36 - echo "$count pages..\n";
37 -
38 - $db_master->insert( 'pagelinks', $buffer, 'createNullLinksRows', array('IGNORE') );
39 -
40 - wfWaitForSlaves(10);
41 -
42 - $buffer = array();
43 - }
44 -}
45 -
46 -# Insert the rest
47 -
48 -echo "$count pages..\n";
49 -
50 -$db_master->insert( 'pagelinks', $buffer, 'createNullLinksRows', array('IGNORE') );
51 -
52 -wfWaitForSlaves(10);
53 -
54 -## Do categorylinks update
55 -
56 -$buffer = array();
57 -
58 -echo "Updating categorylinks with null rows.\n";
59 -
60 -list( $page, $categorylinks ) = $db_slave->tableNamesN( 'page', 'categorylinks' );
61 -
62 -$pl_query = "SELECT page_id
63 - FROM $page
64 - LEFT JOIN $categorylinks ON page_id=cl_from
65 - WHERE cl_from IS NULL";
66 -
67 -$res = $db_slave->query( $pl_query, 'createNullLinksRows' );
68 -
69 -$buffer = array();
70 -
71 -while ($row = $db_slave->fetchObject( $res ))
72 -{
73 - $buffer[] = array( 'cl_from' => $row->page_id, 'cl_to' => 0, 'cl_sortkey' => '' );
74 -
75 - if (count($buffer) > 100)
76 - {
77 - #Batch-insert
78 -
79 - echo "$count pages..\n";
80 -
81 - $db_master->insert( 'categorylinks', $buffer, 'createNullLinksRows', array('IGNORE') );
82 -
83 - wfWaitForSlaves(10);
84 -
85 - $buffer = array();
86 - }
87 -}
88 -
89 -echo "$count pages..\n";
90 -
91 -$db_master->insert( 'categorylinks', $buffer, 'createNullLinksRows', array('IGNORE') );
92 -
93 -$buffer = array();
94 -
95 -echo "Done!\n";
Index: trunk/phase3/maintenance/archives/create_null_links_entries.sql
@@ -1,15 +0,0 @@
2 -
3 -INSERT INTO /*$wgDBprefix*/pagelinks (pl_from,pl_namespace,pl_title)
4 -SELECT page_id,0,''
5 - FROM /*$wgDBprefix*/page
6 - LEFT JOIN /*$wgDBprefix*/pagelinks ON page_id=pl_from
7 - WHERE pl_from IS NULL;
8 -
9 -INSERT INTO /*$wgDBprefix*/categorylinks (cl_from,cl_sortkey,cl_to)
10 -SELECT page_id,'',0
11 - FROM /*$wgDBprefix*/page
12 - LEFT JOIN /*$wgDBprefix*/categorylinks ON page_id=cl_from
13 - WHERE cl_from IS NULL;
Index: trunk/phase3/includes/SpecialUncategorizedpages.php
@@ -20,7 +20,7 @@
2121 }
2222
2323 function isExpensive() {
24 - return false;
 24+ return true;
2525 }
2626 function isSyndicated() { return false; }
2727
@@ -33,11 +33,12 @@
3434 "
3535 SELECT
3636 $name as type,
37 - page.page_namespace AS namespace,
38 - page.page_title AS title,
39 - page.page_title AS value
40 - FROM $page,$categorylinks
41 - WHERE page_id=cl_from AND page_namespace={$this->requestedNamespace} AND page_is_redirect=0 AND cl_to=''
 37+ page_namespace AS namespace,
 38+ page_title AS title,
 39+ page_title AS value
 40+ FROM $page
 41+ LEFT JOIN $categorylinks ON page_id=cl_from
 42+ WHERE cl_from IS NULL AND page_namespace={$this->requestedNamespace} AND page_is_redirect=0
4243 ";
4344 }
4445 }
Index: trunk/phase3/includes/LinksUpdate.php
@@ -52,10 +52,6 @@
5353 $this->mExternals = $parserOutput->getExternalLinks();
5454 $this->mCategories = $parserOutput->getCategories();
5555
56 - # Insert (0,'') entries if there are none of a given type of link (page and category links only)
57 - $this->mLinks = $this->addNullEntries( $this->mLinks, array( 0 => array( '' => 0 ) ) );
58 - $this->mCategories = $this->addNullEntries( $this->mCategories );
59 -
6056 # Convert the format of the interlanguage links
6157 # I didn't want to change it in the ParserOutput, because that array is passed all
6258 # the way back to the skin, so either a skin API break would be required, or an
@@ -73,21 +69,6 @@
7470 }
7571
7672 /**
77 - * Add "no links" entries to the parser-output.
78 - * @param $links array The links array to add null entries to.
79 - * @param $replace array What to replace it with if $links is empty.
80 - * @return array The links array, after being modified.
81 - */
82 - function addNullEntries( $links, $replace = array( '' => '' ) )
83 - {
84 - if ( count( $links ) == 0 ) {
85 - $links = $replace;
86 - }
87 -
88 - return $links;
89 - }
90 -
91 - /**
9273 * Update link tables with outgoing links from an updated article
9374 */
9475 function doUpdate() {
@@ -341,7 +322,6 @@
342323 # array_diff_key() was introduced in PHP 5.1, there is a compatibility function
343324 # in GlobalFunctions.php
344325 $diffs = isset( $existing[$ns] ) ? array_diff_key( $dbkeys, $existing[$ns] ) : $dbkeys;
345 -
346326 foreach ( $diffs as $dbk => $id ) {
347327 $arr[] = array(
348328 'pl_from' => $this->mId,
Index: trunk/phase3/includes/SpecialDeadendpages.php
@@ -18,8 +18,13 @@
1919 return wfMsgExt( 'deadendpagestext', array( 'parse' ) );
2020 }
2121
 22+ /**
 23+ * LEFT JOIN is expensive
 24+ *
 25+ * @return true
 26+ */
2227 function isExpensive( ) {
23 - return false;
 28+ return 1;
2429 }
2530
2631 function isSyndicated() { return false; }
@@ -38,12 +43,10 @@
3944 $dbr = wfGetDB( DB_SLAVE );
4045 list( $page, $pagelinks ) = $dbr->tableNamesN( 'page', 'pagelinks' );
4146 return "SELECT 'Deadendpages' as type, page_namespace AS namespace, page_title as title, page_title AS value " .
42 - "FROM $page,$pagelinks " .
43 - "WHERE page_id = pl_from " .
 47+ "FROM $page LEFT JOIN $pagelinks ON page_id = pl_from " .
 48+ "WHERE pl_from IS NULL " .
4449 "AND page_namespace = 0 " .
45 - "AND page_is_redirect = 0 " .
46 - "AND pl_title = '' " .
47 - "AND pl_namespace = 0";
 50+ "AND page_is_redirect = 0";
4851 }
4952 }
5053
Index: trunk/phase3/RELEASE-NOTES
@@ -19,9 +19,6 @@
2020 it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
2121
2222 === Configuration changes in 1.12 ===
23 -* The permission key required to edit another user's css/js subpage is now
24 - editusercssjs, rather than editinterface, as it was previously. This permission
25 - is assigned by default to the sysop group.
2623
2724 === New features in 1.12 ===
2825 * Add a warning for non-descriptive filenames at Special:Upload
@@ -51,9 +48,6 @@
5249 * (bug 11266) Set fallback language for Fulfulde (ff) to French
5350 * (bug 11179) Include image version deletion comment in public log
5451 * (bug 11158) Fix escaping in API HTML-formatted JSON
55 -* Speed up Special:UncategorizedPages and Special:Deadendpages (no longer marked
56 - as slow queries). They now add blank ('','') entries for pages without ANY links
57 - or categories.
5852 * Fixed notice when accessing special page without read permission and whitelist
5953 is not defined
6054

Follow-up revisions

RevisionCommit summaryAuthorDate
r25804Merged revisions 25752-25803 via svnmerge from...david02:25, 12 September 2007

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r25768* Speed up Special:UncategorizedPages and Special:Deadendpages (no longer mar...werdna08:10, 11 September 2007
r25771* Update scripts (stand-alone PHP and mysql) for updating old wikis with the ...werdna09:22, 11 September 2007

Status & tagging log