jenkins-bot has submitted this change and it was merged.
Change subject: Improvements to Special:ManageMessageGroups
......................................................................
Improvements to Special:ManageMessageGroups
* Better way of not having too many changes per page
* When the number of changes per group exceeded the limit, only one
more change per group would be processed. All the remaining changes
would be ignored and cause data to be out of sync.
* Immediately show more changes instead of confusing confirmation page
* Add a small note above submit button indicating that there will be
more changes to review in case there are
Also includes a sanity check in FFS to avoid fatal errors if FFS types
get mixed.
Change-Id: I4f3efdfd60e468d1f74307f04213d2b934d17da5
---
M Translate.i18n.php
M ffs/FFS.php
M specials/SpecialManageGroups.php
3 files changed, 49 insertions(+), 17 deletions(-)
Approvals:
Siebrand: Looks good to me, approved
jenkins-bot: Verified
diff --git a/Translate.i18n.php b/Translate.i18n.php
index cb650bf..39ad313 100644
--- a/Translate.i18n.php
+++ b/Translate.i18n.php
@@ -280,7 +280,7 @@
'translate-smg-nochanges' => 'There are no changes to process.',
'translate-smg-submit' => 'Submit changes for processing',
'translate-smg-submitted' => 'Message definitions have been updated.
Changes are being processed in the background.',
- 'translate-smg-postponed' => 'Some changes could not be processed.
[[{{FULLPAGENAME}}|Try again]].',
+ 'translate-smg-more' => 'There will be more changes to process after
submitting these changes.',
'translate-smg-left' => 'Message content in wiki',
'translate-smg-right' => 'Incoming changes',
diff --git a/ffs/FFS.php b/ffs/FFS.php
index fa4bda8..c2a7c46 100644
--- a/ffs/FFS.php
+++ b/ffs/FFS.php
@@ -325,6 +325,10 @@
return;
}
+ if ( get_class( $this->group->getFFS() ) !== get_class( $this )
) {
+ return;
+ }
+
$sourceText = $this->tryReadFile( $filename );
// No need to do anything in SimpleFFS if it's false,
diff --git a/specials/SpecialManageGroups.php b/specials/SpecialManageGroups.php
index fbe6aea..93a5ac9 100644
--- a/specials/SpecialManageGroups.php
+++ b/specials/SpecialManageGroups.php
@@ -53,7 +53,7 @@
$req = $this->getRequest();
if ( !$req->wasPosted() ) {
- $this->showChanges( $allowed );
+ $this->showChanges( $allowed, $this->getLimit() );
return;
}
@@ -66,6 +66,22 @@
$this->processSubmit();
}
+ /**
+ * How many changes can be shown per page.
+ * @return int
+ */
+ protected function getLimit() {
+ $limits = array(
+ 1000, // Default max
+ ini_get( 'max_input_vars' ),
+ ini_get( 'suhosin.post.max_vars' ),
+ ini_get( 'suhosin.request.max_vars' )
+ );
+ // Ignore things not set
+ $limits = array_filter( $limits );
+ return min( $limits );
+ }
+
protected function getLegend() {
$text = $this->diff->addHeader(
'',
@@ -76,7 +92,7 @@
return Html::rawElement( 'div', array( 'class' =>
"mw-translate-smg-header" ), $text );
}
- protected function showChanges( $allowed ) {
+ protected function showChanges( $allowed, $limit ) {
global $wgContLang;
$diff = new DifferenceEngine( $this->getContext() );
@@ -93,7 +109,9 @@
$this->getLegend()
);
- $counter = 0;
+ // The above count as two
+ $limit = $limit - 2;
+
$changefile = TranslateUtils::cacheFile( self::CHANGEFILE );
$reader = CdbReader::open( $changefile );
$groups = unserialize( $reader->get( '#keys' ) );
@@ -127,14 +145,16 @@
foreach ( $changes as $code => $subchanges ) {
foreach ( $subchanges as $type => $messages ) {
foreach ( $messages as $params ) {
- $counter++;
- $change = $this->formatChange(
$group, $code, $type, $params );
+ $change = $this->formatChange(
$group, $code, $type, $params, $limit );
$out->addHtml( $change );
+
+ if ( $limit <= 0 ) {
+ // We need to restrict
the changes per page per form submission
+ // limitations as well
as performance.
+ $out->wrapWikiMsg(
"<div class=warning>\n$1\n</div>", 'translate-smg-more' );
+ break 4;
+ }
}
- }
- if ( $counter > 500 ) {
- // Avoid creating too heavy pages
- break 2;
}
}
}
@@ -156,12 +176,12 @@
* @param array $params
* @return string HTML
*/
- protected function formatChange( MessageGroup $group, $code, $type,
$params ) {
+ protected function formatChange( MessageGroup $group, $code, $type,
$params, &$limit ) {
$key = $params['key'];
$title = Title::makeTitleSafe( $group->getNamespace(),
"$key/$code" );
$id = self::changeId( $group->getId(), $code, $type, $key );
- if ( $title->exists() && $type === 'addition' ) {
+ if ( $title && $title->exists() && $type === 'addition' ) {
// The message has for some reason dropped out from
cache
// or perhaps it is being reused. In any case treat it
// as a change for display, so the admin can see if
@@ -170,7 +190,7 @@
// forever and will prevent rebuilding the cache, which
// leads to many other annoying problems.
$type = 'change';
- } elseif ( !$title->exists() && ( $type === 'deletion' || $type
=== 'change' ) ) {
+ } elseif ( $title && !$title->exists() && ( $type ===
'deletion' || $type === 'change' ) ) {
return '';
}
@@ -191,10 +211,12 @@
$label = $this->msg( 'translate-manage-action-ignore'
)->text();
$actions = Xml::checkLabel( $label, "i/$id", "i/$id" );
+ $limit--;
if ( $group->getSourceLanguage() === $code ) {
$label = $this->msg(
'translate-manage-action-fuzzy' )->text();
$actions .= ' ' . Xml::checkLabel( $label,
"f/$id", "f/$id" );
+ $limit--;
}
$this->diff->setText( $wiki, $params['content'] );
@@ -202,8 +224,14 @@
}
$hidden = Html::hidden( $id, 1 );
+ $limit--;
$text .= $hidden;
$classes = "mw-translate-smg-change smg-change-$type";
+
+ if ( $limit < 0 ) {
+ // Don't add if one of the fields might get dropped of
at submission
+ return '';
+ }
return Html::rawElement( 'div', array( 'class' => $classes ),
$text );
}
@@ -232,7 +260,7 @@
if ( $req->getVal( $id ) ===
null ) {
// We probably hit the
limit with number of post parameters.
$postponed[$groupId][$code][$type][$index] = $params;
- break 1;
+ continue;
}
if ( $type === 'deletion' ||
$req->getCheck( "i/$id" ) ) {
@@ -257,7 +285,6 @@
$reader->close();
rename( $changefile, $changefile . '-' . wfTimestamp() );
- $out->addWikiMsg( 'translate-smg-submitted' );
if ( count( $postponed ) ) {
$changefile = TranslateUtils::cacheFile(
self::CHANGEFILE );
@@ -268,8 +295,9 @@
$writer->set( $groupId, serialize( $changes ) );
}
$writer->close();
-
- $out->wrapWikiMsg( "<div class=warning>\n$1\n</div>",
'translate-smg-postponed' );
+ $this->showChanges( true, $this->getLimit() );
+ } else {
+ $out->addWikiMsg( 'translate-smg-submitted' );
}
}
--
To view, visit https://gerrit.wikimedia.org/r/90744
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I4f3efdfd60e468d1f74307f04213d2b934d17da5
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Translate
Gerrit-Branch: master
Gerrit-Owner: Nikerabbit <[email protected]>
Gerrit-Reviewer: Siebrand <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits