r66013 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r66012‎ | r66013 | r66014 >
Date:13:51, 7 May 2010
Author:demon
Status:resolved (Comments)
Tags:
Comment:
Stop using mySQL-specific interwiki.sql, broke this into new file interwiki.list. Move interwiki population to its own installer step so it can return errors independently of table creation
Modified paths:
  • /trunk/phase3/includes/installer/Installer.i18n.php (modified) (history)
  • /trunk/phase3/includes/installer/Installer.php (modified) (history)
  • /trunk/phase3/includes/installer/InstallerDBType.php (modified) (history)
  • /trunk/phase3/includes/installer/MysqlInstaller.php (modified) (history)
  • /trunk/phase3/includes/installer/SqliteInstaller.php (modified) (history)
  • /trunk/phase3/maintenance/interwiki.list (added) (history)

Diff [purge]

Index: trunk/phase3/maintenance/interwiki.list
@@ -0,0 +1,97 @@
 2+-- Based more or less on the public interwiki map from MeatballWiki
 3+-- Default interwiki prefixes...
 4+acronym|http://www.acronymfinder.com/af-query.asp?String=exact&Acronym=$1|0
 5+advogato|http://www.advogato.org/$1|0
 6+annotationwiki|http://www.seedwiki.com/page.cfm?wikiid=368&doc=$1|0
 7+arxiv|http://www.arxiv.org/abs/$1|0
 8+c2find|http://c2.com/cgi/wiki?FindPage&value=$1|0
 9+cache|http://www.google.com/search?q=cache:$1|0
 10+commons|http://commons.wikimedia.org/wiki/$1|0
 11+corpknowpedia|http://corpknowpedia.org/wiki/index.php/$1|0
 12+dictionary|http://www.dict.org/bin/Dict?Database=*&Form=Dict1&Strategy=*&Query=$1|0
 13+disinfopedia|http://www.disinfopedia.org/wiki.phtml?title=$1|0
 14+docbook|http://wiki.docbook.org/topic/$1|0
 15+doi|http://dx.doi.org/$1|0
 16+drumcorpswiki|http://www.drumcorpswiki.com/index.php/$1|0
 17+dwjwiki|http://www.suberic.net/cgi-bin/dwj/wiki.cgi?$1|0
 18+emacswiki|http://www.emacswiki.org/cgi-bin/wiki.pl?$1|0
 19+elibre|http://enciclopedia.us.es/index.php/$1|0
 20+foldoc|http://foldoc.org/?$1|0
 21+foxwiki|http://fox.wikis.com/wc.dll?Wiki~$1|0
 22+freebsdman|http://www.FreeBSD.org/cgi/man.cgi?apropos=1&query=$1|0
 23+gej|http://www.esperanto.de/cgi-bin/aktivikio/wiki.pl?$1|0
 24+gentoo-wiki|http://gentoo-wiki.com/$1|0
 25+google|http://www.google.com/search?q=$1|0
 26+googlegroups|http://groups.google.com/groups?q=$1|0
 27+hammondwiki|http://www.dairiki.org/HammondWiki/$1|0
 28+hewikisource|http://he.wikisource.org/wiki/$1|1
 29+hrwiki|http://www.hrwiki.org/index.php/$1|0
 30+imdb|http://us.imdb.com/Title?$1|0
 31+jargonfile|http://sunir.org/apps/meta.pl?wiki=JargonFile&redirect=$1|0
 32+jspwiki|http://www.jspwiki.org/wiki/$1|0
 33+keiki|http://kei.ki/en/$1|0
 34+kmwiki|http://kmwiki.wikispaces.com/$1|0
 35+linuxwiki|http://linuxwiki.de/$1|0
 36+lojban|http://www.lojban.org/tiki/tiki-index.php?page=$1|0
 37+lqwiki|http://wiki.linuxquestions.org/wiki/$1|0
 38+lugkr|http://lug-kr.sourceforge.net/cgi-bin/lugwiki.pl?$1|0
 39+mathsongswiki|http://SeedWiki.com/page.cfm?wikiid=237&doc=$1|0
 40+meatball|http://www.usemod.com/cgi-bin/mb.pl?$1|0
 41+mediazilla|https://bugzilla.wikimedia.org/$1|1
 42+mediawikiwiki|http://www.mediawiki.org/wiki/$1|0
 43+memoryalpha|http://www.memory-alpha.org/en/index.php/$1|0
 44+metawiki|http://sunir.org/apps/meta.pl?$1|0
 45+metawikipedia|http://meta.wikimedia.org/wiki/$1|0
 46+moinmoin|http://purl.net/wiki/moin/$1|0
 47+mozillawiki|http://wiki.mozilla.org/index.php/$1|0
 48+mw|http://www.mediawiki.org/wiki/$1|0
 49+oeis|http://www.research.att.com/cgi-bin/access.cgi/as/njas/sequences/eisA.cgi?Anum=$1|0
 50+openfacts|http://openfacts.berlios.de/index.phtml?title=$1|0
 51+openwiki|http://openwiki.com/?$1|0
 52+patwiki|http://gauss.ffii.org/$1|0), # 2008-02-27: lots of spambots
 53+pmeg|http://www.bertilow.com/pmeg/$1.php|0
 54+ppr|http://c2.com/cgi/wiki?$1|0
 55+pythoninfo|http://wiki.python.org/moin/$1|0
 56+rfc|http://www.rfc-editor.org/rfc/rfc$1.txt|0
 57+s23wiki|http://is-root.de/wiki/index.php/$1|0
 58+seattlewiki|http://seattle.wikia.com/wiki/$1|0
 59+seattlewireless|http://seattlewireless.net/?$1|0
 60+senseislibrary|http://senseis.xmp.net/?$1|0
 61+slashdot|http://slashdot.org/article.pl?sid=$1|0), # 2008-02-27: update me
 62+sourceforge|http://sourceforge.net/$1|0
 63+squeak|http://wiki.squeak.org/squeak/$1|0
 64+susning|http://www.susning.nu/$1|0
 65+svgwiki|http://wiki.svg.org/$1|0
 66+tavi|http://tavi.sourceforge.net/$1|0
 67+tejo|http://www.tejo.org/vikio/$1|0
 68+tmbw|http://www.tmbw.net/wiki/$1|0
 69+tmnet|http://www.technomanifestos.net/?$1|0
 70+tmwiki|http://www.EasyTopicMaps.com/?page=$1|0
 71+theopedia|http://www.theopedia.com/$1|0
 72+twiki|http://twiki.org/cgi-bin/view/$1|0
 73+uea|http://www.tejo.org/uea/$1|0
 74+unreal|http://wiki.beyondunreal.com/wiki/$1|0
 75+usemod|http://www.usemod.com/cgi-bin/wiki.pl?$1|0
 76+vinismo|http://vinismo.com/en/$1|0
 77+webseitzwiki|http://webseitz.fluxent.com/wiki/$1|0
 78+why|http://clublet.com/c/c/why?$1|0
 79+wiki|http://c2.com/cgi/wiki?$1|0
 80+wikia|http://www.wikia.com/wiki/$1|0
 81+wikibooks|http://en.wikibooks.org/wiki/$1|1
 82+wikicities|http://www.wikia.com/wiki/$1|0
 83+wikif1|http://www.wikif1.org/$1|0
 84+wikihow|http://www.wikihow.com/$1|0
 85+wikinfo|http://www.wikinfo.org/index.php/$1|0
 86+wikimedia|http://wikimediafoundation.org/wiki/$1|0
 87+wikinews|http://en.wikinews.org/wiki/$1|1
 88+wikiquote|http://en.wikiquote.org/wiki/$1|1
 89+wikipedia|http://en.wikipedia.org/wiki/$1|1
 90+wikisource|http://wikisource.org/wiki/$1|1
 91+wikispecies|http://species.wikimedia.org/wiki/$1|1
 92+wikitravel|http://wikitravel.org/en/$1|0
 93+wikiversity|http://en.wikiversity.org/wiki/$1|1
 94+wikt|http://en.wiktionary.org/wiki/$1|1
 95+wiktionary|http://en.wiktionary.org/wiki/$1|1
 96+wlug|http://www.wlug.org.nz/$1|0
 97+zwiki|http://zwiki.org/$1|0
 98+zzz wiki|http://wiki.zzz.ee/index.php/$1|0
\ No newline at end of file
Index: trunk/phase3/includes/installer/Installer.i18n.php
@@ -417,6 +417,7 @@
418418 'config-install-pg-schema-failed' => 'Tables creation failed.
419419 Make sure that the user "$1" can write to the schema "$2".',
420420 'config-install-tables' => 'Creating tables',
 421+ 'config-install-interwiki' => 'Populating default interwiki table',
421422 'config-install-interwiki-sql' => 'Could not find file <code>interwiki.sql</code>',
422423 'config-install-secretkey' => 'Generating secret key',
423424 'config-insecure-secretkey' => "'''Warning:''' Unable to create secure <code>\$wgSecretKey</code>.
Index: trunk/phase3/includes/installer/Installer.php
@@ -129,6 +129,7 @@
130130 var $installSteps = array(
131131 'database',
132132 'tables',
 133+ 'interwiki',
133134 'secretkey',
134135 'sysop',
135136 'localsettings',
@@ -854,6 +855,11 @@
855856 return $status;
856857 }
857858
 859+ public function installInterwiki() {
 860+ $installer = $this->getDBInstaller();
 861+ return $installer->populateInterwikiTable();
 862+ }
 863+
858864 public function installSecretKey() {
859865 $file = wfIsWindows() ? null : @fopen( "/dev/urandom", "r" );
860866 if ( $file ) {
Index: trunk/phase3/includes/installer/SqliteInstaller.php
@@ -160,7 +160,7 @@
161161 }
162162 //@todo set up searchindex
163163 // Create default interwikis
164 - return $this->populateInterwikiTable( $this->db );
 164+ return Status::newGood();
165165 }
166166
167167 function doUpgrade() {
Index: trunk/phase3/includes/installer/MysqlInstaller.php
@@ -383,9 +383,7 @@
384384 return $status;
385385 }
386386 $this->db->selectDB( $this->getVar( 'wgDBname' ) );
387 - if ( !$this->db->sourceFile( "$IP/maintenance/tables.sql" )
388 - || !$this->db->sourceFile( "$IP/maintenance/interwiki.sql" ) )
389 - {
 387+ if ( !$this->db->sourceFile( "$IP/maintenance/tables.sql" ) ) {
390388 //@todo
391389 }
392390 return Status::newGood();
Index: trunk/phase3/includes/installer/InstallerDBType.php
@@ -337,21 +337,27 @@
338338 /**
339339 * Common function for databases that don't understand the MySQLish syntax of interwiki.sql
340340 */
341 - protected function populateInterwikiTable( $db ) {
 341+ public function populateInterwikiTable() {
 342+ $status = $this->getConnection();
 343+ if ( !$status->isOK() ) {
 344+ return $status;
 345+ }
 346+ $this->db->selectDB( $this->getVar( 'wgDBname' ) );
342347 global $IP;
343 - // Originally from DatabasePostgres
344 - $f = fopen( "$IP/maintenance/interwiki.sql", 'r' );
345 - if ( $f == false ) {
 348+ $rows = file( "$IP/maintenance/interwiki.list",
 349+ FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES );
 350+ $interwikis = array();
 351+ if ( !$rows ) {
346352 return Status::newFatal( 'config-install-interwiki-sql' );
347353 }
348 - $table = $db->tableName( 'interwiki' );
349 - $sql = "INSERT INTO $table(iw_prefix,iw_url,iw_local) VALUES ";
350 - while ( !feof( $f ) ) {
351 - $line = fgets( $f, 1024 );
352 - $matches = array();
353 - if ( !preg_match( '/^\s*(\(.+?),(\d)\)/', $line, $matches ) ) continue;
354 - $db->query( "$sql $matches[1],$matches[2])" );
 354+ foreach( $rows as $row ) {
 355+ if( substr( $row, 0, 2 ) == '--' ) continue; // skip comments -- Whee
 356+ $interwikis[] = array_combine(
 357+ array( 'iw_prefix', 'iw_url', 'iw_local' ),
 358+ explode( '|', $row )
 359+ );
355360 }
 361+ $this->db->insert( 'interwiki', $interwikis, __METHOD__ );
356362 return Status::newGood();
357363 }
358364

Follow-up revisions

RevisionCommit summaryAuthorDate
r68457Fixes for r66013: fixed syntax, switched interwiki.list to use more customary...maxsem16:06, 23 June 2010
r81542Remove unused interwiki.sql like I said I would in r66013demon21:12, 4 February 2011

Comments

#Comment by MaxSem (talk | contribs)   06:32, 23 June 2010

Should interwiki.sql be deleted now?

#Comment by 😂 (talk | contribs)   12:34, 23 June 2010

The old updater/installer still uses it, so not until that goes away.

#Comment by Platonides (talk | contribs)   15:32, 23 June 2010
patwiki|http://gauss.ffii.org/$1|0), # 2008-02-27: lots of spambots
slashdot|http://slashdot.org/article.pl?sid=$1|0), # 2008-02-27: update me

This looks like an error in trasnforming the file.

I'm not sure that changing the format is needed, since the other db types already handle it quite well.

Although I'd place it into a common function inside Database.php, instead of duplicating the same piece of code inside each db type setup_databas().

#Comment by Catrope (talk | contribs)   13:05, 7 December 2010
+		$installer = $this->getDBInstaller();
+		return $installer->populateInterwikiTable();

What's wrong with $this->getDBInstaller()->populateInterwikiTabe(); ? This reminds me of PHP4.

#Comment by 😂 (talk | contribs)   13:06, 7 December 2010

That stuff was all changed, see current CoreInstaller::getInstallSteps()

Status & tagging log