summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Evans <grknight@gentoo.org>2021-07-19 15:20:22 -0400
committerBrian Evans <grknight@gentoo.org>2021-07-19 15:20:22 -0400
commit9f092345e6bbecfde8c19e6d1490a6031a35f61f (patch)
tree2abb2398cd0df686e8608e15097ddc58b8995615 /MLEB/Translate/messagegroups
parentOAuth: Update for fixes and security (diff)
downloadextensions-9f092345e6bbecfde8c19e6d1490a6031a35f61f.tar.gz
extensions-9f092345e6bbecfde8c19e6d1490a6031a35f61f.tar.bz2
extensions-9f092345e6bbecfde8c19e6d1490a6031a35f61f.zip
Update to MLEB 2021.06
Signed-off-by: Brian Evans <grknight@gentoo.org>
Diffstat (limited to 'MLEB/Translate/messagegroups')
-rw-r--r--MLEB/Translate/messagegroups/AggregateMessageGroup.php36
-rw-r--r--MLEB/Translate/messagegroups/FileBasedMessageGroup.php12
-rw-r--r--MLEB/Translate/messagegroups/MessageGroup.php15
-rw-r--r--MLEB/Translate/messagegroups/MessageGroupBase.php134
-rw-r--r--MLEB/Translate/messagegroups/MessageGroupOld.php88
-rw-r--r--MLEB/Translate/messagegroups/RecentAdditionsMessageGroup.php12
-rw-r--r--MLEB/Translate/messagegroups/RecentMessageGroup.php12
-rw-r--r--MLEB/Translate/messagegroups/SandboxMessageGroup.php5
-rw-r--r--MLEB/Translate/messagegroups/WikiMessageGroup.php2
-rw-r--r--MLEB/Translate/messagegroups/WikiPageMessageGroup.php28
-rw-r--r--MLEB/Translate/messagegroups/WorkflowStatesMessageGroup.php10
-rw-r--r--MLEB/Translate/messagegroups/loaders/AggregateMessageGroupLoader.php12
-rw-r--r--MLEB/Translate/messagegroups/loaders/FileBasedMessageGroupLoader.php7
-rw-r--r--MLEB/Translate/messagegroups/loaders/TranslatablePageMessageGroupStore.php14
14 files changed, 120 insertions, 267 deletions
diff --git a/MLEB/Translate/messagegroups/AggregateMessageGroup.php b/MLEB/Translate/messagegroups/AggregateMessageGroup.php
index 52666b89..17d83a33 100644
--- a/MLEB/Translate/messagegroups/AggregateMessageGroup.php
+++ b/MLEB/Translate/messagegroups/AggregateMessageGroup.php
@@ -14,14 +14,10 @@
* @ingroup MessageGroup
*/
class AggregateMessageGroup extends MessageGroupBase {
- /**
- * @var MessageGroup[]
- */
+ /** @var MessageGroup[] */
private $groups;
- /**
- * @inheritDoc
- */
+ /** @inheritDoc */
public function exists() {
// Group exists if there are any subgroups.
$exists = (bool)$this->conf['GROUPS'];
@@ -29,15 +25,11 @@ class AggregateMessageGroup extends MessageGroupBase {
return $exists;
}
- /**
- * @inheritDoc
- */
+ /** @inheritDoc */
public function load( $code ) {
$messages = [];
- /**
- * @var $group MessageGroup
- */
+ /** @var $group MessageGroup */
foreach ( $this->getGroups() as $group ) {
$messages += $group->load( $code );
}
@@ -45,9 +37,7 @@ class AggregateMessageGroup extends MessageGroupBase {
return $messages;
}
- /**
- * @inheritDoc
- */
+ /** @inheritDoc */
public function getMangler() {
if ( $this->mangler === null ) {
$this->mangler = new StringMatcher();
@@ -116,9 +106,7 @@ class AggregateMessageGroup extends MessageGroupBase {
return $messages;
}
- /**
- * @inheritDoc
- */
+ /** @inheritDoc */
public function initCollection( $code ) {
$messages = $this->loadMessagesFromCache( $this->getGroups() );
$namespace = $this->getNamespace();
@@ -130,9 +118,7 @@ class AggregateMessageGroup extends MessageGroupBase {
return $collection;
}
- /**
- * @inheritDoc
- */
+ /** @inheritDoc */
public function getMessage( $key, $code ) {
/* Just hand over the message content retrieval to the primary message
* group directly. This used to iterate over the subgroups looking for
@@ -160,9 +146,7 @@ class AggregateMessageGroup extends MessageGroupBase {
}
}
- /**
- * @inheritDoc
- */
+ /** @inheritDoc */
public function getTags( $type = null ) {
$tags = [];
@@ -173,9 +157,7 @@ class AggregateMessageGroup extends MessageGroupBase {
return $tags;
}
- /**
- * @inheritDoc
- */
+ /** @inheritDoc */
public function getKeys() {
$keys = [];
foreach ( $this->getGroups() as $group ) {
diff --git a/MLEB/Translate/messagegroups/FileBasedMessageGroup.php b/MLEB/Translate/messagegroups/FileBasedMessageGroup.php
index 08b2f055..c348df4c 100644
--- a/MLEB/Translate/messagegroups/FileBasedMessageGroup.php
+++ b/MLEB/Translate/messagegroups/FileBasedMessageGroup.php
@@ -209,9 +209,7 @@ class FileBasedMessageGroup extends MessageGroupBase implements MetaYamlSchemaEx
return $schema;
}
- /**
- * @inheritDoc
- */
+ /** @inheritDoc */
public function getKeys() {
$cache = $this->getMessageGroupCache( $this->getSourceLanguage() );
if ( !$cache->exists() ) {
@@ -221,9 +219,7 @@ class FileBasedMessageGroup extends MessageGroupBase implements MetaYamlSchemaEx
}
}
- /**
- * @inheritDoc
- */
+ /** @inheritDoc */
public function initCollection( $code ) {
$namespace = $this->getNamespace();
$messages = [];
@@ -245,9 +241,7 @@ class FileBasedMessageGroup extends MessageGroupBase implements MetaYamlSchemaEx
return $collection;
}
- /**
- * @inheritDoc
- */
+ /** @inheritDoc */
public function getMessage( $key, $code ) {
$cache = $this->getMessageGroupCache( $code );
if ( $cache->exists() ) {
diff --git a/MLEB/Translate/messagegroups/MessageGroup.php b/MLEB/Translate/messagegroups/MessageGroup.php
index 9c7c898c..2786c11d 100644
--- a/MLEB/Translate/messagegroups/MessageGroup.php
+++ b/MLEB/Translate/messagegroups/MessageGroup.php
@@ -9,6 +9,8 @@
* @license GPL-2.0-or-later
*/
+use MediaWiki\Extension\Translate\Validation\ValidationRunner;
+
/**
* Interface for message groups.
*
@@ -89,7 +91,7 @@ interface MessageGroup {
/**
* Returns a message validator object or null.
- * @return MessageValidator|null
+ * @return ValidationRunner|null
*/
public function getValidator();
@@ -161,8 +163,8 @@ interface MessageGroup {
public function getMessageGroupStates();
/**
- * Get all the translatable languages for a group, considering the whitelisting
- * and blacklisting.
+ * Get all the translatable languages for a group, considering the inclusion
+ * and exclusion list.
* @return array|null The language codes as array keys.
*/
public function getTranslatableLanguages();
@@ -174,4 +176,11 @@ interface MessageGroup {
* @return array
*/
public function getTranslationAids();
+
+ /**
+ * Gets support URL defined for the group if any
+ *
+ * @return array|null
+ */
+ public function getSupportConfig(): ?array;
}
diff --git a/MLEB/Translate/messagegroups/MessageGroupBase.php b/MLEB/Translate/messagegroups/MessageGroupBase.php
index c067e692..dfd62502 100644
--- a/MLEB/Translate/messagegroups/MessageGroupBase.php
+++ b/MLEB/Translate/messagegroups/MessageGroupBase.php
@@ -8,6 +8,9 @@
* @license GPL-2.0-or-later
*/
+use MediaWiki\Extension\Translate\TranslatorInterface\Insertable\CombinedInsertablesSuggester;
+use MediaWiki\Extension\Translate\TranslatorInterface\Insertable\InsertableFactory;
+use MediaWiki\Extension\Translate\Validation\ValidationRunner;
use MediaWiki\MediaWikiServices;
/**
@@ -22,10 +25,7 @@ use MediaWiki\MediaWikiServices;
abstract class MessageGroupBase implements MessageGroup {
protected $conf;
protected $namespace;
-
- /**
- * @var StringMatcher
- */
+ /** @var StringMatcher */
protected $mangler;
protected function __construct() {
@@ -115,10 +115,19 @@ abstract class MessageGroupBase implements MessageGroup {
return null;
}
- $msgValidator = new MessageValidator( $this->getId() );
+ $msgValidator = new ValidationRunner( $this->getId() );
foreach ( $validatorConfigs as $config ) {
- $msgValidator->addValidator( $config );
+ try {
+ $msgValidator->addValidator( $config );
+ } catch ( Exception $e ) {
+ $id = $this->getId();
+ throw new InvalidArgumentException(
+ "Unable to construct validator for message group $id: " . $e->getMessage(),
+ 0,
+ $e
+ );
+ }
}
return $msgValidator;
@@ -138,9 +147,7 @@ abstract class MessageGroupBase implements MessageGroup {
throw new MWException( "Mangler class $class does not exist." );
}
- /**
- * @todo Branch handling, merge with upper branch keys
- */
+ /** @todo Branch handling, merge with upper branch keys */
$this->mangler = new $class();
$this->mangler->setConf( $this->conf['MANGLER'] );
}
@@ -154,35 +161,28 @@ abstract class MessageGroupBase implements MessageGroup {
* @return CombinedInsertablesSuggester
*/
public function getInsertablesSuggester() {
- $allClasses = [];
-
- $class = $this->getFromConf( 'INSERTABLES', 'class' );
- if ( $class !== null ) {
- $allClasses[] = $class;
- }
-
- $classes = $this->getFromConf( 'INSERTABLES', 'classes' );
- if ( $classes !== null ) {
- $allClasses = array_merge( $allClasses, $classes );
- }
-
- $allClasses = array_unique( $allClasses, SORT_REGULAR );
-
$suggesters = [];
+ $insertableConf = $this->getFromConf( 'INSERTABLES' ) ?? [];
- foreach ( $allClasses as $class ) {
- if ( !class_exists( $class ) ) {
- throw new InvalidArgumentException( "InsertablesSuggester class $class does not exist." );
+ foreach ( $insertableConf as $config ) {
+ if ( !isset( $config['class'] ) ) {
+ throw new InvalidArgumentException(
+ 'Insertable configuration for group: ' . $this->getId() .
+ ' does not provide a class.'
+ );
}
- $suggesters[] = new $class();
- }
+ if ( !is_string( $config['class'] ) ) {
+ throw new InvalidArgumentException(
+ 'Expected Insertable class to be string, got: ' . gettype( $config['class'] ) .
+ ' for group: ' . $this->getId()
+ );
+ }
- if ( $suggesters === [] ) {
- $suggesters = $this->getArrayInsertables();
+ $suggesters[] = InsertableFactory::make( $config['class'], $config['params'] ?? [] );
}
- // get validators marked as insertable
+ // Get validators marked as insertable
$messageValidator = $this->getValidator();
if ( $messageValidator ) {
$suggesters = array_merge( $suggesters, $messageValidator->getInsertableValidators() );
@@ -191,9 +191,7 @@ abstract class MessageGroupBase implements MessageGroup {
return new CombinedInsertablesSuggester( $suggesters );
}
- /**
- * @inheritDoc
- */
+ /** @inheritDoc */
public function getKeys() {
return array_keys( $this->getDefinitions() );
}
@@ -237,7 +235,7 @@ abstract class MessageGroupBase implements MessageGroup {
* Use mangler to find messages that match.
*/
foreach ( $messageKeys as $key ) {
- if ( $mangler->match( $key ) ) {
+ if ( $mangler->matches( $key ) ) {
$matches[] = $key;
}
}
@@ -290,9 +288,7 @@ abstract class MessageGroupBase implements MessageGroup {
return $code === $this->getSourceLanguage();
}
- /**
- * @deprecated Use getMessageGroupStates
- */
+ /** @deprecated Use getMessageGroupStates */
public function getWorkflowConfiguration() {
global $wgTranslateWorkflowStates;
if ( !$wgTranslateWorkflowStates ) {
@@ -318,11 +314,7 @@ abstract class MessageGroupBase implements MessageGroup {
return new MessageGroupStates( $conf );
}
- /**
- * Get all the translatable languages for a group, considering the whitelisting
- * and blacklisting.
- * @return array|null The language codes as array keys.
- */
+ /** @inheritDoc */
public function getTranslatableLanguages() {
global $wgTranslateBlacklist;
@@ -336,39 +328,39 @@ abstract class MessageGroupBase implements MessageGroup {
$lists = $groupConfiguration['LANGUAGES'];
if ( isset( $lists['blacklist'] ) ) {
- $blacklist = $lists['blacklist'];
- if ( $blacklist === '*' ) {
- // All languages blacklisted
+ $exclusionList = $lists['blacklist'];
+ if ( $exclusionList === '*' ) {
+ // All excluded languages
$codes = [];
- } elseif ( is_array( $blacklist ) ) {
- foreach ( $blacklist as $code ) {
+ } elseif ( is_array( $exclusionList ) ) {
+ foreach ( $exclusionList as $code ) {
unset( $codes[$code] );
}
}
} else {
- // Treat lack of explicit blacklist the same as blacklisting everything. This way,
- // when one defines only whitelist, it means that only those languages are allowed.
+ // Treat lack of explicit exclusion list the same as excluding everything. This way,
+ // when one defines only inclusions, it means that only those languages are allowed.
$codes = [];
}
// DWIM with $wgTranslateBlacklist, e.g. languages in that list should not unexpectedly
- // be enabled when a whitelist is used to whitelist any language.
+ // be enabled when an inclusion list is used to include any language.
$checks = [ $this->getId(), strtok( $this->getId(), '-' ), '*' ];
foreach ( $checks as $check ) {
if ( isset( $wgTranslateBlacklist[ $check ] ) ) {
- foreach ( array_keys( $wgTranslateBlacklist[ $check ] ) as $blacklistedCode ) {
- unset( $codes[ $blacklistedCode ] );
+ foreach ( array_keys( $wgTranslateBlacklist[ $check ] ) as $excludedCode ) {
+ unset( $codes[ $excludedCode ] );
}
}
}
if ( isset( $lists['whitelist'] ) ) {
- $whitelist = $lists['whitelist'];
- if ( $whitelist === '*' ) {
- // All languages whitelisted (except $wgTranslateBlacklist)
+ $inclusionList = $lists['whitelist'];
+ if ( $inclusionList === '*' ) {
+ // All languages included (except $wgTranslateBlacklist)
return null;
- } elseif ( is_array( $whitelist ) ) {
- foreach ( $whitelist as $code ) {
+ } elseif ( is_array( $inclusionList ) ) {
+ foreach ( $inclusionList as $code ) {
$codes[$code] = true;
}
}
@@ -387,29 +379,7 @@ abstract class MessageGroupBase implements MessageGroup {
return TranslationAid::getTypes();
}
- /**
- * Fetches insertables that have been added in the array configuration format.
- * TODO: MessageValidator - Move this code to getInsertablesSuggester once all
- * insertables in group config file have been migrated to the array structure.
- * @return array
- */
- private function getArrayInsertables() {
- $suggesters = [];
- $insertableConf = $this->getFromConf( 'INSERTABLES' );
-
- if ( $insertableConf === null ) {
- return $suggesters;
- }
-
- foreach ( $insertableConf as $config ) {
- if ( !isset( $config['class'] ) ) {
- throw new InvalidArgumentException( "Insertable configuration does not provide a class." );
- }
-
- $class = $config['class'];
- $suggesters[] = new $class( $config['params'] ?? [] );
- }
-
- return $suggesters;
+ public function getSupportConfig(): ?array {
+ return $this->getFromConf( 'BASIC', 'support' );
}
}
diff --git a/MLEB/Translate/messagegroups/MessageGroupOld.php b/MLEB/Translate/messagegroups/MessageGroupOld.php
index 0eec3d0a..f34d2594 100644
--- a/MLEB/Translate/messagegroups/MessageGroupOld.php
+++ b/MLEB/Translate/messagegroups/MessageGroupOld.php
@@ -31,9 +31,7 @@ abstract class MessageGroupOld implements MessageGroup {
return $this->label;
}
- /**
- * @param string $value
- */
+ /** @param string $value */
public function setLabel( $value ) {
$this->label = $value;
}
@@ -43,16 +41,12 @@ abstract class MessageGroupOld implements MessageGroup {
*/
protected $id = 'none';
- /**
- * @return string
- */
+ /** @return string */
public function getId() {
return $this->id;
}
- /**
- * @param string $value
- */
+ /** @param string $value */
public function setId( $value ) {
$this->id = $value;
}
@@ -81,46 +75,7 @@ abstract class MessageGroupOld implements MessageGroup {
}
/**
- * List of messages that are hidden by default, but can still be translated if
- * needed.
- */
- protected $optional = [];
-
- /**
- * @return array
- */
- public function getOptional() {
- return $this->optional;
- }
-
- /**
- * @param array $value
- */
- public function setOptional( $value ) {
- $this->optional = $value;
- }
-
- /**
- * List of messages that are always hidden and cannot be translated.
- */
- protected $ignored = [];
-
- /**
- * @return array
- */
- public function getIgnored() {
- return $this->ignored;
- }
-
- /**
- * @param array $value
- */
- public function setIgnored( $value ) {
- $this->ignored = $value;
- }
-
- /**
- * Holds descripton of this group. Description is a wiki text snippet that
+ * Holds description of this group. Description is a wiki text snippet that
* gives information about this group to translators.
*/
protected $description = null;
@@ -161,9 +116,7 @@ abstract class MessageGroupOld implements MessageGroup {
*/
protected $mangler = null;
- /**
- * @return StringMatcher
- */
+ /** @return StringMatcher */
public function getMangler() {
if ( !isset( $this->mangler ) ) {
$this->mangler = new StringMatcher();
@@ -206,9 +159,7 @@ abstract class MessageGroupOld implements MessageGroup {
return $this->meta ? [] : $this->getDefinitions();
}
- /**
- * @inheritDoc
- */
+ /** @inheritDoc */
public function getKeys() {
return array_keys( $this->getDefinitions() );
}
@@ -219,7 +170,7 @@ abstract class MessageGroupOld implements MessageGroup {
*
* @param string $key Message key
* @param string $code Language code
- * @return Mixed List of stored translation or \null.
+ * @return mixed List of stored translation or \null.
*/
public function getMessage( $key, $code ) {
if ( !isset( $this->messages[$code] ) ) {
@@ -320,16 +271,7 @@ abstract class MessageGroupOld implements MessageGroup {
}
public function getTags( $type = null ) {
- $tags = [
- 'optional' => $this->optional,
- 'ignored' => $this->ignored,
- ];
-
- if ( !$type ) {
- return $tags;
- }
-
- return $tags[$type] ?? [];
+ return [];
}
/**
@@ -355,9 +297,7 @@ abstract class MessageGroupOld implements MessageGroup {
return null;
}
- /**
- * @deprecated Use getMessageGroupStates
- */
+ /** @deprecated Use getMessageGroupStates */
public function getWorkflowConfiguration() {
global $wgTranslateWorkflowStates;
if ( !$wgTranslateWorkflowStates ) {
@@ -383,11 +323,7 @@ abstract class MessageGroupOld implements MessageGroup {
return new MessageGroupStates( $conf );
}
- /**
- * Get all the translatable languages for a group, considering the whitelisting
- * and blacklisting.
- * @return array|null The language codes as array keys.
- */
+ /** @inheritDoc */
public function getTranslatableLanguages() {
return null;
}
@@ -411,4 +347,8 @@ abstract class MessageGroupOld implements MessageGroup {
public function getTranslationAids() {
return TranslationAid::getTypes();
}
+
+ public function getSupportConfig(): ?array {
+ return null;
+ }
}
diff --git a/MLEB/Translate/messagegroups/RecentAdditionsMessageGroup.php b/MLEB/Translate/messagegroups/RecentAdditionsMessageGroup.php
index 688d75a0..70baedbd 100644
--- a/MLEB/Translate/messagegroups/RecentAdditionsMessageGroup.php
+++ b/MLEB/Translate/messagegroups/RecentAdditionsMessageGroup.php
@@ -8,15 +8,13 @@
* @license GPL-2.0-or-later
*/
-use MediaWiki\Extensions\Translate\SystemUsers\FuzzyBot;
+use MediaWiki\Extension\Translate\SystemUsers\FuzzyBot;
/**
* @since 2012-11-01
* @ingroup MessageGroup
*/
class RecentAdditionsMessageGroup extends RecentMessageGroup {
- protected $groupInfoCache = [];
-
public function getId() {
return '!additions';
}
@@ -43,15 +41,9 @@ class RecentAdditionsMessageGroup extends RecentMessageGroup {
'rc_namespace' => $wgTranslateMessageNamespaces,
'rc_type != ' . RC_LOG,
'rc_id > ' . $this->getRCCutoff(),
+ 'rc_actor' => FuzzyBot::getUser()->getActorId()
];
- if ( class_exists( ActorMigration::class ) ) {
- $conds[] = ActorMigration::newMigration()
- ->getWhere( $db, 'rc_user', FuzzyBot::getUser() )['conds'];
- } else {
- $conds['rc_user'] = FuzzyBot::getUser()->getId();
- }
-
return $conds;
}
diff --git a/MLEB/Translate/messagegroups/RecentMessageGroup.php b/MLEB/Translate/messagegroups/RecentMessageGroup.php
index 7a19c088..426d546b 100644
--- a/MLEB/Translate/messagegroups/RecentMessageGroup.php
+++ b/MLEB/Translate/messagegroups/RecentMessageGroup.php
@@ -19,7 +19,6 @@ class RecentMessageGroup extends WikiMessageGroup {
* @see MessageCollection::getPages()
*/
protected $namespace = false;
-
protected $language;
/**
@@ -93,14 +92,9 @@ class RecentMessageGroup extends WikiMessageGroup {
$db = wfGetDB( DB_REPLICA );
- if ( is_callable( [ RecentChange::class, 'getQueryInfo' ] ) ) {
- $rcQuery = RecentChange::getQueryInfo();
- $tables = $rcQuery['tables'];
- $joins = $rcQuery['joins'];
- } else {
- $tables = 'recentchanges';
- $joins = [];
- }
+ $rcQuery = RecentChange::getQueryInfo();
+ $tables = $rcQuery['tables'];
+ $joins = $rcQuery['joins'];
$fields = [ 'rc_namespace', 'rc_title' ];
$conds = $this->getQueryConditions();
diff --git a/MLEB/Translate/messagegroups/SandboxMessageGroup.php b/MLEB/Translate/messagegroups/SandboxMessageGroup.php
index 8866d38b..df33e67b 100644
--- a/MLEB/Translate/messagegroups/SandboxMessageGroup.php
+++ b/MLEB/Translate/messagegroups/SandboxMessageGroup.php
@@ -7,6 +7,8 @@
* @license GPL-2.0-or-later
*/
+use MediaWiki\Extension\Translate\TranslatorSandbox\TranslationStashStorage;
+
/**
* @since 2013.06
* @ingroup MessageGroup
@@ -17,7 +19,6 @@ class SandboxMessageGroup extends WikiMessageGroup {
* @see MessageCollection::getPages()
*/
protected $namespace = false;
-
protected $language;
/**
@@ -86,7 +87,7 @@ class SandboxMessageGroup extends WikiMessageGroup {
$messagesToProvide = $wgTranslateSandboxLimit * 2;
foreach ( $list as $index => &$translation ) {
- list( $ns, $page ) = explode( ':', $index, 2 );
+ [ $ns, $page ] = explode( ':', $index, 2 );
$title = Title::makeTitle( $ns, "$page/{$this->language}" );
$handle = new MessageHandle( $title );
diff --git a/MLEB/Translate/messagegroups/WikiMessageGroup.php b/MLEB/Translate/messagegroups/WikiMessageGroup.php
index 4e90db00..ea97a7ed 100644
--- a/MLEB/Translate/messagegroups/WikiMessageGroup.php
+++ b/MLEB/Translate/messagegroups/WikiMessageGroup.php
@@ -22,8 +22,6 @@ class WikiMessageGroup extends MessageGroupOld {
protected $source;
/**
- * Constructor.
- *
* @param string $id Unique id for this group.
* @param string $source Mediawiki message that contains list of message keys.
*/
diff --git a/MLEB/Translate/messagegroups/WikiPageMessageGroup.php b/MLEB/Translate/messagegroups/WikiPageMessageGroup.php
index 747ab104..e894fbb6 100644
--- a/MLEB/Translate/messagegroups/WikiPageMessageGroup.php
+++ b/MLEB/Translate/messagegroups/WikiPageMessageGroup.php
@@ -8,6 +8,9 @@
* @license GPL-2.0-or-later
*/
+use MediaWiki\Extension\Translate\PageTranslation\TranslatablePageInsertablesSuggester;
+use MediaWiki\Extension\Translate\PageTranslation\TranslationUnit;
+use MediaWiki\Extension\Translate\Validation\ValidationRunner;
use MediaWiki\MediaWikiServices;
use MediaWiki\Revision\SlotRecord;
@@ -16,14 +19,9 @@ use MediaWiki\Revision\SlotRecord;
* @ingroup PageTranslation MessageGroup
*/
class WikiPageMessageGroup extends MessageGroupOld implements IDBAccessObject {
- /**
- * @var Title|string
- */
+ /** @var Title|string */
protected $title;
-
- /**
- * @var int
- */
+ /** @var int */
protected $namespace = NS_TRANSLATIONS;
/**
@@ -39,9 +37,7 @@ class WikiPageMessageGroup extends MessageGroupOld implements IDBAccessObject {
return $this->getTitle()->getPageLanguage()->getCode();
}
- /**
- * @return Title
- */
+ /** @return Title */
public function getTitle() {
if ( is_string( $this->title ) ) {
$this->title = Title::newFromText( $this->title );
@@ -56,9 +52,7 @@ class WikiPageMessageGroup extends MessageGroupOld implements IDBAccessObject {
*/
protected $definitions;
- /**
- * @return string[]
- */
+ /** @return string[] */
public function getDefinitions() {
if ( is_array( $this->definitions ) ) {
return $this->definitions;
@@ -81,7 +75,7 @@ class WikiPageMessageGroup extends MessageGroupOld implements IDBAccessObject {
$defs = [];
foreach ( $res as $r ) {
- $section = new TPSection();
+ $section = new TranslationUnit();
$section->text = $r->trs_text;
$defs[$r->trs_key] = $section->getTextWithVariables();
}
@@ -171,11 +165,9 @@ class WikiPageMessageGroup extends MessageGroupOld implements IDBAccessObject {
return ContentHandler::getContentText( $rev->getContent( SlotRecord::MAIN ) );
}
- /**
- * @return MessageValidator
- */
+ /** @return ValidationRunner */
public function getValidator() {
- $validator = new MessageValidator( $this->getId() );
+ $validator = new ValidationRunner( $this->getId() );
$validator->setValidators( [
[ 'id' => 'MediaWikiPlural' ],
[ 'id' => 'BraceBalance' ]
diff --git a/MLEB/Translate/messagegroups/WorkflowStatesMessageGroup.php b/MLEB/Translate/messagegroups/WorkflowStatesMessageGroup.php
index f3b40460..cffdf62c 100644
--- a/MLEB/Translate/messagegroups/WorkflowStatesMessageGroup.php
+++ b/MLEB/Translate/messagegroups/WorkflowStatesMessageGroup.php
@@ -9,11 +9,9 @@
* @license GPL-2.0-or-later
*/
-use MediaWiki\Extensions\Translate\SystemUsers\FuzzyBot;
+use MediaWiki\Extension\Translate\SystemUsers\FuzzyBot;
-/**
- * @ingroup MessageGroup
- */
+/** @ingroup MessageGroup */
class WorkflowStatesMessageGroup extends WikiMessageGroup {
// id and source are not needed
public function __construct() {
@@ -41,9 +39,7 @@ class WorkflowStatesMessageGroup extends WikiMessageGroup {
$groups = MessageGroups::getAllGroups();
$keys = [];
- /**
- * @var $g MessageGroup
- */
+ /** @var $g MessageGroup */
foreach ( $groups as $g ) {
$states = $g->getMessageGroupStates()->getStates();
foreach ( array_keys( $states ) as $state ) {
diff --git a/MLEB/Translate/messagegroups/loaders/AggregateMessageGroupLoader.php b/MLEB/Translate/messagegroups/loaders/AggregateMessageGroupLoader.php
index 54fed244..226ed7d1 100644
--- a/MLEB/Translate/messagegroups/loaders/AggregateMessageGroupLoader.php
+++ b/MLEB/Translate/messagegroups/loaders/AggregateMessageGroupLoader.php
@@ -19,18 +19,12 @@ class AggregateMessageGroupLoader extends MessageGroupLoader
implements CachedMessageGroupLoader {
private const CACHE_KEY = 'aggregate';
- private const CACHE_VERSION = 1;
+ private const CACHE_VERSION = 2;
- /**
- * @var MessageGroupWANCache
- */
+ /** @var MessageGroupWANCache */
protected $cache;
-
- /**
- * @var IDatabase
- */
+ /** @var IDatabase */
protected $db;
-
/**
* List of groups
* @var array|null
diff --git a/MLEB/Translate/messagegroups/loaders/FileBasedMessageGroupLoader.php b/MLEB/Translate/messagegroups/loaders/FileBasedMessageGroupLoader.php
index 2134d47c..4225dd67 100644
--- a/MLEB/Translate/messagegroups/loaders/FileBasedMessageGroupLoader.php
+++ b/MLEB/Translate/messagegroups/loaders/FileBasedMessageGroupLoader.php
@@ -18,17 +18,14 @@ class FileBasedMessageGroupLoader extends MessageGroupLoader
implements CachedMessageGroupLoader {
private const CACHE_KEY = 'filebased';
- private const CACHE_VERSION = 1;
+ private const CACHE_VERSION = 2;
/**
* List of groups
* @var array|null
*/
protected $groups;
-
- /**
- * @var MessageGroupWANCache
- */
+ /** @var MessageGroupWANCache */
protected $cache;
public function __construct( MessageGroupWANCache $cache ) {
diff --git a/MLEB/Translate/messagegroups/loaders/TranslatablePageMessageGroupStore.php b/MLEB/Translate/messagegroups/loaders/TranslatablePageMessageGroupStore.php
index 287d9d80..7117a22e 100644
--- a/MLEB/Translate/messagegroups/loaders/TranslatablePageMessageGroupStore.php
+++ b/MLEB/Translate/messagegroups/loaders/TranslatablePageMessageGroupStore.php
@@ -19,18 +19,12 @@ class TranslatablePageMessageGroupStore extends MessageGroupLoader
{
private const CACHE_KEY = 'wikipage';
- private const CACHE_VERSION = 1;
+ private const CACHE_VERSION = 2;
- /**
- * @var Wikimedia\Rdbms\IDatabase
- */
+ /** @var Wikimedia\Rdbms\IDatabase */
protected $db;
-
- /**
- * @var MessageGroupWANCache
- */
+ /** @var MessageGroupWANCache */
protected $cache;
-
/**
* List of groups
* @var array|null
@@ -154,7 +148,7 @@ class TranslatablePageMessageGroupStore extends MessageGroupLoader
$tables = [ 'page', 'revtag' ];
$vars = [ 'page_id', 'page_namespace', 'page_title' ];
$conds = [ 'page_id=rt_page', 'rt_type' => RevTag::getType( 'tp:mark' ) ];
- $options = [ 'GROUP BY' => 'rt_page' ];
+ $options = [ 'GROUP BY' => 'rt_page,page_id,page_namespace,page_title' ];
$res = $this->db->select( $tables, $vars, $conds, __METHOD__, $options );
foreach ( $res as $r ) {