Wctaiwan has uploaded a new change for review.
https://gerrit.wikimedia.org/r/184117
Change subject: Use getData() instead of getJsonData()
......................................................................
Use getData() instead of getJsonData()
wfObjectToArray() is used for targets, since the code as written expects
targets to be associative arrays.
Change-Id: I22f5bff6fb6133b1a0e94b9df7801416e0c05375
---
M includes/content/MassMessageListContent.php
1 file changed, 16 insertions(+), 5 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MassMessage
refs/changes/17/184117/1
diff --git a/includes/content/MassMessageListContent.php
b/includes/content/MassMessageListContent.php
index da33c81..67b8aa0 100644
--- a/includes/content/MassMessageListContent.php
+++ b/includes/content/MassMessageListContent.php
@@ -134,11 +134,22 @@
if ( $this->decoded ) {
return;
}
- $data = $this->getJsonData();
- if ( is_array( $data ) ) {
- $this->description = array_key_exists( 'description',
$data ) ?
- $data['description'] : null;
- $this->targets = array_key_exists( 'targets', $data ) ?
$data['targets'] : null;
+ $jsonParse = $this->getData();
+ $data = $jsonParse->isGood() ? $jsonParse->getValue() : null;
+ if ( $data ) {
+ $this->description = isset( $data->description ) ?
$data->description : null;
+ if ( isset( $data->targets ) && is_array(
$data->targets ) ) {
+ $this->targets = array();
+ foreach ( $data->targets as $target ) {
+ if ( !is_object( $target ) ) { // There
is a malformed target.
+ $this->targets = null;
+ break;
+ }
+ $this->targets[] = wfObjectToArray(
$target ); // Convert target to associative array.
+ }
+ } else {
+ $this->targets = null;
+ }
}
$this->decoded = true;
}
--
To view, visit https://gerrit.wikimedia.org/r/184117
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I22f5bff6fb6133b1a0e94b9df7801416e0c05375
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MassMessage
Gerrit-Branch: master
Gerrit-Owner: Wctaiwan <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits