jenkins-bot has submitted this change and it was merged.
Change subject: Edit translations for all jump wikis on central wiki
......................................................................
Edit translations for all jump wikis on central wiki
Fortunately jump wikis don't have questions or options, so we only have
to worry about mapping the election's ID (which we do in the same way we
do elsewhere, by title lookup).
Bug: T74576
Change-Id: Ifcf2ac4b0f9544a3968df52c2f653f15ee2f6426
---
M i18n/en.json
M i18n/qqq.json
M includes/pages/TranslatePage.php
3 files changed, 80 insertions(+), 0 deletions(-)
Approvals:
Tim Starling: Looks good to me, approved
jenkins-bot: Verified
diff --git a/i18n/en.json b/i18n/en.json
index 151bc6a..4ed2366 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -87,6 +87,8 @@
"securepoll-dump-no-urandom": "Cannot open /dev/urandom. \nTo maintain
voter privacy, encrypted election records are only publically available when
they can be shuffled with a secure random number stream.",
"securepoll-urandom-not-supported": "This server does not support
cryptographic random number generation.\nTo maintain voter privacy, encrypted
election records are only publically available when they can be shuffled with a
secure random number stream.",
"securepoll-translate-title": "Translate: $1",
+ "securepoll-translate-redirect": "Messages for this election must be
configured on $1",
+ "securepoll-translate-redirect-otherwiki": "the main wiki",
"securepoll-translate-label-comment": "Reason: ",
"securepoll-invalid-language": "Invalid language code \"$1\"",
"securepoll-header-trans-id": "ID",
diff --git a/i18n/qqq.json b/i18n/qqq.json
index 827a07c..a59599d 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -80,6 +80,8 @@
"securepoll-dump-no-urandom": "Do not translate
\"/dev/urandom\".\n\nServers running Microsoft Windows will present
[[MediaWiki:Securepoll-urandom-not-supported/en|Securepoll-urandom-not-supported]]
instead.",
"securepoll-urandom-not-supported": "As to the meaning of
''cryptographic random number'', see [[:wikipedia:Cryptographically secure
pseudorandom number generator]] for reference.\n\nThe /dev/urandom
cryptographic random number generation device is not supported on servers
running Microsoft Windows. On other platforms the
[[MediaWiki:Securepoll-dump-no-urandom/en|Securepoll-dump-no-urandom]] message
is generated if opening of the /dev/urandom device fails.",
"securepoll-translate-title": "Used as page title. Parameters:\n* $1 -
title of election\n{{Identical|Translate}}",
+ "securepoll-translate-redirect": "Text displayed when trying to edit
messages for a multi-wiki poll on the wrong wiki.\n\nParameters:\n* $1 - HTML
of a link to the correct wiki. Displayed text is either the wiki name or
{{msg-mw|securepoll-translate-redirect-otherwiki}}",
+ "securepoll-translate-redirect-otherwiki": "Used with
{{msg-mw|securepoll-translate-redirect}} when no name is available for the
target wiki.",
"securepoll-translate-label-comment": "Label for the \"edit summary\"
field on Special:SecurePoll/translate.\n{{Identical|Reason}}",
"securepoll-invalid-language": "Parameters:\n* $1 - language code",
"securepoll-header-trans-id": "{{optional}}\n{{Identical|ID}}",
diff --git a/includes/pages/TranslatePage.php b/includes/pages/TranslatePage.php
index e92fe7c..240147a 100644
--- a/includes/pages/TranslatePage.php
+++ b/includes/pages/TranslatePage.php
@@ -26,6 +26,31 @@
$wgOut->setPageTitle( wfMsg( 'securepoll-translate-title',
$this->election->getMessage( 'title' ) ) );
+ $jumpUrl = $this->election->getProperty( 'jump-url' );
+ if ( $jumpUrl ) {
+ $jumpId = $this->election->getProperty( 'jump-id' );
+ if ( !$jumpId ) {
+ throw new MWException( 'Configuration error: no
jump-id' );
+ }
+ $jumpUrl .= "/edit/$jumpId";
+ if ( count( $params ) > 1 ) {
+ $jumpUrl .= '/' . join( '/', array_slice(
$params, 1 ) );
+ }
+
+ $wiki = $this->election->getProperty( 'main-wiki' );
+ if ( $wiki ) {
+ $wiki = WikiMap::getWikiName( $wiki );
+ } else {
+ $wiki = $this->msg(
'securepoll-edit-redirect-otherwiki' )->text();
+ }
+
+ $wgOut->addWikiMsg( 'securepoll-edit-redirect',
+ Message::rawParam( Linker::makeExternalLink(
$jumpUrl, $wiki ) )
+ );
+
+ return;
+ }
+
$this->isAdmin = $this->election->isAdmin( $wgUser );
$primary = $this->election->getLanguage();
@@ -164,6 +189,7 @@
$entities = array_merge( array( $this->election ),
$this->election->getDescendants() );
$replaceBatch = array();
+ $jumpReplaceBatch = array();
foreach ( $entities as $entity ) {
foreach ( $entity->getMessageNames() as $messageName ) {
$controlName = 'trans_' . $entity->getId() .
'_' . $messageName;
@@ -175,10 +201,28 @@
'msg_key' => $messageName,
'msg_text' => $value
);
+
+ // Jump wikis don't have subentities
+ if ( $entity === $this->election ) {
+ $jumpReplaceBatch[] = array(
+ 'msg_entity' =>
$entity->getId(),
+ 'msg_lang' =>
$secondary,
+ 'msg_key' =>
$messageName,
+ 'msg_text' => $value
+ );
+ }
}
}
}
if ( $replaceBatch ) {
+ $wikis = $this->election->getProperty( 'wikis' );
+ if ( $wikis ) {
+ $wikis = explode( "\n", $wikis );
+ } else {
+ $wikis = array();
+ }
+
+ // First, the main wiki
$dbw = $this->context->getDB();
$dbw->replace(
'securepoll_msgs',
@@ -197,6 +241,38 @@
$wp = WikiPage::factory( $title );
$wp->doEditContent( $content,
$wgRequest->getText( 'comment' ) );
}
+
+ // Then each jump-wiki
+ foreach ( $wikis as $dbname ) {
+ if ( $dbname === wfWikiID() ) {
+ continue;
+ }
+
+ $lb = wfGetLB( $dbname );
+ $dbw = $lb->getConnection( DB_MASTER, array(),
$dbname );
+ try {
+ $id = $dbw->selectField(
'securepoll_elections', 'el_entity', array(
+ 'el_title' =>
$this->election->title
+ ) );
+ if ( $id ) {
+ foreach ( $jumpReplaceBatch as
&$row ) {
+ $row['msg_entity'] =
$id;
+ }
+ unset( $row );
+
+ $dbw->replace(
+ 'securepoll_msgs',
+ array( array(
'msg_entity', 'msg_lang', 'msg_key' ) ),
+ $jumpReplaceBatch,
+ __METHOD__
+ );
+ }
+ } catch ( Exception $ex ) {
+ // Log the exception, but don't abort
the updating of the rest of the jump-wikis
+ MWExceptionHandler::logException( $ex );
+ }
+ $lb->reuseConnection( $dbw );
+ }
}
$wgOut->redirect( $this->getTitle( $secondary )->getFullUrl() );
}
--
To view, visit https://gerrit.wikimedia.org/r/173052
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ifcf2ac4b0f9544a3968df52c2f653f15ee2f6426
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/SecurePoll
Gerrit-Branch: master
Gerrit-Owner: Anomie <[email protected]>
Gerrit-Reviewer: Anomie <[email protected]>
Gerrit-Reviewer: Reedy <[email protected]>
Gerrit-Reviewer: Siebrand <[email protected]>
Gerrit-Reviewer: Tim Starling <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits