Skip to content

[XML-RPC library] Object of class XMLParser could not be converted to string (PHP 8) #6187

Description

@luizzz

CodeIgniter 3.1.13
PHP 8.1.10
File: /system/libraries/Xmlrpc.php

Error:
Exception: Object of class XMLParser could not be converted to string (Xmlrpc.php on line 1284)

Where:
Triggers when i call "http://localhost/api/helloWorld" (same sample as shown on documentation)
This code works flawlessly on PHP 7.4 or older.
`class Api extends CI_Controller {

function __construct()
{
    parent::__construct();
    $this->load->library('xmlrpc');
    $this->load->config('xmlrpc');
    $this->xmlrpc->debug = $this->config->item('xmlrpc_debug');
    $server_url = site_url('webservice');
    $this->xmlrpc->server($server_url, 80);
}

function helloWorld()
{
    $this->xmlrpc->method('helloWorld');
    $request = array();
    return $this->makeRequest($request);
}

}`

How i fixed it:
Target file: /system/libraries/Xmlrpc.php
Change all lines from:

$the_parser = (string) $the_parser;

To:

if(empty((array) $the_parser)) { $the_parser = '0'; } else { $the_parser = (string) $the_parser; }

Not sure if this are correct but it's works here...

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions