From: Greg Sabino Mullane Date: Sat, 9 Dec 2006 17:23:13 +0000 (+0000) Subject: Overhaul and cleanup Postgres older version updater. X-Git-Tag: 1.31.0-rc.0~54948 X-Git-Url: http://git.cyclocoop.org/url?a=commitdiff_plain;h=36b8d68f268950c875dd5ebfb968c2f95f405a81;p=lhc%2Fweb%2Fwiklou.git Overhaul and cleanup Postgres older version updater. --- diff --git a/maintenance/updaters.inc b/maintenance/updaters.inc index 400da7e128..25a0223843 100644 --- a/maintenance/updaters.inc +++ b/maintenance/updaters.inc @@ -907,20 +907,28 @@ function archive($name) { function do_postgres_updates() { global $wgDatabase, $wgVersion, $wgDBmwschema; - $version = "1.7.1"; - # Just in case their LocalSetings.php does not have this: if ( !isset( $wgDBmwschema )) $wgDBmwschema = 'mediawiki'; + ## Default to the oldest supported version + $version = 1.7; + if ($wgDatabase->tableExists("mediawiki_version")) { $version = "1.8"; + $sql = "SELECT mw_version FROM mediawiki_version ORDER BY cdate DESC LIMIT 1"; + $tempversion = pg_fetch_result($wgDatabase->doQuery($sql),0,0); + $thisver = array(); + if (preg_match('/(\d+\.\d+)/', $tempversion, $thisver)) { + $version = $thisver[1]; + } } - if ($version == '1.7.1') { - $upgrade = <<query($upgrade); - + $upgrade = str_replace( 'THISVERSION', $version, $upgrade ); + $res = $wgDatabase->query("BEGIN;\n\n $upgrade\n\nCOMMIT;\n"); return; }