Skip to content

Commit

Permalink
Resurrect changes from #8131
Browse files Browse the repository at this point in the history
These changes were lost when we moved to the 3.next branch. This revives
those changes and solves #8259
  • Loading branch information
markstory committed Mar 2, 2016
1 parent f84ab99 commit 2224d73
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 6 deletions.
1 change: 0 additions & 1 deletion src/Error/ExceptionRenderer.php
Expand Up @@ -183,7 +183,6 @@ public function render()
'format' => 'array',
'args' => false
]);
$viewVars['_serialize'][] = 'trace';
}
$this->controller->set($viewVars);

Expand Down
2 changes: 1 addition & 1 deletion src/Mailer/Email.php
Expand Up @@ -1012,7 +1012,7 @@ protected function _constructTransport($name)
$className = App::className($config['className'], 'Network/Email', 'Transport');
trigger_error(
'Transports in "Network/Email" are deprecated, use "Mailer/Transport" instead.',
E_USER_WARNING
E_USER_DEPRECATED
);
}

Expand Down
4 changes: 2 additions & 2 deletions src/ORM/Table.php
Expand Up @@ -1030,7 +1030,7 @@ public function findList(Query $query, array $options)
if (isset($options['idField'])) {
$options['keyField'] = $options['idField'];
unset($options['idField']);
trigger_error('Option "idField" is deprecated, use "keyField" instead.', E_USER_WARNING);
trigger_error('Option "idField" is deprecated, use "keyField" instead.', E_USER_DEPRECATED);
}

if (!$query->clause('select') &&
Expand Down Expand Up @@ -1096,7 +1096,7 @@ public function findThreaded(Query $query, array $options)
if (isset($options['idField'])) {
$options['keyField'] = $options['idField'];
unset($options['idField']);
trigger_error('Option "idField" is deprecated, use "keyField" instead.', E_USER_WARNING);
trigger_error('Option "idField" is deprecated, use "keyField" instead.', E_USER_DEPRECATED);
}

$options = $this->_setFieldMatchers($options, ['keyField', 'parentField']);
Expand Down
2 changes: 1 addition & 1 deletion src/View/JsonView.php
Expand Up @@ -129,7 +129,7 @@ public function render($view = null, $layout = null)
*
* @param array|string|bool $serialize The name(s) of the view variable(s)
* that need(s) to be serialized. If true all available view variables.
* @return string The serialized data
* @return string|false The serialized data, or boolean false if not serializable.
*/
protected function _serialize($serialize)
{
Expand Down
7 changes: 6 additions & 1 deletion src/View/SerializedView.php
Expand Up @@ -17,6 +17,7 @@
use Cake\Event\EventManager;
use Cake\Network\Request;
use Cake\Network\Response;
use RuntimeException;

/**
* Parent class for view classes generating serialized outputs like JsonView and XmlView.
Expand Down Expand Up @@ -85,7 +86,11 @@ public function render($view = null, $layout = null)
}

if ($serialize !== false) {
return $this->_serialize($serialize);
$result = $this->_serialize($serialize);
if ($result === false) {
throw new RuntimeException('Serialization of View data failed.');
}
return (string)$result;
}
if ($view !== false && $this->_getViewFileName($view)) {
return parent::render($view, false);
Expand Down

0 comments on commit 2224d73

Please sign in to comment.