Skip to content

Commit 6530fd6

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 9e1e1a1 commit 6530fd6

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

appsys/libraries/Xmlrpc.php

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1153,7 +1153,10 @@ public function parseResponse($fp)
11531153
//-------------------------------------
11541154

11551155
$parser = xml_parser_create($this->xmlrpc_defencoding);
1156-
$pname = (string) $parser;
1156+
if (version_compare(PHP_VERSION, '7.2.0') >= 0)
1157+
$pname = spl_object_id($parser);
1158+
else
1159+
$pname = (string) $parser;
11571160
$this->xh[$pname] = array(
11581161
'isf' => 0,
11591162
'ac' => '',
@@ -1281,7 +1284,10 @@ public function parseResponse($fp)
12811284
*/
12821285
public function open_tag($the_parser, $name)
12831286
{
1284-
$the_parser = (string) $the_parser;
1287+
if (version_compare(PHP_VERSION, '7.2.0') >= 0)
1288+
$the_parser = spl_object_id($the_parser);
1289+
else
1290+
$the_parser = (string) $the_parser;
12851291

12861292
// If invalid nesting, then return
12871293
if ($this->xh[$the_parser]['isf'] > 1) return;
@@ -1382,7 +1388,10 @@ public function open_tag($the_parser, $name)
13821388
*/
13831389
public function closing_tag($the_parser, $name)
13841390
{
1385-
$the_parser = (string) $the_parser;
1391+
if (version_compare(PHP_VERSION, '7.2.0') >= 0)
1392+
$the_parser = spl_object_id($the_parser);
1393+
else
1394+
$the_parser = (string) $the_parser;
13861395

13871396
if ($this->xh[$the_parser]['isf'] > 1) return;
13881397

@@ -1516,7 +1525,10 @@ public function closing_tag($the_parser, $name)
15161525
*/
15171526
public function character_data($the_parser, $data)
15181527
{
1519-
$the_parser = (string) $the_parser;
1528+
if (version_compare(PHP_VERSION, '7.2.0') >= 0)
1529+
$the_parser = spl_object_id($the_parser);
1530+
else
1531+
$the_parser = (string) $the_parser;
15201532

15211533
if ($this->xh[$the_parser]['isf'] > 1) return; // XML Fault found already
15221534

appsys/libraries/Xmlrpcs.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,10 @@ public function parseRequest($data = '')
234234

235235
$parser = xml_parser_create($this->xmlrpc_defencoding);
236236
$parser_object = new XML_RPC_Message('filler');
237-
$pname = (string) $parser;
237+
if (version_compare(PHP_VERSION, '7.2.0') >= 0)
238+
$pname = spl_object_id($parser);
239+
else
240+
$pname = (string) $parser;
238241

239242
$parser_object->xh[$pname] = array(
240243
'isf' => 0,

0 commit comments

Comments
 (0)