r92611 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r92610‎ | r92611 | r92612 >
Date:08:14, 20 July 2011
Author:aaron
Status:ok (Comments)
Tags:
Comment:
* Added MWMultiVersion::getVersionNumber method and use it for various dirs (consistent with 1.17)
* Updated $wgTexvc per r91703
* Enforce wikiversions.cdb format conformity a bit more
Modified paths:
  • /trunk/tools/mwmultiversion/scripts/mwversionsinuse (added) (history)
  • /trunk/tools/mwmultiversion/scripts/wikiversions.cdb.sample (added) (history)
  • /trunk/tools/mwmultiversion/scripts/wikiversions.dat.sample (deleted) (history)
  • /trunk/tools/mwmultiversion/wmf-config/CommonSettings.php (modified) (history)
  • /trunk/tools/mwmultiversion/wmf-config/MWMultiVersion.php (modified) (history)

Diff [purge]

Index: trunk/tools/mwmultiversion/scripts/wikiversions.dat.sample
@@ -1,3 +0,0 @@
2 -trunkwiki trunk
3 -enwiki php-1.17
4 -testwiki php-1.18
Index: trunk/tools/mwmultiversion/scripts/mwversionsinuse
@@ -0,0 +1,26 @@
 2+#!/bin/sh
 3+# Returns a space separated list of all active MW versions (e.g. x.xx).
 4+# This script belongs in /usr/bin/ and should be in PATH.
 5+declare -a mwVersionsionNums
 6+while read line
 7+do
 8+ mwVersion=${line#* }
 9+ mwVersionNum=${mwVersion#*-}
 10+ if [ -n "$mwVersion" -a -n "$mwVersionNum" ]; then
 11+ mwVersionInArray=0
 12+ for i in "${mwVersionsionNums[@]}"
 13+ do
 14+ if [ "$i" -eq "$mwVersionNum" ]; then
 15+ mwVersionInArray=1
 16+ break
 17+ fi
 18+ done
 19+ if [ mwVersionInArray -eq 0 ]; then
 20+ mwVersionsionNums=("${mwVersionsionNums[@]}" mwVersionNum)
 21+ fi
 22+ else
 23+ echo ""
 24+ exit 1
 25+ fi
 26+done < /usr/local/apache/common-local/wmf-config/wikiversions.cdb
 27+echo "${mwVersionsionNums[@]}"
Index: trunk/tools/mwmultiversion/scripts/wikiversions.cdb.sample
@@ -0,0 +1,3 @@
 2+trunkwiki php-trunk
 3+enwiki php-1.17
 4+testwiki php-1.18
Property changes on: trunk/tools/mwmultiversion/scripts/wikiversions.cdb.sample
___________________________________________________________________
Added: svn:eol-style
15 + native
Index: trunk/tools/mwmultiversion/wmf-config/CommonSettings.php
@@ -95,7 +95,7 @@
9696
9797 # Determine domain and language and the directories for this instance
9898 list( $site, $lang ) = $wgConf->siteFromDB( $wgDBname );
99 -$wgVersionDirectory = $multiVersion->getVersion();
 99+$wgVersionNumber = $multiVersion->getVersionNumber();
100100
101101 # Is this database listed in $cluster.dblist?
102102 if ( array_search( $wgDBname, $wgLocalDatabases ) === false ){
@@ -110,7 +110,7 @@
111111
112112 # Try configuration cache
113113
114 -$filename = "/tmp/mw-cache-$wgVersionDirectory/conf-$wgDBname";
 114+$filename = "/tmp/mw-cache-$wgVersionNumber/conf-$wgDBname";
115115 $globals = false;
116116 if ( @filemtime( $filename ) >= filemtime( "$wmfConfigDir/InitialiseSettings.php" ) ) {
117117 $cacheRecord = @file_get_contents( $filename );
@@ -143,7 +143,7 @@
144144
145145 # Save cache
146146 $oldUmask = umask( 0 );
147 - @mkdir( '/tmp/mw-cache-' . $wgVersionDirectory, 0777 );
 147+ @mkdir( '/tmp/mw-cache-' . $wgVersionNumber, 0777 );
148148 $file = fopen( $filename, 'w' );
149149 if ( $file ) {
150150 fwrite( $file, serialize( $globals ) );
@@ -182,18 +182,18 @@
183183 #$wgStyleSheetPath = '/w/skins-1.17';
184184 if ( $wgDBname == 'testwiki' ) {
185185 // Make testing skin/JS changes easier
186 - $wgExtensionAssetsPath = "$urlprotocol//test.wikipedia.org/w/extensions-" . $wgVersionDirectory;
187 - $wgStyleSheetPath = "$urlprotocol//test.wikipedia.org/w/skins-" . $wgVersionDirectory;
 186+ $wgExtensionAssetsPath = "$urlprotocol//test.wikipedia.org/w/extensions-" . $wgVersionNumber;
 187+ $wgStyleSheetPath = "$urlprotocol//test.wikipedia.org/w/skins-" . $wgVersionNumber;
188188
189189 } else {
190 - $wgExtensionAssetsPath = "$urlprotocol//bits.wikimedia.org/w/extensions-" . $wgVersionDirectory;
191 - $wgStyleSheetPath = "$urlprotocol//bits.wikimedia.org/skins-" . $wgVersionDirectory;
 190+ $wgExtensionAssetsPath = "$urlprotocol//bits.wikimedia.org/w/extensions-" . $wgVersionNumber;
 191+ $wgStyleSheetPath = "$urlprotocol//bits.wikimedia.org/skins-" . $wgVersionNumber;
192192 }
193193 $wgStylePath = $wgStyleSheetPath;
194194 $wgArticlePath = "/wiki/$1";
195195
196196 $wgScriptPath = '/w';
197 -$wgLocalStylePath = "$wgScriptPath/skins-$wgVersionDirectory";
 197+$wgLocalStylePath = "$wgScriptPath/skins-$wgVersionNumber";
198198 $wgStockPath = '/images';
199199 $wgScript = $wgScriptPath.'/index.php';
200200 $wgRedirectScript = $wgScriptPath.'/redirect.php';
@@ -204,7 +204,7 @@
205205
206206 $oldLabsWikis = array( 'en_labswikimedia', 'de_labswikimedia', 'flaggedrevs_labswikimedia' );
207207 if ( !in_array( $wgDBname, $oldLabsWikis ) ) {
208 - $wgCacheDirectory = '/tmp/mw-cache-' . $wgVersionDirectory;
 208+ $wgCacheDirectory = '/tmp/mw-cache-' . $wgVersionNumber;
209209 } else {
210210 # @TODO: remove this hack (use multiversioning proper)
211211 $wgCacheDirectory = '/tmp/mw-cache-labs';
@@ -261,7 +261,7 @@
262262 $wgRCMaxAge = 30*86400;
263263
264264 $wgUseTeX = true;
265 -$wgTexvc = "/usr/local/bin/texvc";
 265+$wgTexvc = "/usr/local/apache/uncommon/$wgVersionNumber/bin";
266266 $wgTmpDirectory = '/tmp';
267267 $wgLegalTitleChars = "+ %!\"$&'()*,\\-.\\/0-9:;=?@A-Z\\\\^_`a-z~\\x80-\\xFF";
268268
Index: trunk/tools/mwmultiversion/wmf-config/MWMultiVersion.php
@@ -194,18 +194,32 @@
195195 }
196196
197197 /**
198 - * Get the version as specified in a cdb file located in /usr/local/apache/common/wikiversions.db
199 - * The key should be the dbname and the version should be the version directory for this wiki
200 - * @return String the version wirectory for this wiki
 198+ * Get the version as specified in a cdb file located
 199+ * at /usr/local/apache/common/wikiversions.cdb.
 200+ * The key should be the dbname and the version should be the version directory.
 201+ * @return String the version directory for this wiki
201202 */
202203 public function getVersion() {
203204 $db = dba_open( '/usr/local/apache/common/wikiversions.cdb', 'r', 'cdb' );
204205 if ( $db ) {
205206 $version = dba_fetch( $this->getDatabase(), $db );
 207+ if ( strpos( $version, '-' ) === false ) {
 208+ die( 'wikiversions.cdb entry should be of the format: php-...' );
 209+ }
206210 } else {
207 - //trigger_error( "Unable to open /usr/local/apache/common/wikiversions.db. Assuming php-1.17", E_USER_ERROR );
 211+ //trigger_error( "Unable to open /usr/local/apache/common/wikiversions.cdb. Assuming php-1.17", E_USER_ERROR );
208212 $version = 'php-1.17';
209213 }
210214 return $version;
211215 }
 216+
 217+ /**
 218+ * Get the version number as specified in a cdb file located
 219+ * at /usr/local/apache/common/wikiversions.cdb.
 220+ * @return String the version number for this wiki (e.g. "x.xx" or "trunk")
 221+ */
 222+ public function getVersionNumber() {
 223+ list( /*...*/, $ver ) = explode( $this->getVersion(), '-', 2 );
 224+ return $ver;
 225+ }
212226 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r92612Cleaned up mwversionsinuse bash script (committed by accident in r92611)aaron08:40, 20 July 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r91703* Sync script updates for improved privilege separation. A new user (mwdeploy...tstarling00:50, 8 July 2011

Comments

#Comment by Aaron Schulz (talk | contribs)   08:30, 20 July 2011

Didn't mean to commit unfinished mwversionsinuse script...sigh.

#Comment by Catrope (talk | contribs)   19:13, 20 July 2011

Didn't review bash script. Should be reviewed by someone with more bash chops in r92612.

Status & tagging log