mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-03-01 07:09:46 +00:00
Merge branch 'master' into 2.4
This commit is contained in:
commit
cce9e84907
3 changed files with 33 additions and 12 deletions
lib/Cake
|
@ -151,6 +151,7 @@ class ExceptionRenderer {
|
||||||
$response->header($exception->responseHeader());
|
$response->header($exception->responseHeader());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (class_exists('AppController')) {
|
||||||
try {
|
try {
|
||||||
$controller = new CakeErrorController($request, $response);
|
$controller = new CakeErrorController($request, $response);
|
||||||
$controller->startupProcess();
|
$controller->startupProcess();
|
||||||
|
@ -159,6 +160,7 @@ class ExceptionRenderer {
|
||||||
$controller->RequestHandler->startup($controller);
|
$controller->RequestHandler->startup($controller);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (empty($controller)) {
|
if (empty($controller)) {
|
||||||
$controller = new Controller($request, $response);
|
$controller = new Controller($request, $response);
|
||||||
$controller->viewPath = 'Errors';
|
$controller->viewPath = 'Errors';
|
||||||
|
|
|
@ -187,12 +187,23 @@ class XmlTest extends CakeTestCase {
|
||||||
*
|
*
|
||||||
* @dataProvider invalidDataProvider
|
* @dataProvider invalidDataProvider
|
||||||
* @expectedException XmlException
|
* @expectedException XmlException
|
||||||
* return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testBuildInvalidData($value) {
|
public function testBuildInvalidData($value) {
|
||||||
Xml::build($value);
|
Xml::build($value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test that building SimpleXmlElement with invalid XML causes the right exception.
|
||||||
|
*
|
||||||
|
* @expectedException XmlException
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testBuildInvalidDataSimpleXml() {
|
||||||
|
$input = '<derp';
|
||||||
|
$xml = Xml::build($input, array('return' => 'simplexml'));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* test build with a single empty tag
|
* test build with a single empty tag
|
||||||
*
|
*
|
||||||
|
|
|
@ -124,6 +124,7 @@ class Xml {
|
||||||
* @param string $input The input to load.
|
* @param string $input The input to load.
|
||||||
* @param array $options The options to use. See Xml::build()
|
* @param array $options The options to use. See Xml::build()
|
||||||
* @return SimpleXmlElement|DOMDocument
|
* @return SimpleXmlElement|DOMDocument
|
||||||
|
* @throws XmlException
|
||||||
*/
|
*/
|
||||||
protected static function _loadXml($input, $options) {
|
protected static function _loadXml($input, $options) {
|
||||||
$hasDisable = function_exists('libxml_disable_entity_loader');
|
$hasDisable = function_exists('libxml_disable_entity_loader');
|
||||||
|
@ -131,16 +132,23 @@ class Xml {
|
||||||
if ($hasDisable && !$options['loadEntities']) {
|
if ($hasDisable && !$options['loadEntities']) {
|
||||||
libxml_disable_entity_loader(true);
|
libxml_disable_entity_loader(true);
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
if ($options['return'] === 'simplexml' || $options['return'] === 'simplexmlelement') {
|
if ($options['return'] === 'simplexml' || $options['return'] === 'simplexmlelement') {
|
||||||
$xml = new SimpleXMLElement($input, LIBXML_NOCDATA);
|
$xml = new SimpleXMLElement($input, LIBXML_NOCDATA);
|
||||||
} else {
|
} else {
|
||||||
$xml = new DOMDocument();
|
$xml = new DOMDocument();
|
||||||
$xml->loadXML($input);
|
$xml->loadXML($input);
|
||||||
}
|
}
|
||||||
|
} catch (Exception $e) {
|
||||||
|
$xml = null;
|
||||||
|
}
|
||||||
if ($hasDisable && !$options['loadEntities']) {
|
if ($hasDisable && !$options['loadEntities']) {
|
||||||
libxml_disable_entity_loader(false);
|
libxml_disable_entity_loader(false);
|
||||||
}
|
}
|
||||||
libxml_use_internal_errors($internalErrors);
|
libxml_use_internal_errors($internalErrors);
|
||||||
|
if ($xml === null) {
|
||||||
|
throw new XmlException(__d('cake_dev', 'Xml cannot be read.'));
|
||||||
|
}
|
||||||
return $xml;
|
return $xml;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue