mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Revert "MINOR Use json_decode() instead of the Services_JSON class if the function exists." - it breaks assumptions around Convert::json2array() only converting the *first* level of an object structure into an array, which in turn fails CMSMainTest and LeftAndMainTest (as well as some UI functionality relying on it). In order to introduce this change we have to fix these issues in a backwards compatible manner.
This reverts commit 3a006b77ae
.
This commit is contained in:
parent
68a394427d
commit
05d19d9a82
@ -170,14 +170,10 @@ class Convert {
|
||||
* @return mixed JSON safe string
|
||||
*/
|
||||
static function json2obj($val) {
|
||||
if(function_exists('json_decode')) {
|
||||
return json_decode($val);
|
||||
} else {
|
||||
require_once(Director::baseFolder() . '/sapphire/thirdparty/json/JSON.php');
|
||||
$json = new Services_JSON();
|
||||
return $json->decode($val);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a JSON string into an array.
|
||||
@ -187,9 +183,6 @@ class Convert {
|
||||
* @return array|boolean
|
||||
*/
|
||||
static function json2array($val) {
|
||||
if(function_exists('json_decode')) {
|
||||
return json_decode($val, true);
|
||||
} else {
|
||||
$json = self::json2obj($val);
|
||||
if(!$json) return false;
|
||||
|
||||
@ -200,7 +193,6 @@ class Convert {
|
||||
|
||||
return $arr;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts an XML string to a PHP array
|
||||
|
Loading…
Reference in New Issue
Block a user