jenkins-bot has submitted this change and it was merged.

Change subject: Get rid of SingleFileBasedMessageGroup
......................................................................


Get rid of SingleFileBasedMessageGroup

As the current MediaWikiExtensionMessageGroup shows, it is not
property of a messageg group: we have both json and php files
supported at the same time.

Change-Id: I692d364c53bfd719025222755be1f94cbadeb300
---
M _autoload.php
M ffs/FFS.php
M ffs/PythonSingleFFS.php
M messagegroups/MediaWikiExtensionMessageGroup.php
D messagegroups/SingleFileBasedMessageGroup.php
M utils/MessageGroupCache.php
6 files changed, 16 insertions(+), 38 deletions(-)

Approvals:
  Siebrand: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/_autoload.php b/_autoload.php
index 1a26323..abdb778 100644
--- a/_autoload.php
+++ b/_autoload.php
@@ -253,8 +253,6 @@
 $wgAutoloadClasses['RecentAdditionsMessageGroup'] =
        "$dir/messagegroups/RecentAdditionsMessageGroup.php";
 $wgAutoloadClasses['SandboxMessageGroup'] = 
"$dir/messagegroups/SandboxMessageGroup.php";
-$wgAutoloadClasses['SingleFileBasedMessageGroup'] =
-       "$dir/messagegroups/SingleFileBasedMessageGroup.php";
 $wgAutoloadClasses['WikiMessageGroup'] = 
"$dir/messagegroups/WikiMessageGroup.php";
 $wgAutoloadClasses['WikiPageMessageGroup'] = 
"$dir/messagegroups/WikiPageMessageGroup.php";
 $wgAutoloadClasses['WorkflowStatesMessageGroup'] =
diff --git a/ffs/FFS.php b/ffs/FFS.php
index f439221..855ecc3 100644
--- a/ffs/FFS.php
+++ b/ffs/FFS.php
@@ -312,15 +312,15 @@
        }
 
        /**
+        * This tries to pick up external authors in the source files so that 
they
+        * are not lost if those authors are not among those who have 
translated in
+        * the wiki.
+        *
         * @todo Get rid of this
         * @param string $filename
         * @param MessageCollection $collection
         */
        protected function tryReadSource( $filename, MessageCollection 
$collection ) {
-               if ( $this->group instanceof SingleFileBasedMessageGroup ) {
-                       return;
-               }
-
                if ( get_class( $this->group->getFFS() ) !== get_class( $this ) 
) {
                        return;
                }
diff --git a/ffs/PythonSingleFFS.php b/ffs/PythonSingleFFS.php
index 7e9f2f8..8df21c0 100644
--- a/ffs/PythonSingleFFS.php
+++ b/ffs/PythonSingleFFS.php
@@ -221,4 +221,9 @@
 
                return $m[1];
        }
+
+       // Handled in writeReal
+       protected function tryReadSource( $filename, MessageCollection 
$collection ) {
+               return;
+       }
 }
diff --git a/messagegroups/MediaWikiExtensionMessageGroup.php 
b/messagegroups/MediaWikiExtensionMessageGroup.php
index 7a1bac6..e44d1d5 100644
--- a/messagegroups/MediaWikiExtensionMessageGroup.php
+++ b/messagegroups/MediaWikiExtensionMessageGroup.php
@@ -4,7 +4,6 @@
  *
  * @file
  * @author Niklas Laxström
- * @copyright Copyright © 2012-2013, Niklas Laxström
  * @license GPL-2.0+
  */
 
@@ -12,7 +11,7 @@
  * Message group for %MediaWiki extensions.
  * @ingroup MessageGroup
  */
-class MediaWikiExtensionMessageGroup extends SingleFileBasedMessageGroup {
+class MediaWikiExtensionMessageGroup extends FileBasedMessageGroup {
        /**
         * MediaWiki extensions all should have key in their i18n files
         * describing them. This override method implements the logic
diff --git a/messagegroups/SingleFileBasedMessageGroup.php 
b/messagegroups/SingleFileBasedMessageGroup.php
deleted file mode 100644
index f94fdd4..0000000
--- a/messagegroups/SingleFileBasedMessageGroup.php
+++ /dev/null
@@ -1,27 +0,0 @@
-<?php
-/**
- * This file a contains a message group implementation.
- *
- * @file
- * @author Niklas Laxström
- * @copyright Copyright © 2012-2013, Niklas Laxström
- * @license GPL-2.0+
- */
-
-/**
- * SingleFileBasedMessageGroup is a special case of FileBasedMessageGroup.
- * It should be used for all file based message groups that store all
- * language translations in single file.
- *
- * It triggers special handling when importing external changes, since we
- * actually need to parse the file to look what languages are present instead
- * of just checking whether files with specific names exist.
- *
- * The message group should go together with FFS implementation that handles
- * multiple languages in one file efficiently. See MediaWikiExtensionFFS for
- * high quality example implementation.
- *
- * @ingroup MessageGroup
- */
-class SingleFileBasedMessageGroup extends FileBasedMessageGroup {
-}
diff --git a/utils/MessageGroupCache.php b/utils/MessageGroupCache.php
index d31c66a..c29749b 100644
--- a/utils/MessageGroupCache.php
+++ b/utils/MessageGroupCache.php
@@ -98,7 +98,7 @@
                $this->close(); // Close the reader instance just to be sure
 
                $messages = $this->group->load( $this->code );
-               if ( !count( $messages ) && !( $this->group instanceof 
SingleFileBasedMessageGroup ) ) {
+               if ( $messages === array() ) {
                        if ( $this->exists() ) {
                                // Delete stale cache files
                                unlink( $this->getCacheFileName() );
@@ -137,14 +137,17 @@
                $group = $this->group;
                $groupId = $group->getId();
 
+               $pattern = $group->getSourceFilePath( '*' );
                $filename = $group->getSourceFilePath( $this->code );
 
-               if ( $group instanceof SingleFileBasedMessageGroup ) {
+               // If the file pattern is not dependent on the language, we 
will assume
+               // that all translations are stored in one file. This means we 
need to
+               // actually parse the file to know if a language is present.
+               if ( strpos( $pattern, '*' ) === false ) {
                        $source = $group->getFFS()->read( $this->code ) !== 
false;
                } else {
                        static $globCache = null;
                        if ( !isset( $globCache[$groupId] ) ) {
-                               $pattern = $group->getSourceFilePath( '*' );
                                $globCache[$groupId] = array_flip( glob( 
$pattern, GLOB_NOESCAPE ) );
                                // Definition file might not match the above 
pattern
                                $globCache[$groupId][$group->getSourceFilePath( 
'en' )] = true;

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I692d364c53bfd719025222755be1f94cbadeb300
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/Translate
Gerrit-Branch: master
Gerrit-Owner: Nikerabbit <niklas.laxst...@gmail.com>
Gerrit-Reviewer: Siebrand <siebr...@kitano.nl>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to