r420 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r419‎ | r420 | r421 >
Date:19:15, 23 May 2002
Author:lcrocker
Status:old
Tags:
Comment:
Moved link cache to its own class.
Modified paths:
  • /trunk/phpwiki/newcodebase/Skin.php (modified) (history)
  • /trunk/phpwiki/newcodebase/Title.php (modified) (history)
  • /trunk/phpwiki/newcodebase/sql/buildtables.sql (modified) (history)
  • /trunk/phpwiki/newcodebase/sql/convertdb.php (modified) (history)
  • /trunk/phpwiki/newcodebase/wiki.phtml (modified) (history)

Diff [purge]

Index: trunk/phpwiki/newcodebase/wiki.phtml
@@ -11,13 +11,14 @@
1212 include_once( "Skin.php" );
1313 include_once( "OutputPage.php" );
1414 include_once( "User.php" );
 15+include_once( "LinkCache.php" );
1516 include_once( "Title.php" );
1617 include_once( "Article.php" );
1718
1819 global $action, $title, $search, $target;
1920 global $target, $returnto;
2021 global $wgUser, $wgLang, $wgOut, $wgTitle; # Objects to handle output
21 -global $wgArticle, $wgDeferredUpdateList;
 22+global $wgArticle, $wgDeferredUpdateList, $wgLinkCache;
2223
2324 $wgOut = new OutputPage();
2425 $wgLangClass = "Language" . ucfirst( $wgLanguageCode );
@@ -27,6 +28,7 @@
2829 $wgUser = new User();
2930 $wgUser->loadFromSession();
3031 $wgDeferredUpdateList = array();
 32+$wgLinkCache = new LinkCache();
3133
3234 wfStripTextFields(); # Clean up PHP mess
3335
Index: trunk/phpwiki/newcodebase/sql/buildtables.sql
@@ -54,15 +54,22 @@
5555 INDEX old_timestamp (old_timestamp)
5656 ) TYPE=MyISAM PACK_KEYS=1;
5757
58 -# Internal links: values are external keys into cur
 58+# Internal links
5959 #
60 -CREATE TABLE linked (
61 - linked_from int(8) unsigned NOT NULL default '0',
62 - linked_to int(8) unsigned NOT NULL default '0',
63 - INDEX linked_from (linked_from),
64 - INDEX linked_to (linked_to)
 60+CREATE TABLE links (
 61+ l_from varchar(255) binary NOT NULL default '',
 62+ l_to int(8) unsigned NOT NULL default '0',
 63+ INDEX l_from (l_from),
 64+ INDEX l_to (l_to)
6565 ) TYPE=MyISAM;
6666
 67+CREATE TABLE brokenlinks (
 68+ bl_from int(8) unsigned NOT NULL default '0',
 69+ bl_to varchar(255) binary NOT NULL default '',
 70+ INDEX bl_from (bl_from),
 71+ INDEX bl_to (bl_to)
 72+) TYPE=MyISAM;
 73+
6774 # Site-wide statistics.
6875 #
6976 CREATE TABLE site_stats (
Index: trunk/phpwiki/newcodebase/sql/convertdb.php
@@ -13,12 +13,14 @@
1414 include_once( "Language.php" );
1515 include_once( "Namespace.php" );
1616 include_once( "User.php" );
 17+include_once( "LinkCache.php" );
1718 include_once( "Title.php" );
1819 include_once( "Article.php" );
1920
20 -global $wgUser, $wgLang, $wgOut, $wgTitle;
 21+global $wgUser, $wgLang, $wgOut, $wgTitle, $wgLinkCache;
2122 $wgLangClass = "Language" . ucfirst( $wgLanguageCode );
2223 $wgLang = new $wgLangClass();
 24+$wgLinkCache = new LinkCache();
2325
2426 # Name of old databse, SQL file to produce, and global progress counter.
2527 #
@@ -33,9 +35,10 @@
3436 $outf = fopen( $outfilename, "w" ) or die( "Can't open output file.\n" );
3537
3638
37 -convertUserTable();
38 -convertCurTable();
39 -convertOldTable();
 39+# convertUserTable();
 40+# convertCurTable();
 41+# convertOldTable();
 42+rebuildLinkTables();
4043
4144
4245 # All done
@@ -200,6 +203,10 @@
201204 fwrite( $outf, ";\n" );
202205 }
203206
 207+function rebuildLinkTables()
 208+{
 209+}
 210+
204211 function fixUserOptions( $in )
205212 {
206213 $s = urldecode( $in );
Index: trunk/phpwiki/newcodebase/Skin.php
@@ -402,7 +402,7 @@
403403 # a final pass through here for things like table backgrounds.
404404 #
405405 function transformContent( $text )
406 - {
 406+ {
407407 return $text;
408408 }
409409
Index: trunk/phpwiki/newcodebase/Title.php
@@ -25,11 +25,6 @@
2626 "en" => "http://www.wikipedia.com/wiki/$1"
2727 );
2828
29 -# This array is kept globally for existence-checking
30 -# internal links and such
31 -#
32 -$wgArticleIDcache = array();
33 -
3429 class Title {
3530 /* private */ var $mTextform, $mUrlform, $mDbkeyform;
3631 /* private */ var $mNamespace, $mInterwiki;
@@ -163,29 +158,11 @@
164159
165160 function getArticleID()
166161 {
167 - global $wgArticleIDcache;
 162+ global $wgLinkCache;
168163
169164 if ( -1 != $this->mArticleID ) { return $this->mArticleID; }
170 -
171 - $pt = $this->getPrefixedDBkey();
172 - if ( key_exists( $pt, $wgArticleIDcache ) ) {
173 - $this->mArticleID = $wgArticleIDcache[$pt];
174 - } else {
175 - $conn = wfGetDB();
176 - $sql = "SELECT cur_id FROM cur WHERE (cur_namespace=" .
177 - "{$this->mNamespace} AND cur_title='{$this->mDbkeyform}')";
178 - # wfDebug( "Title: 1: $sql\n" );
179 - $res = mysql_query( $sql, $conn );
180 -
181 - if ( ( false === $res ) || 0 == mysql_num_rows( $res ) ) {
182 - $this->mArticleID = 0;
183 - } else {
184 - $s = mysql_fetch_object( $res );
185 - $this->mArticleID = $s->cur_id;
186 - mysql_free_result( $res );
187 - }
188 - }
189 - $wgArticleIDcache[$pt] = $this->mArticleID;
 165+ $this->mArticleID = $wgLinkCache->addLink(
 166+ $this->getPrefixedDBkey() );
190167 return $this->mArticleID;
191168 }
192169

Status & tagging log