Reedy has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/91796


Change subject: Move activeMWVersions to a php file. Create wrapper to replace 
it
......................................................................

Move activeMWVersions to a php file. Create wrapper to replace it

Change-Id: I65d04735615e2feb1411e6a4e13a2e156326442e
---
M multiversion/activeMWVersions
A multiversion/activeMWVersions.php
2 files changed, 66 insertions(+), 64 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/operations/mediawiki-config 
refs/changes/96/91796/1

diff --git a/multiversion/activeMWVersions b/multiversion/activeMWVersions
index 21afca4..49d8002 100755
--- a/multiversion/activeMWVersions
+++ b/multiversion/activeMWVersions
@@ -1,66 +1,3 @@
 #!/usr/bin/env php
 <?php
-error_reporting( 0 );
-
-require_once( dirname( __FILE__ ) . '/defines.php' );
-require_once( dirname( __FILE__ ) . '/MWRealm.php' );
-require_once( dirname( __FILE__ ) . '/MWWikiversions.php' );
-
-/*
- * Returns a space separated list of all active MW versions (e.g. "x.xx").
- * Versions are read from /usr/local/apache/common-local/wikiversions.cdb.
- *
- * Given --home, versions are instead read from /a/common/wikiversions.cdb.
- * Given --withdb, each item in the list will be appended with '=' followed by
- *             the DB name of *some* wiki that uses that version. Used to run 
maintenance scripts.
- * Given --extended, versions will include any extra suffix specified in 
wikiversions.cdb.
- *             This may result in more items being listed than without.
- * Given --report, error messages would be displayed if this dies.
- *
- * @return string
- */
-function getActiveWikiVersions() {
-       global $argv;
-       $options = $argv; // copy
-       array_shift( $options ); // first item is this file
-
-       if ( in_array( '--home', $options ) ) {
-               $datPath = getRealmSpecificFilename( MULTIVER_CDB_DIR_HOME . 
'/wikiversions.dat' );
-       } else {
-               $datPath = getRealmSpecificFilename( MULTIVER_CDB_DIR_APACHE . 
'/wikiversions.dat' );
-       }
-
-       # Get all the wikiversion rows in wikiversions.dat...
-       try {
-               $versionRows = MWWikiversions::readWikiVersionsFile( $datPath );
-       } catch( Exception $e ) {
-               if ( in_array( '--report', $options ) ) {
-                       throw $e; // show error
-               } else {
-                       die( 1 ); // silent death
-               }
-       }
-
-       $result = $activeVersions = array();
-       foreach ( $versionRows as $row ) {
-               list( $dbName, $version, $extVersion, $comment ) = $row;
-               if ( $extVersion !== '*' && in_array( '--extended', $options ) 
) {
-                       $version .= "-$extVersion";
-               }
-               if ( !isset( $activeVersions[$version] ) ) { // already listed?
-                       $activeVersions[$version] = 1;
-
-                       $version = substr( $version, 4 ); // remove 'php-'
-                       if ( in_array( '--withdb', $options ) ) {
-                               $result[] = "{$version}={$dbName}";
-                       } else {
-                               $result[] = "{$version}";
-                       }
-               }
-
-       }
-
-       return implode( ' ', $result );
-}
-
-echo getActiveWikiVersions() . "\n";
+require_once( dirname( __FILE__ ) . '/activeMWVersions.php' );
diff --git a/multiversion/activeMWVersions.php 
b/multiversion/activeMWVersions.php
new file mode 100755
index 0000000..dfaa0c8
--- /dev/null
+++ b/multiversion/activeMWVersions.php
@@ -0,0 +1,65 @@
+<?php
+error_reporting( 0 );
+
+require_once( dirname( __FILE__ ) . '/defines.php' );
+require_once( dirname( __FILE__ ) . '/MWRealm.php' );
+require_once( dirname( __FILE__ ) . '/MWWikiversions.php' );
+
+/*
+ * Returns a space separated list of all active MW versions (e.g. "x.xx").
+ * Versions are read from /usr/local/apache/common-local/wikiversions.cdb.
+ *
+ * Given --home, versions are instead read from /a/common/wikiversions.cdb.
+ * Given --withdb, each item in the list will be appended with '=' followed by
+ *             the DB name of *some* wiki that uses that version. Used to run 
maintenance scripts.
+ * Given --extended, versions will include any extra suffix specified in 
wikiversions.cdb.
+ *             This may result in more items being listed than without.
+ * Given --report, error messages would be displayed if this dies.
+ *
+ * @return string
+ */
+function getActiveWikiVersions() {
+       global $argv;
+       $options = $argv; // copy
+       array_shift( $options ); // first item is this file
+
+       if ( in_array( '--home', $options ) ) {
+               $datPath = getRealmSpecificFilename( MULTIVER_CDB_DIR_HOME . 
'/wikiversions.dat' );
+       } else {
+               $datPath = getRealmSpecificFilename( MULTIVER_CDB_DIR_APACHE . 
'/wikiversions.dat' );
+       }
+
+       # Get all the wikiversion rows in wikiversions.dat...
+       try {
+               $versionRows = MWWikiversions::readWikiVersionsFile( $datPath );
+       } catch( Exception $e ) {
+               if ( in_array( '--report', $options ) ) {
+                       throw $e; // show error
+               } else {
+                       die( 1 ); // silent death
+               }
+       }
+
+       $result = $activeVersions = array();
+       foreach ( $versionRows as $row ) {
+               list( $dbName, $version, $extVersion, $comment ) = $row;
+               if ( $extVersion !== '*' && in_array( '--extended', $options ) 
) {
+                       $version .= "-$extVersion";
+               }
+               if ( !isset( $activeVersions[$version] ) ) { // already listed?
+                       $activeVersions[$version] = 1;
+
+                       $version = substr( $version, 4 ); // remove 'php-'
+                       if ( in_array( '--withdb', $options ) ) {
+                               $result[] = "{$version}={$dbName}";
+                       } else {
+                               $result[] = "{$version}";
+                       }
+               }
+
+       }
+
+       return implode( ' ', $result );
+}
+
+echo getActiveWikiVersions() . "\n";

-- 
To view, visit https://gerrit.wikimedia.org/r/91796
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I65d04735615e2feb1411e6a4e13a2e156326442e
Gerrit-PatchSet: 1
Gerrit-Project: operations/mediawiki-config
Gerrit-Branch: master
Gerrit-Owner: Reedy <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to