Skip to content

Commit d82f276

Browse files
committed
Remove options for JSON view.
json_encode() does not support options in 5.2. Because 2.6.x is 5.2 compatible we have to remove these options. People needing these options should upgrade to 2.7.x Refs #7083
1 parent 727b73e commit d82f276

File tree

2 files changed

+1
-38
lines changed

2 files changed

+1
-38
lines changed

lib/Cake/Test/Case/View/JsonViewTest.php

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -194,31 +194,6 @@ public function testRenderWithoutView($data, $serialize, $expected) {
194194
$this->assertSame($expected, $output);
195195
}
196196

197-
/**
198-
* Test render with _jsonOptions setting.
199-
*
200-
* @return void
201-
*/
202-
public function testRenderWithoutViewJsonOptions() {
203-
$this->skipIf(!version_compare(PHP_VERSION, '5.3.0', '>='), 'Needs PHP5.3+ for these constants to be tested');
204-
205-
$Request = new CakeRequest();
206-
$Response = new CakeResponse();
207-
$Controller = new Controller($Request, $Response);
208-
209-
// Test render with encode <, >, ', &, and " for RFC4627-compliant to be serialized.
210-
$data = array('rfc4627_escape' => '<tag> \'quote\' "double-quote" &');
211-
$serialize = 'rfc4627_escape';
212-
$expected = json_encode('<tag> \'quote\' "double-quote" &', JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP | JSON_HEX_QUOT);
213-
214-
$Controller->set($data);
215-
$Controller->set('_serialize', $serialize);
216-
$Controller->set('_jsonOptions', JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP | JSON_HEX_QUOT);
217-
$View = new JsonView($Controller);
218-
$output = $View->render(false);
219-
220-
$this->assertSame($expected, $output);
221-
}
222197
/**
223198
* Test that rendering with _serialize does not load helpers.
224199
*

lib/Cake/View/JsonView.php

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -149,19 +149,7 @@ protected function _serialize($serialize) {
149149
$data = isset($this->viewVars[$serialize]) ? $this->viewVars[$serialize] : null;
150150
}
151151

152-
$jsonOptions = 0;
153-
if (isset($this->viewVars['_jsonOptions'])) {
154-
if ($this->viewVars['_jsonOptions'] === false) {
155-
$jsonOptions = 0;
156-
} else {
157-
$jsonOptions = $this->viewVars['_jsonOptions'];
158-
}
159-
}
160-
if (version_compare(PHP_VERSION, '5.4.0', '>=') && Configure::read('debug')) {
161-
$jsonOptions = $jsonOptions | JSON_PRETTY_PRINT;
162-
}
163-
164-
$json = json_encode($data, $jsonOptions);
152+
$json = json_encode($data);
165153

166154
if (function_exists('json_last_error') && json_last_error() !== JSON_ERROR_NONE) {
167155
throw new CakeException(json_last_error_msg());

0 commit comments

Comments
 (0)