Daniel Kinzler has uploaded a new change for review.
https://gerrit.wikimedia.org/r/74176
Change subject: (bug 49338) Fix error handling in RollbackAction.
......................................................................
(bug 49338) Fix error handling in RollbackAction.
Some code assumes that Status::getErrorArray will return an array of
the form ( messagekey, param... ), but this was not the case when a
Message object was passed to the Status.
This change makes sure Status::getErrorArray will always return arrays
of the expected form.
Change-Id: I0deaa9888e9d86726a8e41ca606c571f56190c91
---
M includes/Message.php
M includes/Status.php
2 files changed, 12 insertions(+), 4 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/76/74176/1
diff --git a/includes/Message.php b/includes/Message.php
index de0b17e..74b4021 100644
--- a/includes/Message.php
+++ b/includes/Message.php
@@ -234,7 +234,13 @@
* @return string
*/
public function getKey() {
- return $this->key;
+ if ( is_array( $this->key ) ) {
+ // May happen if some kind of fallback is applied.
+ // For now, just use the first key. We really need a
better solution.
+ return $this->key[0];
+ } else {
+ return $this->key;
+ }
}
/**
diff --git a/includes/Status.php b/includes/Status.php
index f0253df..7ec1b0f 100644
--- a/includes/Status.php
+++ b/includes/Status.php
@@ -269,7 +269,8 @@
/**
* Get the list of errors (but not warnings)
*
- * @return Array
+ * @return array A list in which each entry is an array with a message
key as its first element.
+ * The remaining array elements are the message parameters.
*/
function getErrorsArray() {
return $this->getStatusArray( "error" );
@@ -278,7 +279,8 @@
/**
* Get the list of warnings (but not errors)
*
- * @return Array
+ * @return array A list in which each entry is an array with a message
key as its first element.
+ * The remaining array elements are the message parameters.
*/
function getWarningsArray() {
return $this->getStatusArray( "warning" );
@@ -295,7 +297,7 @@
foreach ( $this->errors as $error ) {
if ( $error['type'] === $type ) {
if ( $error['message'] instanceof Message ) {
- $result[] = $error['message'];
+ $result[] = array_merge( array(
$error['message']->getKey() ), $error['message']->getParams() );
} elseif ( $error['params'] ) {
$result[] = array_merge( array(
$error['message'] ), $error['params'] );
} else {
--
To view, visit https://gerrit.wikimedia.org/r/74176
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I0deaa9888e9d86726a8e41ca606c571f56190c91
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Daniel Kinzler <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits