Skip to content

Commit dddda72

Browse files
committed
PHP 7.4 bc fix for XML_PARSER hash
1 parent 8a88e51 commit dddda72

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

bundled-libs/XML/RPC.php

+6-4
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ function XML_RPC_se($parser_resource, $name, $attrs)
245245
{
246246
global $XML_RPC_xh, $XML_RPC_valid_parents;
247247

248-
$parser = spl_object_hash($parser_resource);
248+
$parser = is_resource($parser_resource) ? ((int) $parser_resource) : spl_object_hash($parser_resource);
249249

250250
// if invalid xmlrpc already detected, skip all processing
251251
if ($XML_RPC_xh[$parser]['isf'] >= 2) {
@@ -374,7 +374,7 @@ function XML_RPC_ee($parser_resource, $name)
374374
{
375375
global $XML_RPC_xh;
376376

377-
$parser = spl_object_hash($parser_resource);
377+
$parser = is_resource($parser_resource) ? ((int) $parser_resource) : spl_object_hash($parser_resource);
378378

379379
if ($XML_RPC_xh[$parser]['isf'] >= 2) {
380380
return;
@@ -511,7 +511,7 @@ function XML_RPC_cd($parser_resource, $data)
511511
{
512512
global $XML_RPC_xh, $XML_RPC_backslash;
513513

514-
$parser = spl_object_hash($parser_resource);
514+
$parser = is_resource($parser_resource) ? ((int) $parser_resource) : spl_object_hash($parser_resource);
515515

516516
if ($XML_RPC_xh[$parser]['lv'] != 3) {
517517
// "lookforvalue==3" means that we've found an entire value
@@ -1433,7 +1433,9 @@ function parseResponse($data = '')
14331433

14341434
$encoding = $this->getEncoding($data);
14351435
$parser_resource = xml_parser_create($encoding);
1436-
$parser = spl_object_hash($parser_resource);
1436+
# xml_parser_create returns a resource before PHP 8, an object later. Only a resource can be
1437+
# casted to int
1438+
$parser = is_resource($parser_resource) ? ((int) $parser_resource) : spl_object_hash($parser_resource);
14371439

14381440
$XML_RPC_xh = array();
14391441
$XML_RPC_xh[$parser] = array();

0 commit comments

Comments
 (0)