1
0
mirror of https://github.com/php/php-src.git synced 2026-03-25 16:52:18 +01:00
Files
archived-php-src/ext/libxml/tests/libxml_get_external_entity_loader.phpt
Tim Starling 11796229f2 Add libxml_get_external_entity_loader()
Add libxml_get_external_entity_loader(), which returns the currently
installed external entity loader, i.e. the value which was passed to
libxml_set_external_entity_loader() or null if no loader was installed
and the default entity loader will be used.

This allows libraries to save and restore the loader, controlling entity
expansion without interfering with the rest of the application.

Add macro Z_PARAM_FUNC_OR_NULL_WITH_ZVAL(). This allows us to get the
zval for a callable parameter without duplicating callable argument
parsing.

The saved zval keeps the object needed for fcc/fci alive, simplifying
memory management.

Fixes #76763.
2022-08-28 12:47:20 +01:00

37 lines
763 B
PHP

--TEST--
libxml_get_external_entity_loader() returns current handler
--EXTENSIONS--
libxml
--FILE--
<?php
class Handler {
private $name;
public function __construct($name) {
$this->name = $name;
}
public function handle($public, $system, $context) {
return null;
}
public function __toString() {
return "Handler#{$this->name}";
}
}
var_dump(libxml_get_external_entity_loader());
libxml_set_external_entity_loader([new Handler('A'), 'handle']);
print libxml_get_external_entity_loader()[0] . "\n";
libxml_set_external_entity_loader([new Handler('B'), 'handle']);
print libxml_get_external_entity_loader()[0] . "\n";
libxml_set_external_entity_loader(null);
var_dump(libxml_get_external_entity_loader());
--EXPECT--
NULL
Handler#A
Handler#B
NULL