jenkins-bot has submitted this change and it was merged. Change subject: wikiversions.cdb for labs ......................................................................
wikiversions.cdb for labs This patch adapts multiversion to detect an eventual wikiversions-labs.cdb file whenever it exists. With git-deploy we will have to add the .cdb files to git in order to deploy them, so we want wikiversions-labs.dat to generate a different cdb file. Bug: 44424 Change-Id: I812a591225bb7cd9c957cfaa2d3a27f10fd423ee --- M .gitignore M README M multiversion/MWMultiVersion.php M multiversion/getMWVersion M multiversion/refreshWikiversionsCDB 5 files changed, 33 insertions(+), 15 deletions(-) Approvals: Anomie: Looks good to me, approved jenkins-bot: Verified diff --git a/.gitignore b/.gitignore index e0e117b..b92e0da 100644 --- a/.gitignore +++ b/.gitignore @@ -12,6 +12,7 @@ wmf-config/ExtensionMessages-*.php php-* wikiversions.cdb +wikiversions-labs.cdb wmf-config/*-setup.php wmf-config/checkers.php lib @@ -35,4 +36,4 @@ # Operating system stuff ## Mac OS X .DS_Store -/nbproject/private/ \ No newline at end of file +/nbproject/private/ diff --git a/README b/README index e4a9c9e..e407cd6 100644 --- a/README +++ b/README @@ -10,6 +10,7 @@ "all-labs.dblist". wikiversions.dat, wikiversions.cdb +wikiversions-labs.dat, wikiversions-labs.cdb Let us associate a database with a specific copy of MediaWiki (generally a branch). The .cdb file is updated by editing wikiversions.dat first and then running multiversion/refreshWikiversionsCDB. To vary by realm, add a suffix diff --git a/multiversion/MWMultiVersion.php b/multiversion/MWMultiVersion.php index 158054a..13db7cb 100644 --- a/multiversion/MWMultiVersion.php +++ b/multiversion/MWMultiVersion.php @@ -257,23 +257,27 @@ } $this->versionLoaded = true; - $db = dba_open( MULTIVER_CDB_DIR_APACHE . '/wikiversions.cdb', 'r', 'cdb' ); + $cdbFilename = getRealmSpecificFilename( + MULTIVER_CDB_DIR_APACHE . '/wikiversions.cdb' + ); + + $db = dba_open( $cdbFilename, 'r', 'cdb' ); if ( $db ) { $version = dba_fetch( "ver:{$this->db}", $db ); if ( $version === false ) { $extraVersion = false; } else { if ( strpos( $version, 'php-' ) !== 0 ) { - self::error( "wikiversions.cdb version entry does not start with `php-` (got `$version`).\n" ); + self::error( "$cdbFilename version entry does not start with `php-` (got `$version`).\n" ); } $extraVersion = dba_fetch( "ext:{$this->db}", $db ); if ( $extraVersion === false ) { - self::error( "wikiversions.cdb has no extra version entry for `$db`.\n" ); + self::error( "$cdbFilename has no extra version entry for `$db`.\n" ); } } dba_close( $db ); } else { - self::error( "Unable to open wikiversions.cdb.\n" ); + self::error( "Unable to open $cdbFilename.\n" ); } $this->version = $version; @@ -285,8 +289,11 @@ * @return bool */ private function assertNotMissing() { + $cdbFilename = getRealmSpecificFilename( + MULTIVER_CDB_DIR_APACHE . '/wikiversions.cdb' + ); if ( $this->isMissing() ) { - self::error( "wikiversions.cdb has no version entry for `{$this->db}`.\n" ); + self::error( "$cdbFilename has no version entry for `{$this->db}`.\n" ); } } diff --git a/multiversion/getMWVersion b/multiversion/getMWVersion index b64aec9..ae1024d 100755 --- a/multiversion/getMWVersion +++ b/multiversion/getMWVersion @@ -3,6 +3,7 @@ error_reporting( 0 ); require_once( dirname( __FILE__ ) . '/defines.php' ); +require_once( dirname( __FILE__ ) . '/MWRealm.php' ); /** * This script prints the MW version associated with a specified wikidb. @@ -17,16 +18,19 @@ * @return string MW code version (e.g. "php-x.xx" or "php-trunk") */ function getWikiVersion( $dbName ) { - $db = dba_open( MULTIVER_CDB_DIR_APACHE . '/wikiversions.cdb', 'r', 'cdb' ); + $cdbFilename = getRealmSpecificFilename( + MULTIVER_CDB_DIR_APACHE . '/wikiversions.cdb' + ); + $db = dba_open( $cdbFilename, 'r', 'cdb' ); if ( $db ) { $version = dba_fetch( "ver:$dbName", $db ); dba_close( $db ); if ( $version !== false ) { return $version; // found version entry } - die( "wikiversions.cdb has no version entry for `$dbName`.\n" ); + die( "$cdbFilename has no version entry for `$dbName`.\n" ); } - die( "Unable to open wikiversions.cdb.\n" ); + die( "Unable to open $cdbFilename.\n" ); } echo getWikiVersion( $argv[1] ) . "\n"; diff --git a/multiversion/refreshWikiversionsCDB b/multiversion/refreshWikiversionsCDB index 51f2674..504ced3 100755 --- a/multiversion/refreshWikiversionsCDB +++ b/multiversion/refreshWikiversionsCDB @@ -14,8 +14,13 @@ */ function refreshWikiversionsCDB() { $srcPath = getRealmSpecificFilename( MULTIVER_CDB_DIR_HOME . '/wikiversions.dat' ); - $tmpDBPath = MULTIVER_CDB_DIR_HOME . '/wikiversions.cdb.tmp'; - $finalDBPath = MULTIVER_CDB_DIR_HOME . '/wikiversions.cdb'; + + $cdbFilename = getRealmSpecificFilename( + MULTIVER_CDB_DIR_HOME . '/wikiversions.cdb' + ); + + $tmpDBPath = $cdbFilename . '.tmp'; + $finalDBPath = $cdbFilename; // Get the array of sanitized wikiversion rows... $rows = MWWikiversions::readWikiVersionsFile( $srcPath ); @@ -43,7 +48,7 @@ @unlink( $tmpDBPath ); // clear any old temp file for sanity $db = dba_open( $tmpDBPath, "n", "cdb_make" ); if ( !$db ) { - die( "Unable to create wikiversions.cdb.tmp.\n" ); + die( "Unable to create {$tmpDBPath}.\n" ); } foreach ( $rows as $row ) { list( $dbName, $version, $extVersion, $comment ) = $row; @@ -57,16 +62,16 @@ # Sanity check the temp file... if ( !is_file( $tmpDBPath ) ) { - die( "Unable to create wikiversions.cdb.tmp.\n" ); + die( "Unable to create {$tmpDBPath}.\n" ); } # Move temp file to the final location only when finished... if ( !rename( $tmpDBPath, $finalDBPath ) ) { - die( "Unable to move wikiversions.cdb.tmp to wikiversions.cdb.\n" ); + die( "Unable to move {$tmpDBPath} to {$finalDBPath}.\n" ); } chmod( $finalDBPath, 0664 ); // rw-rw-r - print "wikiversions.cdb successfully built.\n"; + print "{$cdbFilename} successfully built.\n"; } refreshWikiversionsCDB(); -- To view, visit https://gerrit.wikimedia.org/r/47564 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I812a591225bb7cd9c957cfaa2d3a27f10fd423ee Gerrit-PatchSet: 4 Gerrit-Project: operations/mediawiki-config Gerrit-Branch: master Gerrit-Owner: Hashar <has...@free.fr> Gerrit-Reviewer: Anomie <bjor...@wikimedia.org> Gerrit-Reviewer: Demon <ch...@wikimedia.org> Gerrit-Reviewer: Hashar <has...@free.fr> Gerrit-Reviewer: Reedy <re...@wikimedia.org> Gerrit-Reviewer: jenkins-bot _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits