From f32be895b8301b943bf242c30d9603039adbc25a Mon Sep 17 00:00:00 2001 From: Chad Horohoe Date: Fri, 7 May 2010 13:51:19 +0000 Subject: [PATCH] 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 --- includes/installer/Installer.i18n.php | 1 + includes/installer/Installer.php | 6 ++ includes/installer/InstallerDBType.php | 28 +++++--- includes/installer/MysqlInstaller.php | 4 +- includes/installer/SqliteInstaller.php | 2 +- maintenance/interwiki.list | 97 ++++++++++++++++++++++++++ 6 files changed, 123 insertions(+), 15 deletions(-) create mode 100644 maintenance/interwiki.list diff --git a/includes/installer/Installer.i18n.php b/includes/installer/Installer.i18n.php index c4186f5b2e..0c343ed672 100644 --- a/includes/installer/Installer.i18n.php +++ b/includes/installer/Installer.i18n.php @@ -417,6 +417,7 @@ They may require additional configuration, but you can enable them now', 'config-install-pg-schema-failed' => 'Tables creation failed. Make sure that the user "$1" can write to the schema "$2".', 'config-install-tables' => 'Creating tables', + 'config-install-interwiki' => 'Populating default interwiki table', 'config-install-interwiki-sql' => 'Could not find file interwiki.sql', 'config-install-secretkey' => 'Generating secret key', 'config-insecure-secretkey' => "'''Warning:''' Unable to create secure \$wgSecretKey. diff --git a/includes/installer/Installer.php b/includes/installer/Installer.php index 6abdbf384d..5cafed95cf 100644 --- a/includes/installer/Installer.php +++ b/includes/installer/Installer.php @@ -129,6 +129,7 @@ abstract class Installer { var $installSteps = array( 'database', 'tables', + 'interwiki', 'secretkey', 'sysop', 'localsettings', @@ -854,6 +855,11 @@ abstract class Installer { return $status; } + public function installInterwiki() { + $installer = $this->getDBInstaller(); + return $installer->populateInterwikiTable(); + } + public function installSecretKey() { $file = wfIsWindows() ? null : @fopen( "/dev/urandom", "r" ); if ( $file ) { diff --git a/includes/installer/InstallerDBType.php b/includes/installer/InstallerDBType.php index 93cde567de..93f1d4e589 100644 --- a/includes/installer/InstallerDBType.php +++ b/includes/installer/InstallerDBType.php @@ -337,21 +337,27 @@ abstract class InstallerDBType { /** * Common function for databases that don't understand the MySQLish syntax of interwiki.sql */ - protected function populateInterwikiTable( $db ) { + public function populateInterwikiTable() { + $status = $this->getConnection(); + if ( !$status->isOK() ) { + return $status; + } + $this->db->selectDB( $this->getVar( 'wgDBname' ) ); global $IP; - // Originally from DatabasePostgres - $f = fopen( "$IP/maintenance/interwiki.sql", 'r' ); - if ( $f == false ) { + $rows = file( "$IP/maintenance/interwiki.list", + FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES ); + $interwikis = array(); + if ( !$rows ) { return Status::newFatal( 'config-install-interwiki-sql' ); } - $table = $db->tableName( 'interwiki' ); - $sql = "INSERT INTO $table(iw_prefix,iw_url,iw_local) VALUES "; - while ( !feof( $f ) ) { - $line = fgets( $f, 1024 ); - $matches = array(); - if ( !preg_match( '/^\s*(\(.+?),(\d)\)/', $line, $matches ) ) continue; - $db->query( "$sql $matches[1],$matches[2])" ); + foreach( $rows as $row ) { + if( substr( $row, 0, 2 ) == '--' ) continue; // skip comments -- Whee + $interwikis[] = array_combine( + array( 'iw_prefix', 'iw_url', 'iw_local' ), + explode( '|', $row ) + ); } + $this->db->insert( 'interwiki', $interwikis, __METHOD__ ); return Status::newGood(); } diff --git a/includes/installer/MysqlInstaller.php b/includes/installer/MysqlInstaller.php index 58c667d0a7..f0d6035b8d 100644 --- a/includes/installer/MysqlInstaller.php +++ b/includes/installer/MysqlInstaller.php @@ -383,9 +383,7 @@ class MysqlInstaller extends InstallerDBType { return $status; } $this->db->selectDB( $this->getVar( 'wgDBname' ) ); - if ( !$this->db->sourceFile( "$IP/maintenance/tables.sql" ) - || !$this->db->sourceFile( "$IP/maintenance/interwiki.sql" ) ) - { + if ( !$this->db->sourceFile( "$IP/maintenance/tables.sql" ) ) { //@todo } return Status::newGood(); diff --git a/includes/installer/SqliteInstaller.php b/includes/installer/SqliteInstaller.php index 1d321e04a7..5dea22224e 100644 --- a/includes/installer/SqliteInstaller.php +++ b/includes/installer/SqliteInstaller.php @@ -160,7 +160,7 @@ class SqliteInstaller extends InstallerDBType { } //@todo set up searchindex // Create default interwikis - return $this->populateInterwikiTable( $this->db ); + return Status::newGood(); } function doUpgrade() { diff --git a/maintenance/interwiki.list b/maintenance/interwiki.list new file mode 100644 index 0000000000..42b84837d6 --- /dev/null +++ b/maintenance/interwiki.list @@ -0,0 +1,97 @@ +-- Based more or less on the public interwiki map from MeatballWiki +-- Default interwiki prefixes... +acronym|http://www.acronymfinder.com/af-query.asp?String=exact&Acronym=$1|0 +advogato|http://www.advogato.org/$1|0 +annotationwiki|http://www.seedwiki.com/page.cfm?wikiid=368&doc=$1|0 +arxiv|http://www.arxiv.org/abs/$1|0 +c2find|http://c2.com/cgi/wiki?FindPage&value=$1|0 +cache|http://www.google.com/search?q=cache:$1|0 +commons|http://commons.wikimedia.org/wiki/$1|0 +corpknowpedia|http://corpknowpedia.org/wiki/index.php/$1|0 +dictionary|http://www.dict.org/bin/Dict?Database=*&Form=Dict1&Strategy=*&Query=$1|0 +disinfopedia|http://www.disinfopedia.org/wiki.phtml?title=$1|0 +docbook|http://wiki.docbook.org/topic/$1|0 +doi|http://dx.doi.org/$1|0 +drumcorpswiki|http://www.drumcorpswiki.com/index.php/$1|0 +dwjwiki|http://www.suberic.net/cgi-bin/dwj/wiki.cgi?$1|0 +emacswiki|http://www.emacswiki.org/cgi-bin/wiki.pl?$1|0 +elibre|http://enciclopedia.us.es/index.php/$1|0 +foldoc|http://foldoc.org/?$1|0 +foxwiki|http://fox.wikis.com/wc.dll?Wiki~$1|0 +freebsdman|http://www.FreeBSD.org/cgi/man.cgi?apropos=1&query=$1|0 +gej|http://www.esperanto.de/cgi-bin/aktivikio/wiki.pl?$1|0 +gentoo-wiki|http://gentoo-wiki.com/$1|0 +google|http://www.google.com/search?q=$1|0 +googlegroups|http://groups.google.com/groups?q=$1|0 +hammondwiki|http://www.dairiki.org/HammondWiki/$1|0 +hewikisource|http://he.wikisource.org/wiki/$1|1 +hrwiki|http://www.hrwiki.org/index.php/$1|0 +imdb|http://us.imdb.com/Title?$1|0 +jargonfile|http://sunir.org/apps/meta.pl?wiki=JargonFile&redirect=$1|0 +jspwiki|http://www.jspwiki.org/wiki/$1|0 +keiki|http://kei.ki/en/$1|0 +kmwiki|http://kmwiki.wikispaces.com/$1|0 +linuxwiki|http://linuxwiki.de/$1|0 +lojban|http://www.lojban.org/tiki/tiki-index.php?page=$1|0 +lqwiki|http://wiki.linuxquestions.org/wiki/$1|0 +lugkr|http://lug-kr.sourceforge.net/cgi-bin/lugwiki.pl?$1|0 +mathsongswiki|http://SeedWiki.com/page.cfm?wikiid=237&doc=$1|0 +meatball|http://www.usemod.com/cgi-bin/mb.pl?$1|0 +mediazilla|https://bugzilla.wikimedia.org/$1|1 +mediawikiwiki|http://www.mediawiki.org/wiki/$1|0 +memoryalpha|http://www.memory-alpha.org/en/index.php/$1|0 +metawiki|http://sunir.org/apps/meta.pl?$1|0 +metawikipedia|http://meta.wikimedia.org/wiki/$1|0 +moinmoin|http://purl.net/wiki/moin/$1|0 +mozillawiki|http://wiki.mozilla.org/index.php/$1|0 +mw|http://www.mediawiki.org/wiki/$1|0 +oeis|http://www.research.att.com/cgi-bin/access.cgi/as/njas/sequences/eisA.cgi?Anum=$1|0 +openfacts|http://openfacts.berlios.de/index.phtml?title=$1|0 +openwiki|http://openwiki.com/?$1|0 +patwiki|http://gauss.ffii.org/$1|0), # 2008-02-27: lots of spambots +pmeg|http://www.bertilow.com/pmeg/$1.php|0 +ppr|http://c2.com/cgi/wiki?$1|0 +pythoninfo|http://wiki.python.org/moin/$1|0 +rfc|http://www.rfc-editor.org/rfc/rfc$1.txt|0 +s23wiki|http://is-root.de/wiki/index.php/$1|0 +seattlewiki|http://seattle.wikia.com/wiki/$1|0 +seattlewireless|http://seattlewireless.net/?$1|0 +senseislibrary|http://senseis.xmp.net/?$1|0 +slashdot|http://slashdot.org/article.pl?sid=$1|0), # 2008-02-27: update me +sourceforge|http://sourceforge.net/$1|0 +squeak|http://wiki.squeak.org/squeak/$1|0 +susning|http://www.susning.nu/$1|0 +svgwiki|http://wiki.svg.org/$1|0 +tavi|http://tavi.sourceforge.net/$1|0 +tejo|http://www.tejo.org/vikio/$1|0 +tmbw|http://www.tmbw.net/wiki/$1|0 +tmnet|http://www.technomanifestos.net/?$1|0 +tmwiki|http://www.EasyTopicMaps.com/?page=$1|0 +theopedia|http://www.theopedia.com/$1|0 +twiki|http://twiki.org/cgi-bin/view/$1|0 +uea|http://www.tejo.org/uea/$1|0 +unreal|http://wiki.beyondunreal.com/wiki/$1|0 +usemod|http://www.usemod.com/cgi-bin/wiki.pl?$1|0 +vinismo|http://vinismo.com/en/$1|0 +webseitzwiki|http://webseitz.fluxent.com/wiki/$1|0 +why|http://clublet.com/c/c/why?$1|0 +wiki|http://c2.com/cgi/wiki?$1|0 +wikia|http://www.wikia.com/wiki/$1|0 +wikibooks|http://en.wikibooks.org/wiki/$1|1 +wikicities|http://www.wikia.com/wiki/$1|0 +wikif1|http://www.wikif1.org/$1|0 +wikihow|http://www.wikihow.com/$1|0 +wikinfo|http://www.wikinfo.org/index.php/$1|0 +wikimedia|http://wikimediafoundation.org/wiki/$1|0 +wikinews|http://en.wikinews.org/wiki/$1|1 +wikiquote|http://en.wikiquote.org/wiki/$1|1 +wikipedia|http://en.wikipedia.org/wiki/$1|1 +wikisource|http://wikisource.org/wiki/$1|1 +wikispecies|http://species.wikimedia.org/wiki/$1|1 +wikitravel|http://wikitravel.org/en/$1|0 +wikiversity|http://en.wikiversity.org/wiki/$1|1 +wikt|http://en.wiktionary.org/wiki/$1|1 +wiktionary|http://en.wiktionary.org/wiki/$1|1 +wlug|http://www.wlug.org.nz/$1|0 +zwiki|http://zwiki.org/$1|0 +zzz wiki|http://wiki.zzz.ee/index.php/$1|0 \ No newline at end of file -- 2.20.1