Thiemo Mättig (WMDE) has uploaded a new change for review.
https://gerrit.wikimedia.org/r/218307
Change subject: Use json_decode instead of FormatJson::decode
......................................................................
Use json_decode instead of FormatJson::decode
The wrapper does not do anything and never did, as far as I can tell.
We are *not* using it in about 30 places in our code base. Only very
few places used the FormatJson wrapper.
Change-Id: Ib850e33f631c169c65a1aafeb6e27f43cfc0300f
---
M client/maintenance/populateInterwiki.php
M repo/includes/api/ClaimModificationHelper.php
M repo/includes/api/CreateClaim.php
M repo/includes/api/FormatSnakValue.php
M repo/includes/api/ParseValue.php
M repo/includes/api/SetClaim.php
M repo/includes/api/SetReference.php
7 files changed, 10 insertions(+), 11 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase
refs/changes/07/218307/1
diff --git a/client/maintenance/populateInterwiki.php
b/client/maintenance/populateInterwiki.php
index df0a988..0d22f62 100644
--- a/client/maintenance/populateInterwiki.php
+++ b/client/maintenance/populateInterwiki.php
@@ -79,7 +79,7 @@
}
$json = Http::get( $url );
- $data = FormatJson::decode( $json, true );
+ $data = json_decode( $json, true );
if ( is_array( $data ) ) {
return $data['query']['interwikimap'];
diff --git a/repo/includes/api/ClaimModificationHelper.php
b/repo/includes/api/ClaimModificationHelper.php
index 548215d..2302216 100644
--- a/repo/includes/api/ClaimModificationHelper.php
+++ b/repo/includes/api/ClaimModificationHelper.php
@@ -4,7 +4,6 @@
use ApiBase;
use DataValues\IllegalValueException;
-use FormatJson;
use InvalidArgumentException;
use LogicException;
use OutOfBoundsException;
@@ -118,8 +117,10 @@
*/
public function getSnakInstance( $params, PropertyId $propertyId ) {
$valueData = null;
+
if ( isset( $params['value'] ) ) {
- $valueData = FormatJson::decode( $params['value'], true
);
+ $valueData = json_decode( $params['value'], true );
+
if ( $valueData === null ) {
$this->errorReporter->dieError( 'Could not
decode snak value', 'invalid-snak' );
}
diff --git a/repo/includes/api/CreateClaim.php
b/repo/includes/api/CreateClaim.php
index 54b9e77..19faf02 100644
--- a/repo/includes/api/CreateClaim.php
+++ b/repo/includes/api/CreateClaim.php
@@ -98,7 +98,7 @@
$this->dieError( 'A property ID needs to be provided
when creating a claim with a Snak', 'param-missing' );
}
- if ( isset( $params['value'] ) && \FormatJson::decode(
$params['value'], true ) == null ) {
+ if ( isset( $params['value'] ) && json_decode(
$params['value'], true ) === null ) {
$this->dieError( 'Could not decode snak value',
'invalid-snak' );
}
}
diff --git a/repo/includes/api/FormatSnakValue.php
b/repo/includes/api/FormatSnakValue.php
index 43c3012..a3cb6f8 100644
--- a/repo/includes/api/FormatSnakValue.php
+++ b/repo/includes/api/FormatSnakValue.php
@@ -112,7 +112,7 @@
* @return DataValue
*/
private function decodeDataValue( $json ) {
- $data = \FormatJson::decode( $json, true );
+ $data = json_decode( $json, true );
if ( !is_array( $data ) ) {
$this->dieError( 'Failed to decode datavalue',
'baddatavalue' );
@@ -137,7 +137,7 @@
$formatterOptions = new FormatterOptions();
$formatterOptions->setOption( ValueFormatter::OPT_LANG,
$this->getLanguage()->getCode() );
- $options = \FormatJson::decode( $optionsParam, true );
+ $options = json_decode( $optionsParam, true );
if ( is_array( $options ) ) {
foreach ( $options as $name => $value ) {
diff --git a/repo/includes/api/ParseValue.php b/repo/includes/api/ParseValue.php
index 591a46d..8c50525 100644
--- a/repo/includes/api/ParseValue.php
+++ b/repo/includes/api/ParseValue.php
@@ -130,7 +130,7 @@
$parserOptions->setOption( ValueParser::OPT_LANG,
$this->getLanguage()->getCode() );
if ( $optionsParam !== null && $optionsParam !== '' ) {
- $options = \FormatJson::decode( $optionsParam, true );
+ $options = json_decode( $optionsParam, true );
if ( !is_array( $options ) ) {
$this->dieError( 'Malformed options parameter',
'malformed-options' );
diff --git a/repo/includes/api/SetClaim.php b/repo/includes/api/SetClaim.php
index e1e93f8..c7f12a4 100644
--- a/repo/includes/api/SetClaim.php
+++ b/repo/includes/api/SetClaim.php
@@ -7,7 +7,6 @@
use DataValues\IllegalValueException;
use Diff\Comparer\ComparableComparer;
use Diff\Differ\OrderedListDiffer;
-use FormatJson;
use InvalidArgumentException;
use LogicException;
use OutOfBoundsException;
@@ -132,7 +131,7 @@
$unserializer = $serializerFactory->newUnserializerForClass(
'Wikibase\DataModel\Claim\Claim' );
try {
- $serializedClaim = FormatJson::decode(
$params['claim'], true );
+ $serializedClaim = json_decode( $params['claim'], true
);
if ( !is_array( $serializedClaim ) ) {
throw new IllegalValueException( 'Failed to get
claim from claim Serialization' );
}
diff --git a/repo/includes/api/SetReference.php
b/repo/includes/api/SetReference.php
index 20fe65e..c09be5c 100644
--- a/repo/includes/api/SetReference.php
+++ b/repo/includes/api/SetReference.php
@@ -4,7 +4,6 @@
use ApiBase;
use ApiMain;
-use FormatJson;
use InvalidArgumentException;
use OutOfBoundsException;
use Wikibase\ChangeOp\ChangeOpReference;
@@ -115,7 +114,7 @@
* @return array
*/
private function getArrayFromParam( $arrayParam ) {
- $rawArray = FormatJson::decode( $arrayParam, true );
+ $rawArray = json_decode( $arrayParam, true );
if ( !is_array( $rawArray ) || !count( $rawArray ) ) {
$this->dieError( 'No array or invalid JSON given',
'invalid-json' );
--
To view, visit https://gerrit.wikimedia.org/r/218307
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib850e33f631c169c65a1aafeb6e27f43cfc0300f
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Thiemo Mättig (WMDE) <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits