r69542 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r69541‎ | r69542 | r69543 >
Date:11:55, 19 July 2010
Author:catrope
Status:resolved (Comments)
Tags:scaptrap schema 
Comment:
Add iw_api and iw_wikiid fields to the interwiki table, plus rudimentary support in Interwiki.php and Title.php . Code written by peter17 in the iwtransclusion branch. This revision is a partial merge of r68170, r68448, r69480, r69540 and r69541
Modified paths:
  • /trunk/phase3/includes/Interwiki.php (modified) (history)
  • /trunk/phase3/includes/Title.php (modified) (history)
  • /trunk/phase3/includes/installer/Updaters.php (modified) (history)
  • /trunk/phase3/maintenance/archives (modified) (history)
  • /trunk/phase3/maintenance/archives/patch-iw_api_and_wikiid.sql (added) (history)
  • /trunk/phase3/maintenance/tables.sql (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/archives/patch-iw_api_and_wikiid.sql
@@ -0,0 +1,9 @@
 2+--
 3+-- Add iw_api and iw_wikiid to interwiki table
 4+--
 5+
 6+ALTER TABLE /*_*/interwiki
 7+ ADD iw_api BLOB NOT NULL;
 8+ALTER TABLE /*_*/interwiki
 9+ ADD iw_wikiid varchar(64) NOT NULL;
 10+
Property changes on: trunk/phase3/maintenance/archives
___________________________________________________________________
Added: svn:mergeinfo
111 Merged /branches/iwtransclusion/phase3/maintenance/archives:r69540
212 Merged /branches/new-installer/phase3/maintenance/archives:r43664-66004
313 Merged /branches/REL1_15/phase3/maintenance/archives:r51646
414 Merged /branches/sqlite/maintenance/archives:r58211-58321
Index: trunk/phase3/maintenance/tables.sql
@@ -1068,6 +1068,12 @@
10691069 -- insertion.
10701070 iw_url blob NOT NULL,
10711071
 1072+ -- The URL of the file api.php
 1073+ iw_api blob NOT NULL,
 1074+
 1075+ -- The name of the database (for a connection to be established with wfGetLB( 'wikiid' ))
 1076+ iw_wikiid varchar(64) NOT NULL,
 1077+
10721078 -- A boolean value indicating whether the wiki is in this project
10731079 -- (used, for example, to detect redirect loops)
10741080 iw_local bool NOT NULL,
Property changes on: trunk/phase3/maintenance/tables.sql
___________________________________________________________________
Added: svn:mergeinfo
10751081 Merged /branches/sqlite/maintenance/tables.sql:r58211-58321
10761082 Merged /branches/iwtransclusion/phase3/maintenance/tables.sql:r68448,69480
10771083 Merged /branches/new-installer/phase3/maintenance/tables.sql:r43664-66004
10781084 Merged /branches/REL1_15/phase3/maintenance/tables.sql:r51646
Index: trunk/phase3/includes/Interwiki.php
@@ -15,11 +15,13 @@
1616 protected static $smCache = array();
1717 const CACHE_LIMIT = 100; // 0 means unlimited, any other value is max number of entries.
1818
19 - protected $mPrefix, $mURL, $mLocal, $mTrans;
 19+ protected $mPrefix, $mURL, $mAPI, $mWikiID, $mLocal, $mTrans;
2020
21 - public function __construct( $prefix = null, $url = '', $local = 0, $trans = 0 ) {
 21+ public function __construct( $prefix = null, $url = '', $api = '', $wikiid = '', $local = 0, $trans = 0 ) {
2222 $this->mPrefix = $prefix;
2323 $this->mURL = $url;
 24+ $this->mAPI = $api;
 25+ $this->mWikiID = $wikiid;
2426 $this->mLocal = $local;
2527 $this->mTrans = $trans;
2628 }
@@ -153,7 +155,7 @@
154156 __METHOD__ ) );
155157 $iw = Interwiki::loadFromArray( $row );
156158 if ( $iw ) {
157 - $mc = array( 'iw_url' => $iw->mURL, 'iw_local' => $iw->mLocal, 'iw_trans' => $iw->mTrans );
 159+ $mc = array( 'iw_url' => $iw->mURL, 'iw_api' => $iw->mAPI, 'iw_local' => $iw->mLocal, 'iw_trans' => $iw->mTrans );
158160 $wgMemc->add( $key, $mc, $wgInterwikiExpiry );
159161 return $iw;
160162 }
@@ -168,9 +170,12 @@
169171 * @return Boolean: whether everything was there
170172 */
171173 protected static function loadFromArray( $mc ) {
172 - if( isset( $mc['iw_url'] ) && isset( $mc['iw_local'] ) && isset( $mc['iw_trans'] ) ) {
 174+ if( isset( $mc['iw_url'] ) && isset( $mc['iw_api'] ) && isset( $mc['iw_wikiid'] )
 175+ && isset( $mc['iw_local'] ) && isset( $mc['iw_trans'] ) ) {
173176 $iw = new Interwiki();
174177 $iw->mURL = $mc['iw_url'];
 178+ $iw->mAPI = $mc['iw_api'];
 179+ $iw->mWikiID = $mc['iw_wikiid'];
175180 $iw->mLocal = $mc['iw_local'];
176181 $iw->mTrans = $mc['iw_trans'];
177182 return $iw;
@@ -193,6 +198,24 @@
194199 }
195200
196201 /**
 202+ * Get the API URL for this wiki
 203+ *
 204+ * @return String: the URL
 205+ */
 206+ public function getAPI( ) {
 207+ return $this->mAPI;
 208+ }
 209+
 210+ /**
 211+ * Get the DB name for this wiki
 212+ *
 213+ * @return String: the DB name
 214+ */
 215+ public function getWikiID( ) {
 216+ return $this->mWikiID;
 217+ }
 218+
 219+ /**
197220 * Is this a local link from a sister project, or is
198221 * it something outside, like Google
199222 *
Property changes on: trunk/phase3/includes/Interwiki.php
___________________________________________________________________
Added: svn:mergeinfo
200223 Merged /branches/REL1_15/phase3/includes/Interwiki.php:r51646
201224 Merged /branches/sqlite/includes/Interwiki.php:r58211-58321
202225 Merged /branches/iwtransclusion/phase3/includes/Interwiki.php:r68170,68448,69480,69541
203226 Merged /branches/new-installer/phase3/includes/Interwiki.php:r43664-66004
204227 Merged /branches/wmf-deployment/includes/Interwiki.php:r53381
Index: trunk/phase3/includes/installer/Updaters.php
@@ -166,7 +166,8 @@
167167 '1.17' => array(
168168 array( 'add_table', 'iwlinks', 'patch-iwlinks.sql' ),
169169 array( 'add_index', 'iwlinks', 'iwl_prefix_from_title', 'patch-rename-iwl_prefix.sql' ),
170 - array( 'add_field', 'updatelog', 'ul_value', 'patch-ul_value.sql' )
 170+ array( 'add_field', 'updatelog', 'ul_value', 'patch-ul_value.sql' ),
 171+ array( 'add_field', 'interwiki', 'iw_api', 'patch-iw_api_and_wikiid.sql' ),
171172 ),
172173 );
173174 }
@@ -206,6 +207,7 @@
207208 array( 'add_table', 'iwlinks', 'patch-iwlinks.sql' ),
208209 array( 'add_index', 'iwlinks', 'iwl_prefix_from_title', 'patch-rename-iwl_prefix.sql' ),
209210 array( 'add_field', 'updatelog', 'ul_value', 'patch-ul_value.sql' ),
 211+ array( 'add_field', 'interwiki', 'iw_api', 'patch-iw_api_and_wikiid.sql' ),
210212 ),
211213 );
212214 }
Property changes on: trunk/phase3/includes/installer/Updaters.php
___________________________________________________________________
Added: svn:mergeinfo
213215 Merged /branches/REL1_15/phase3/includes/installer/Updaters.php:r51646
214216 Merged /branches/sqlite/includes/installer/Updaters.php:r58211-58321
215217 Merged /branches/new-installer/phase3/includes/installer/Updaters.php:r43664-66004
216218 Merged /branches/wmf-deployment/includes/installer/Updaters.php:r53381
217219 Merged /branches/iwtransclusion/phase3/maintenance/updaters.inc:r69540
Index: trunk/phase3/includes/Title.php
@@ -522,6 +522,19 @@
523523 }
524524
525525 /**
 526+ * Returns the DB name of the distant wiki
 527+ * which owns the object.
 528+ *
 529+ * @return \type{\string} the DB name
 530+ */
 531+ public function getTransWikiID() {
 532+ if ( $this->mInterwiki == '' )
 533+ return false;
 534+
 535+ return Interwiki::fetch( $this->mInterwiki )->getWikiID();
 536+ }
 537+
 538+ /**
526539 * Escape a text fragment, say from a link, for a URL
527540 *
528541 * @param $fragment string containing a URL or link fragment (after the "#")
Property changes on: trunk/phase3/includes/Title.php
___________________________________________________________________
Added: svn:mergeinfo
529542 Merged /branches/sqlite/includes/Title.php:r58211-58321
530543 Merged /branches/iwtransclusion/phase3/includes/Title.php:r68448,69480
531544 Merged /branches/new-installer/phase3/includes/Title.php:r43664-66004
532545 Merged /branches/wmf-deployment/includes/Title.php:r53381
533546 Merged /branches/REL1_15/phase3/includes/Title.php:r51646

Follow-up revisions

RevisionCommit summaryAuthorDate
r69580Followup to r69542, since the new installer doesn't support PG, this is going...overlordq05:59, 20 July 2010
r69585Solving an issue in r69542peter1708:47, 20 July 2010
r70207* Make parsertests work with interwiki table on sqlite...mah20:17, 30 July 2010
r71118Fixed SQLite updater broken by r69542maxsem14:49, 15 August 2010

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r68170First version of my code, for interwiki transclusionpeter1713:43, 17 June 2010
r68448Adding 2 fields in the interwiki table and upgrading my codepeter1711:47, 23 June 2010
r69480Renaming DBname to WikiIDpeter1717:08, 17 July 2010
r69540iwtransclusion: Add updater for iw_api and iw_wikiid fieldscatrope11:46, 19 July 2010
r69541iwtransclusion: Add $mWikiID member to Interwiki classcatrope11:53, 19 July 2010

Comments

#Comment by Platonides (talk | contribs)   23:42, 19 July 2010

This change requires running update.php

Otherwise, due to the && isset( $mc['iw_local'] ) && isset( $mc['iw_trans'] ) condition in loadFromArray(), no interwiki will be recognised.


This could be avoided (do we want to?) if their respective class members were set to '' if they weren't set in $mc.

#Comment by Catrope (talk | contribs)   07:23, 20 July 2010

That's probably a good idea.

#Comment by Peter17 (talk | contribs)   08:48, 20 July 2010

Please see r69585 for the fix.

#Comment by MarkAHershberger (talk | contribs)   05:00, 28 July 2010
+ALTER TABLE /*_*/interwiki
+	ADD iw_api BLOB NOT NULL;

The "NOT NULL" causes installation on SQLite to fail:

$ php maintenance/install.php --dbtype=sqlite --dbpath=/tmp no test
Setting up database... done
Creating tables... Adding FTS3 search capabilities... done
Populating default interwiki table... A database query syntax error has occurred.
The last attempted database query was:
"INSERT  INTO interwiki (iw_prefix,iw_url,iw_local) VALUES ('acronym','[http://www.acronymfinder.com/af-query.asp?String=exact&Acronym=$1','0') http://www.acronymfinder.com/af-query.asp?String=exact&Acronym=$1','0')]"
from within function "DatabaseInstaller::populateInterwikiTable/multi-row".
Database returned error "19: interwiki.iw_api may not be NULL"
Backtrace:
#0 /home/mah/work/code/mediawiki/mw-svn/includes/db/Database.php(531): DatabaseBase->reportQueryError('interwiki.iw_ap...', 19, 'INSERT  INTO in...', 'DatabaseInstall...', false)
#1 /home/mah/work/code/mediawiki/mw-svn/includes/db/Database.php(1153): DatabaseBase->query('INSERT  INTO in...', 'DatabaseInstall...')
#2 /home/mah/work/code/mediawiki/mw-svn/includes/db/DatabaseSqlite.php(370): DatabaseBase->insert('interwiki', Array, 'DatabaseInstall...', Array)
#3 /home/mah/work/code/mediawiki/mw-svn/includes/installer/DatabaseInstaller.php(403): DatabaseSqlite->insert('interwiki', Array, 'DatabaseInstall...')
#4 /home/mah/work/code/mediawiki/mw-svn/includes/installer/Installer.php(365): DatabaseInstaller->populateInterwikiTable()
#5 /home/mah/work/code/mediawiki/mw-svn/includes/installer/CoreInstaller.php(325): Installer->installInterwiki(Object(SqliteInstaller))
#6 /home/mah/work/code/mediawiki/mw-svn/includes/installer/CliInstaller.php(71): CoreInstaller->performInstallation(Array, Array)
#7 /home/mah/work/code/mediawiki/mw-svn/maintenance/install.php(58): CliInstaller->execute()
#8 /home/mah/work/code/mediawiki/mw-svn/maintenance/doMaintenance.php(104): CommandLineInstaller->execute()
#9 /home/mah/work/code/mediawiki/mw-svn/maintenance/install.php(64): require_once('/home/mah/work/...')
#10 {main}
#Comment by OverlordQ (talk | contribs)   05:02, 28 July 2010

PG has the same problem, but I just set the default to page.

#Comment by 😂 (talk | contribs)   21:10, 29 July 2010

Suggest reverting back out until the branch is done. I wouldn't expect this code to make it into 1.17 before it branches anyway.

#Comment by Catrope (talk | contribs)   14:58, 31 July 2010

...or to just add a DEFAULT and be done with it?

#Comment by 😂 (talk | contribs)   15:00, 17 December 2010

Ping. What's the status on all this?

#Comment by 😂 (talk | contribs)   23:30, 5 January 2011

This is fine now.

Status & tagging log