FIX Replace usage of Convert JSON methods with json_encode and json_decode

This commit is contained in:
Robbie Averill 2018-10-28 21:21:19 +00:00
parent 9abd721a56
commit ab739c7fb0
4 changed files with 9 additions and 9 deletions

View File

@ -734,7 +734,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
return $this
->getResponse()
->addHeader('Content-Type', 'application/json')
->setBody(Convert::raw2json($data));
->setBody(json_encode($data));
}
/**
@ -859,7 +859,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
return $this
->getResponse()
->addHeader('Content-Type', 'application/json')
->setBody(Convert::raw2json($statusUpdates));
->setBody(json_encode($statusUpdates));
}
public function CanOrganiseSitetree()
@ -927,7 +927,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
'filters' => $searchParams ?: new \stdClass // stdClass maps to empty json object '{}'
];
return Convert::raw2json($schema);
return json_encode($schema);
}
/**
@ -1161,7 +1161,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
$this->extend('updateSiteTreeHints', $def);
$json = Convert::raw2json($def);
$json = json_encode($def);
$cache->set($cacheKey, $json);
return $json;
@ -1573,7 +1573,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
return $this
->getResponse()
->addHeader('Content-Type', 'application/json; charset=utf-8')
->setBody(Convert::raw2json($disallowedChildren));
->setBody(json_encode($disallowedChildren));
}
/**

View File

@ -87,7 +87,7 @@ class SiteTreeURLSegmentField extends TextField
}
Controller::curr()->getResponse()->addHeader('Content-Type', 'application/json');
return Convert::raw2json(array('value' => $page->URLSegment));
return json_encode(array('value' => $page->URLSegment));
}
/**

View File

@ -2736,7 +2736,7 @@ class SiteTree extends DataObject implements PermissionProvider, i18nEntityProvi
$treeTitle = sprintf(
"<span class=\"jstree-pageicon page-icon class-%s\"></span><span class=\"item\" data-allowedchildren=\"%s\">%s</span>",
Convert::raw2htmlid(static::class),
Convert::raw2att(Convert::raw2json($children)),
Convert::raw2att(json_encode($children)),
Convert::raw2xml(str_replace(array("\n","\r"), "", $this->MenuTitle))
);
foreach ($flags as $class => $data) {

View File

@ -57,7 +57,7 @@ class CMSMainTest extends FunctionalTest
$this->assertNotNull($rawHints);
$rawHints = preg_replace('/^"(.*)"$/', '$1', Convert::xml2raw($rawHints));
$hints = Convert::json2array($rawHints);
$hints = json_decode($rawHints, true);
$this->assertArrayHasKey('Root', $hints);
$this->assertArrayHasKey('Page', $hints);
@ -137,7 +137,7 @@ class CMSMainTest extends FunctionalTest
$actions = CMSBatchActionHandler::config()->batch_actions;
if (isset($actions['publish'])) {
$response = $this->get('admin/pages/batchactions/publish?ajax=1&csvIDs=' . implode(',', array($page1->ID, $page2->ID)));
$responseData = Convert::json2array($response->getBody());
$responseData = json_decode($response->getBody(), true);
$this->assertArrayHasKey($page1->ID, $responseData['modified']);
$this->assertArrayHasKey($page2->ID, $responseData['modified']);
}