Index: trunk/phpwiki/newcodebase/wiki.phtml |
— | — | @@ -11,13 +11,14 @@ |
12 | 12 | include_once( "Skin.php" ); |
13 | 13 | include_once( "OutputPage.php" ); |
14 | 14 | include_once( "User.php" ); |
| 15 | +include_once( "LinkCache.php" ); |
15 | 16 | include_once( "Title.php" ); |
16 | 17 | include_once( "Article.php" ); |
17 | 18 | |
18 | 19 | global $action, $title, $search, $target; |
19 | 20 | global $target, $returnto; |
20 | 21 | global $wgUser, $wgLang, $wgOut, $wgTitle; # Objects to handle output |
21 | | -global $wgArticle, $wgDeferredUpdateList; |
| 22 | +global $wgArticle, $wgDeferredUpdateList, $wgLinkCache; |
22 | 23 | |
23 | 24 | $wgOut = new OutputPage(); |
24 | 25 | $wgLangClass = "Language" . ucfirst( $wgLanguageCode ); |
— | — | @@ -27,6 +28,7 @@ |
28 | 29 | $wgUser = new User(); |
29 | 30 | $wgUser->loadFromSession(); |
30 | 31 | $wgDeferredUpdateList = array(); |
| 32 | +$wgLinkCache = new LinkCache(); |
31 | 33 | |
32 | 34 | wfStripTextFields(); # Clean up PHP mess |
33 | 35 | |
Index: trunk/phpwiki/newcodebase/sql/buildtables.sql |
— | — | @@ -54,15 +54,22 @@ |
55 | 55 | INDEX old_timestamp (old_timestamp) |
56 | 56 | ) TYPE=MyISAM PACK_KEYS=1; |
57 | 57 | |
58 | | -# Internal links: values are external keys into cur |
| 58 | +# Internal links |
59 | 59 | # |
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) |
65 | 65 | ) TYPE=MyISAM; |
66 | 66 | |
| 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 | + |
67 | 74 | # Site-wide statistics. |
68 | 75 | # |
69 | 76 | CREATE TABLE site_stats ( |
Index: trunk/phpwiki/newcodebase/sql/convertdb.php |
— | — | @@ -13,12 +13,14 @@ |
14 | 14 | include_once( "Language.php" ); |
15 | 15 | include_once( "Namespace.php" ); |
16 | 16 | include_once( "User.php" ); |
| 17 | +include_once( "LinkCache.php" ); |
17 | 18 | include_once( "Title.php" ); |
18 | 19 | include_once( "Article.php" ); |
19 | 20 | |
20 | | -global $wgUser, $wgLang, $wgOut, $wgTitle; |
| 21 | +global $wgUser, $wgLang, $wgOut, $wgTitle, $wgLinkCache; |
21 | 22 | $wgLangClass = "Language" . ucfirst( $wgLanguageCode ); |
22 | 23 | $wgLang = new $wgLangClass(); |
| 24 | +$wgLinkCache = new LinkCache(); |
23 | 25 | |
24 | 26 | # Name of old databse, SQL file to produce, and global progress counter. |
25 | 27 | # |
— | — | @@ -33,9 +35,10 @@ |
34 | 36 | $outf = fopen( $outfilename, "w" ) or die( "Can't open output file.\n" ); |
35 | 37 | |
36 | 38 | |
37 | | -convertUserTable(); |
38 | | -convertCurTable(); |
39 | | -convertOldTable(); |
| 39 | +# convertUserTable(); |
| 40 | +# convertCurTable(); |
| 41 | +# convertOldTable(); |
| 42 | +rebuildLinkTables(); |
40 | 43 | |
41 | 44 | |
42 | 45 | # All done |
— | — | @@ -200,6 +203,10 @@ |
201 | 204 | fwrite( $outf, ";\n" ); |
202 | 205 | } |
203 | 206 | |
| 207 | +function rebuildLinkTables() |
| 208 | +{ |
| 209 | +} |
| 210 | + |
204 | 211 | function fixUserOptions( $in ) |
205 | 212 | { |
206 | 213 | $s = urldecode( $in ); |
Index: trunk/phpwiki/newcodebase/Skin.php |
— | — | @@ -402,7 +402,7 @@ |
403 | 403 | # a final pass through here for things like table backgrounds. |
404 | 404 | # |
405 | 405 | function transformContent( $text ) |
406 | | - { |
| 406 | + { |
407 | 407 | return $text; |
408 | 408 | } |
409 | 409 | |
Index: trunk/phpwiki/newcodebase/Title.php |
— | — | @@ -25,11 +25,6 @@ |
26 | 26 | "en" => "http://www.wikipedia.com/wiki/$1" |
27 | 27 | ); |
28 | 28 | |
29 | | -# This array is kept globally for existence-checking |
30 | | -# internal links and such |
31 | | -# |
32 | | -$wgArticleIDcache = array(); |
33 | | - |
34 | 29 | class Title { |
35 | 30 | /* private */ var $mTextform, $mUrlform, $mDbkeyform; |
36 | 31 | /* private */ var $mNamespace, $mInterwiki; |
— | — | @@ -163,29 +158,11 @@ |
164 | 159 | |
165 | 160 | function getArticleID() |
166 | 161 | { |
167 | | - global $wgArticleIDcache; |
| 162 | + global $wgLinkCache; |
168 | 163 | |
169 | 164 | 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() ); |
190 | 167 | return $this->mArticleID; |
191 | 168 | } |
192 | 169 | |