DarkaOnLine / Ripcord

XML RPC client and server around PHP's xmlrpc library
33 stars 20 forks source link

`_throwExceptions` is not propagated in `__get()` #29

Open Julien00859 opened 1 year ago

Julien00859 commented 1 year ago

Hello there,

I'm using the arrow operator so that I can go through the server namespace easily. I'm also trying to configure ripcord so that it raises an exception on faults. I did the following:

$models = ripcord::client($url);  // the URL to our xmlrpc capable server
$models->_throwExceptions = true;
$version = $models->version();

When I change the backend so that version() throws an exception, ripcord correctly throws the fault too.

$models = ripcord::client($url);  // the URL to our xmlrpc capable server
$models->_throwExceptions = true;
$records = $models->res->partner->search();

When I change the backend so that search() throws an exception, ripcord silences it. I would like it throws the fault.

From my investigation in the source code, I think the problem is located inside there:

https://github.com/DarkaOnLine/Ripcord/blob/67e79523541bd6d9509c7762b94146a64d4434df/src/Ripcord/Client/Client.php#L241-L258

The _throwExceptions attribute (along with the others attributes) are not propagated to the new instance.

Julien00859 commented 1 year ago

As a work around, I'm doing the following:

use Ripcord\Client\Client;
use Ripcord\Client\Transport\Stream;
class CustomClient extends Client {public $_throwException = true;}
$models = new CustomClient($url, null, new Stream());