Nikerabbit has uploaded a new change for review.

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

Change subject: Restore compatibility with MediaWiki 1.24 and older
......................................................................

Restore compatibility with MediaWiki 1.24 and older

Moved BC code in one place so that it can be removed easily
without touching other code.

Change-Id: I5f81c9be31caf62e51ea2c67f4bcc4879dd19ba2
---
M Babel.php
M BabelLanguageCodes.class.php
M txt2cdb.php
3 files changed, 14 insertions(+), 13 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Babel 
refs/changes/26/205626/1

diff --git a/Babel.php b/Babel.php
index 8095fb4..38d1298 100644
--- a/Babel.php
+++ b/Babel.php
@@ -81,3 +81,10 @@
 MediaWiki:Babel-portal
     The name format of the portal link for each language.
 */
+
+// BC MW <= 1.24
+if ( !class_exists( 'Cdb\Exception' ) && class_exists( 'CdbException' ) ) {
+       class_alias( 'CdbException', 'Cdb\Exception' );
+       class_alias( 'CdbReader', 'Cdb\Reader' );
+       class_alias( 'CdbWriter', 'Cdb\Writer' );
+}
diff --git a/BabelLanguageCodes.class.php b/BabelLanguageCodes.class.php
index 8c57c6b..2092076 100644
--- a/BabelLanguageCodes.class.php
+++ b/BabelLanguageCodes.class.php
@@ -7,9 +7,6 @@
  * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 
2.0 or later
  */
 
-use Cdb\Exception as CdbException;
-use Cdb\Reader as CdbReader;
-
 /**
  * Handle language code and name processing for the Babel extension, it can 
also
  * be used by other extension which need such functionality.
@@ -33,9 +30,9 @@
 
                $codes = false;
                try {
-                       $codesCdb = CdbReader::open( $wgBabelLanguageCodesCdb );
+                       $codesCdb = Cdb\Reader::open( $wgBabelLanguageCodesCdb 
);
                        $codes = $codesCdb->get( $code );
-               } catch ( CdbException $e ) {
+               } catch ( Cdb\Exception $e ) {
                        wfDebug( __METHOD__ . ": CdbException caught, error 
message was "
                                . $e->getMessage() );
                }
@@ -70,9 +67,9 @@
 
                $codes = false;
                try {
-                       $namesCdb = CdbReader::open( $wgBabelLanguageNamesCdb );
+                       $namesCdb = Cdb\Reader::open( $wgBabelLanguageNamesCdb 
);
                        $codes = $namesCdb->get( $code );
-               } catch ( CdbException $e ) {
+               } catch ( Cdb\Exception $e ) {
                        wfDebug( __METHOD__ . ": CdbException caught, error 
message was "
                                . $e->getMessage() );
                }
diff --git a/txt2cdb.php b/txt2cdb.php
index 3c346b7..d34ff23 100644
--- a/txt2cdb.php
+++ b/txt2cdb.php
@@ -11,9 +11,6 @@
        include "$dir/../../CorePath.php"; // Allow override
 }
 
-use Cdb\Exception as CdbException;
-use Cdb\Writer as CdbWriter;
-
 require_once "$IP/maintenance/commandLine.inc";
 
 $names = "$dir/names.cdb";
@@ -21,8 +18,8 @@
 $fr = fopen( "$dir/codes.txt", 'r' );
 
 try {
-       $names = CdbWriter::open( $names );
-       $codes = CdbWriter::open( $codes );
+       $names = Cdb\Writer::open( $names );
+       $codes = Cdb\Writer::open( $codes );
 
        while ( $line = fgets( $fr ) ) {
                // Format is code1 code2 "language name"
@@ -43,7 +40,7 @@
                        $names->set( $iso3, $name );
                }
        }
-} catch ( CdbException $e ) {
+} catch ( Cdb\Exception $e ) {
        throw new Exception( $e->getMessage() );
 }
 

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I5f81c9be31caf62e51ea2c67f4bcc4879dd19ba2
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Babel
Gerrit-Branch: master
Gerrit-Owner: Nikerabbit <[email protected]>

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

Reply via email to