Skip to content

Commit c105802

Browse files
committed
Fix php8/php7 compat for xml_parser_create that nows returns object
* this function returns an XMLParser instance on php8; previously, a resource was returned, or false on failure. so i just compare php versions and use thep roperty on
1 parent 0728e2a commit c105802

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

appsys/libraries/Xmlrpc.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -703,6 +703,10 @@ function parseResponse($fp)
703703
//-------------------------------------
704704

705705
$parser = xml_parser_create($this->xmlrpc_defencoding);
706+
if (version_compare(PHP_VERSION, '7.2.0') >= 0 && is_object($parser))
707+
$parser = spl_object_id($parser);
708+
else
709+
$parser = (string) $parser;
706710

707711
$this->xh[$parser] = array();
708712
$this->xh[$parser]['isf'] = 0;
@@ -847,6 +851,11 @@ function parseResponse($fp)
847851

848852
function open_tag($the_parser, $name, $attrs)
849853
{
854+
if (version_compare(PHP_VERSION, '7.2.0') >= 0 && is_object($the_parser))
855+
$the_parser = spl_object_id($the_parser);
856+
else
857+
$the_parser = (string) $the_parser;
858+
850859
// If invalid nesting, then return
851860
if ($this->xh[$the_parser]['isf'] > 1) return;
852861

@@ -949,6 +958,11 @@ function open_tag($the_parser, $name, $attrs)
949958

950959
function closing_tag($the_parser, $name)
951960
{
961+
if (version_compare(PHP_VERSION, '7.2.0') >= 0 && is_object($the_parser))
962+
$the_parser = spl_object_id($the_parser);
963+
else
964+
$the_parser = (string) $the_parser;
965+
952966
if ($this->xh[$the_parser]['isf'] > 1) return;
953967

954968
// Remove current element from stack and set variable
@@ -1093,6 +1107,11 @@ function closing_tag($the_parser, $name)
10931107

10941108
function character_data($the_parser, $data)
10951109
{
1110+
if (version_compare(PHP_VERSION, '7.2.0') >= 0 && is_object($the_parser))
1111+
$the_parser = spl_object_id($the_parser);
1112+
else
1113+
$the_parser = (string) $the_parser;
1114+
10961115
if ($this->xh[$the_parser]['isf'] > 1) return; // XML Fault found already
10971116

10981117
// If a value has not been found

appsys/libraries/Xmlrpcs.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,10 @@ function parseRequest($data='')
190190

191191
$parser = xml_parser_create($this->xmlrpc_defencoding);
192192
$parser_object = new XML_RPC_Message("filler");
193+
if (version_compare(PHP_VERSION, '7.2.0') >= 0 && is_object($parser))
194+
$parser = spl_object_id($parser);
195+
else
196+
$parser = (string) $parser;
193197

194198
$parser_object->xh[$parser] = array();
195199
$parser_object->xh[$parser]['isf'] = 0;

0 commit comments

Comments
 (0)