[MediaWiki-commits] [Gerrit] Added missing JsonFormat::parse() RELEASE NOTES, fixed docs - change (mediawiki/core)

2014-09-29 Thread Jforrester (Code Review)
Jforrester has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/163790

Change subject: Added missing JsonFormat::parse() RELEASE NOTES, fixed docs
..

Added missing JsonFormat::parse() RELEASE NOTES, fixed docs

Constant values were changed to be above 0xFF - this way
we can easily decide to allow depth-parsing-limit to be OR-able:

  FormatJson::parse( $value, 30 | FormatJson::FORCE_ASSOC )

Follows-up Ic0eb0a7 and I1c4f37a.

Change-Id: I9bfd67a5ca4ea1d399821549c7e63ffdecd56ad1
---
M RELEASE-NOTES-1.24
M includes/json/FormatJson.php
2 files changed, 11 insertions(+), 8 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/90/163790/1

diff --git a/RELEASE-NOTES-1.24 b/RELEASE-NOTES-1.24
index becc5a9..1f4fcfe 100644
--- a/RELEASE-NOTES-1.24
+++ b/RELEASE-NOTES-1.24
@@ -193,6 +193,7 @@
 * (bug 69418) A MultiConfig implementation was added that supports fallback
   to multiple Config instances.
 * Update CSSJanus to v1.1.0.
+* Added FormatJson::parse() returning status with result or localized error 
message
 
 === Bug fixes in 1.24 ===
 * (bug 50572) MediaWiki:Blockip should support gender
diff --git a/includes/json/FormatJson.php b/includes/json/FormatJson.php
index 2dbbc30..f3e5c76 100644
--- a/includes/json/FormatJson.php
+++ b/includes/json/FormatJson.php
@@ -61,14 +61,14 @@
 *
 * @since 1.24
 */
-   const FORCE_ASSOC = 0x1;
+   const FORCE_ASSOC = 0x100;
 
/**
 * If set, attempts to fix invalid json.
 *
 * @since 1.24
 */
-   const TRY_FIXING = 0x2;
+   const TRY_FIXING = 0x200;
 
/**
 * Regex that matches whitespace inside empty arrays and objects.
@@ -130,14 +130,16 @@
}
 
/**
-* Decodes a JSON string.
+* Decodes a JSON string. It is recommended to use FormatJson::parse(), 
which returns more comprehensive
+* result in case of an error, and has more parsing options.
 *
 * @param string $value The JSON string being decoded
 * @param bool $assoc When true, returned objects will be converted 
into associative arrays.
 *
 * @return mixed The value encoded in JSON in appropriate PHP type.
-* `null` is returned if the JSON cannot be decoded or if the encoded 
data is deeper than
-* the recursion limit.
+* `null` is returned if $value represented `null`, if $value could not 
be decoded,
+* or if the encoded data was deeper than the recursion limit.
+* Use FormatJson::parse() to distinguish between types of `null` and 
to get proper error code.
 */
public static function decode( $value, $assoc = false ) {
return json_decode( $value, $assoc );
@@ -145,11 +147,11 @@
 
/**
 * Decodes a JSON string.
+* Unlike FormatJson::decode(), if $value represents null value, it 
will be properly decoded as valid.
 *
 * @param string $value The JSON string being decoded
-* @param int $options A bit field that allows FORCE_ASSOC, TRY_FIXING, 
WRAP_RESULT
-* For backward compatibility, FORCE_ASSOC is set to 1 to match the 
legacy 'true'
-* @return Status If good, the value is available in $result-getValue()
+* @param int $options A bit field that allows FORCE_ASSOC, TRY_FIXING
+* @return Status If valid JSON, the value is available in 
$result-getValue()
 */
public static function parse( $value, $options = 0 ) {
$assoc = ( $options  self::FORCE_ASSOC ) !== 0;

-- 
To view, visit https://gerrit.wikimedia.org/r/163790
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I9bfd67a5ca4ea1d399821549c7e63ffdecd56ad1
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: REL1_24
Gerrit-Owner: Jforrester jforres...@wikimedia.org
Gerrit-Reviewer: Yurik yu...@wikimedia.org

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] Added missing JsonFormat::parse() RELEASE NOTES, fixed docs - change (mediawiki/core)

2014-09-29 Thread jenkins-bot (Code Review)
jenkins-bot has submitted this change and it was merged.

Change subject: Added missing JsonFormat::parse() RELEASE NOTES, fixed docs
..


Added missing JsonFormat::parse() RELEASE NOTES, fixed docs

Constant values were changed to be above 0xFF - this way
we can easily decide to allow depth-parsing-limit to be OR-able:

  FormatJson::parse( $value, 30 | FormatJson::FORCE_ASSOC )

Follows-up Ic0eb0a7 and I1c4f37a.

Change-Id: I9bfd67a5ca4ea1d399821549c7e63ffdecd56ad1
---
M RELEASE-NOTES-1.24
M includes/json/FormatJson.php
2 files changed, 11 insertions(+), 8 deletions(-)

Approvals:
  Jforrester: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/RELEASE-NOTES-1.24 b/RELEASE-NOTES-1.24
index becc5a9..1f4fcfe 100644
--- a/RELEASE-NOTES-1.24
+++ b/RELEASE-NOTES-1.24
@@ -193,6 +193,7 @@
 * (bug 69418) A MultiConfig implementation was added that supports fallback
   to multiple Config instances.
 * Update CSSJanus to v1.1.0.
+* Added FormatJson::parse() returning status with result or localized error 
message
 
 === Bug fixes in 1.24 ===
 * (bug 50572) MediaWiki:Blockip should support gender
diff --git a/includes/json/FormatJson.php b/includes/json/FormatJson.php
index 2dbbc30..f3e5c76 100644
--- a/includes/json/FormatJson.php
+++ b/includes/json/FormatJson.php
@@ -61,14 +61,14 @@
 *
 * @since 1.24
 */
-   const FORCE_ASSOC = 0x1;
+   const FORCE_ASSOC = 0x100;
 
/**
 * If set, attempts to fix invalid json.
 *
 * @since 1.24
 */
-   const TRY_FIXING = 0x2;
+   const TRY_FIXING = 0x200;
 
/**
 * Regex that matches whitespace inside empty arrays and objects.
@@ -130,14 +130,16 @@
}
 
/**
-* Decodes a JSON string.
+* Decodes a JSON string. It is recommended to use FormatJson::parse(), 
which returns more comprehensive
+* result in case of an error, and has more parsing options.
 *
 * @param string $value The JSON string being decoded
 * @param bool $assoc When true, returned objects will be converted 
into associative arrays.
 *
 * @return mixed The value encoded in JSON in appropriate PHP type.
-* `null` is returned if the JSON cannot be decoded or if the encoded 
data is deeper than
-* the recursion limit.
+* `null` is returned if $value represented `null`, if $value could not 
be decoded,
+* or if the encoded data was deeper than the recursion limit.
+* Use FormatJson::parse() to distinguish between types of `null` and 
to get proper error code.
 */
public static function decode( $value, $assoc = false ) {
return json_decode( $value, $assoc );
@@ -145,11 +147,11 @@
 
/**
 * Decodes a JSON string.
+* Unlike FormatJson::decode(), if $value represents null value, it 
will be properly decoded as valid.
 *
 * @param string $value The JSON string being decoded
-* @param int $options A bit field that allows FORCE_ASSOC, TRY_FIXING, 
WRAP_RESULT
-* For backward compatibility, FORCE_ASSOC is set to 1 to match the 
legacy 'true'
-* @return Status If good, the value is available in $result-getValue()
+* @param int $options A bit field that allows FORCE_ASSOC, TRY_FIXING
+* @return Status If valid JSON, the value is available in 
$result-getValue()
 */
public static function parse( $value, $options = 0 ) {
$assoc = ( $options  self::FORCE_ASSOC ) !== 0;

-- 
To view, visit https://gerrit.wikimedia.org/r/163335
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I9bfd67a5ca4ea1d399821549c7e63ffdecd56ad1
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Yurik yu...@wikimedia.org
Gerrit-Reviewer: Jforrester jforres...@wikimedia.org
Gerrit-Reviewer: Legoktm legoktm.wikipe...@gmail.com
Gerrit-Reviewer: Parent5446 tylerro...@gmail.com
Gerrit-Reviewer: jenkins-bot 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] Added missing JsonFormat::parse() RELEASE NOTES, fixed docs - change (mediawiki/core)

2014-09-29 Thread jenkins-bot (Code Review)
jenkins-bot has submitted this change and it was merged.

Change subject: Added missing JsonFormat::parse() RELEASE NOTES, fixed docs
..


Added missing JsonFormat::parse() RELEASE NOTES, fixed docs

Constant values were changed to be above 0xFF - this way
we can easily decide to allow depth-parsing-limit to be OR-able:

  FormatJson::parse( $value, 30 | FormatJson::FORCE_ASSOC )

Follows-up Ic0eb0a7 and I1c4f37a.

Change-Id: I9bfd67a5ca4ea1d399821549c7e63ffdecd56ad1
---
M RELEASE-NOTES-1.24
M includes/json/FormatJson.php
2 files changed, 11 insertions(+), 8 deletions(-)

Approvals:
  Jforrester: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/RELEASE-NOTES-1.24 b/RELEASE-NOTES-1.24
index becc5a9..1f4fcfe 100644
--- a/RELEASE-NOTES-1.24
+++ b/RELEASE-NOTES-1.24
@@ -193,6 +193,7 @@
 * (bug 69418) A MultiConfig implementation was added that supports fallback
   to multiple Config instances.
 * Update CSSJanus to v1.1.0.
+* Added FormatJson::parse() returning status with result or localized error 
message
 
 === Bug fixes in 1.24 ===
 * (bug 50572) MediaWiki:Blockip should support gender
diff --git a/includes/json/FormatJson.php b/includes/json/FormatJson.php
index 2dbbc30..f3e5c76 100644
--- a/includes/json/FormatJson.php
+++ b/includes/json/FormatJson.php
@@ -61,14 +61,14 @@
 *
 * @since 1.24
 */
-   const FORCE_ASSOC = 0x1;
+   const FORCE_ASSOC = 0x100;
 
/**
 * If set, attempts to fix invalid json.
 *
 * @since 1.24
 */
-   const TRY_FIXING = 0x2;
+   const TRY_FIXING = 0x200;
 
/**
 * Regex that matches whitespace inside empty arrays and objects.
@@ -130,14 +130,16 @@
}
 
/**
-* Decodes a JSON string.
+* Decodes a JSON string. It is recommended to use FormatJson::parse(), 
which returns more comprehensive
+* result in case of an error, and has more parsing options.
 *
 * @param string $value The JSON string being decoded
 * @param bool $assoc When true, returned objects will be converted 
into associative arrays.
 *
 * @return mixed The value encoded in JSON in appropriate PHP type.
-* `null` is returned if the JSON cannot be decoded or if the encoded 
data is deeper than
-* the recursion limit.
+* `null` is returned if $value represented `null`, if $value could not 
be decoded,
+* or if the encoded data was deeper than the recursion limit.
+* Use FormatJson::parse() to distinguish between types of `null` and 
to get proper error code.
 */
public static function decode( $value, $assoc = false ) {
return json_decode( $value, $assoc );
@@ -145,11 +147,11 @@
 
/**
 * Decodes a JSON string.
+* Unlike FormatJson::decode(), if $value represents null value, it 
will be properly decoded as valid.
 *
 * @param string $value The JSON string being decoded
-* @param int $options A bit field that allows FORCE_ASSOC, TRY_FIXING, 
WRAP_RESULT
-* For backward compatibility, FORCE_ASSOC is set to 1 to match the 
legacy 'true'
-* @return Status If good, the value is available in $result-getValue()
+* @param int $options A bit field that allows FORCE_ASSOC, TRY_FIXING
+* @return Status If valid JSON, the value is available in 
$result-getValue()
 */
public static function parse( $value, $options = 0 ) {
$assoc = ( $options  self::FORCE_ASSOC ) !== 0;

-- 
To view, visit https://gerrit.wikimedia.org/r/163790
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I9bfd67a5ca4ea1d399821549c7e63ffdecd56ad1
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: REL1_24
Gerrit-Owner: Jforrester jforres...@wikimedia.org
Gerrit-Reviewer: Jforrester jforres...@wikimedia.org
Gerrit-Reviewer: Yurik yu...@wikimedia.org
Gerrit-Reviewer: jenkins-bot 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] Added missing JsonFormat::parse() RELEASE NOTES, fixed docs - change (mediawiki/core)

2014-09-27 Thread Yurik (Code Review)
Yurik has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/163335

Change subject: Added missing JsonFormat::parse() RELEASE NOTES, fixed docs
..

Added missing JsonFormat::parse() RELEASE NOTES, fixed docs

Change-Id: I9bfd67a5ca4ea1d399821549c7e63ffdecd56ad1
---
M RELEASE-NOTES-1.24
M includes/json/FormatJson.php
2 files changed, 9 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/35/163335/1

diff --git a/RELEASE-NOTES-1.24 b/RELEASE-NOTES-1.24
index becc5a9..1f4fcfe 100644
--- a/RELEASE-NOTES-1.24
+++ b/RELEASE-NOTES-1.24
@@ -193,6 +193,7 @@
 * (bug 69418) A MultiConfig implementation was added that supports fallback
   to multiple Config instances.
 * Update CSSJanus to v1.1.0.
+* Added FormatJson::parse() returning status with result or localized error 
message
 
 === Bug fixes in 1.24 ===
 * (bug 50572) MediaWiki:Blockip should support gender
diff --git a/includes/json/FormatJson.php b/includes/json/FormatJson.php
index 5565644..3430d25 100644
--- a/includes/json/FormatJson.php
+++ b/includes/json/FormatJson.php
@@ -123,14 +123,16 @@
}
 
/**
-* Decodes a JSON string.
+* Decodes a JSON string. It is recommended to use FormatJson::parse(), 
which returns more comprehensive
+* result in case of an error.
 *
 * @param string $value The JSON string being decoded
 * @param bool $assoc When true, returned objects will be converted 
into associative arrays.
 *
 * @return mixed The value encoded in JSON in appropriate PHP type.
-* `null` is returned if the JSON cannot be decoded or if the encoded 
data is deeper than
-* the recursion limit.
+* `null` is returned if $value represented `null`, if $value could not 
be decoded,
+* or if the encoded data was deeper than the recursion limit.
+* Use FormatJson::parse() to distinguish between types of `null` and 
to get proper error code.
 */
public static function decode( $value, $assoc = false ) {
return json_decode( $value, $assoc );
@@ -138,11 +140,11 @@
 
/**
 * Decodes a JSON string.
+* Unlike FormatJson::decode(), if $value represents null value, it 
will be properly decoded as valid.
 *
 * @param string $value The JSON string being decoded
-* @param int $options A bit field that allows FORCE_ASSOC, TRY_FIXING, 
WRAP_RESULT
-* For backward compatibility, FORCE_ASSOC is set to 1 to match the 
legacy 'true'
-* @return Status If good, the value is available in $result-getValue()
+* @param int $options A bit field that allows FORCE_ASSOC
+* @return Status If valid JSON, the value is available in 
$result-getValue()
 */
public static function parse( $value, $options = 0 ) {
$assoc = ( $options  self::FORCE_ASSOC ) !== 0;

-- 
To view, visit https://gerrit.wikimedia.org/r/163335
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I9bfd67a5ca4ea1d399821549c7e63ffdecd56ad1
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Yurik yu...@wikimedia.org

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits