Ori.livneh has uploaded a new change for review.

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

Change subject: Provide a smooth migration path of dblist files to dblists/
......................................................................

Provide a smooth migration path of dblist files to dblists/

Facilitate a smooth transition of dblists file from the repository root to the
dblists/ subdirectory by making MWWikiversions::readDbListFile() try a fallback
file path when the specified $srcPath doesn't exist: for file paths with the
form '/foo/bar.dblist', try '/foo/dblists/bar.dblist', and vice versa.

Change-Id: I9d4cbd3d67f746a07c3f5e6e9f837fc1d8db952a
---
M multiversion/MWWikiversions.php
1 file changed, 14 insertions(+), 1 deletion(-)


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

diff --git a/multiversion/MWWikiversions.php b/multiversion/MWWikiversions.php
index 8a20900..d8212f1 100644
--- a/multiversion/MWWikiversions.php
+++ b/multiversion/MWWikiversions.php
@@ -73,9 +73,22 @@
         * @return Array
         */
        public static function readDbListFile( $srcPath ) {
+               $origPath = $srcPath;
                $lines = @file( $srcPath, FILE_IGNORE_NEW_LINES | 
FILE_SKIP_EMPTY_LINES );
+
+               // Provide a means of migrating dblist files to `dblists/`
+               // by checking both `/foo/bar.dblist` and 
`/foo/dblists/bar.dblist`.
                if ( !$lines ) {
-                       throw new Exception( "Unable to read $srcPath.\n" );
+                       $dirName = dirname( $srcPath );
+                       if ( basename( $dirName ) !== 'dblists' ) {
+                               $srcPath = $dirName . '/dblists/' . basename( 
$srcPath );
+                       } else {
+                               $srcPath = dirname( $dirName ) . '/' . 
basename( $srcPath );
+                       }
+                       $lines = @file( $srcPath, FILE_IGNORE_NEW_LINES | 
FILE_SKIP_EMPTY_LINES );
+               }
+               if ( !$lines ) {
+                       throw new Exception( "Unable to read $origPath.\n" );
                }
 
                $dbs = array();

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I9d4cbd3d67f746a07c3f5e6e9f837fc1d8db952a
Gerrit-PatchSet: 1
Gerrit-Project: operations/mediawiki-config
Gerrit-Branch: master
Gerrit-Owner: Ori.livneh <[email protected]>

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

Reply via email to