Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible breaking bug - setHttpClient #9

Open
coreation opened this issue May 20, 2016 · 0 comments
Open

Possible breaking bug - setHttpClient #9

coreation opened this issue May 20, 2016 · 0 comments

Comments

@coreation
Copy link
Contributor

Hi @jacobsteringa ,

Voodoo

I'm not sure how or why, but making an Http\Client and then passing it to the OdooClient's XmlRpc breaks things on my end, I've also used it in the constructor which was my previous pull request, but for some reason, I get an Odoo error now:

This is the one where I set the Http Client with setHttpClient, after constructing the OdooClient

  [Zend\XmlRpc\Client\Exception\FaultException]
  Traceback (most recent call last):
    File "/home/odoo/src/odoo/9.0/openerp/service/wsgi_server.py", line 56, in xmlrpc_return
      result = openerp.http.dispatch_rpc(service, method, params)
    File "/home/odoo/src/odoo/9.0/openerp/http.py", line 114, in dispatch_rpc
      result = dispatch(method, params)
  UnboundLocalError: local variable 'dispatch' referenced before assignment

The error I now get when I pass the Http\Client in the OdooClient's constructor is almost the same, but the error reads "method execute is not found", again an entire Odoo stacktrace on the Odoo Server side.

I have been breaking my head on this because if you make the Http\Client right before you instantiate the XmlRpcClient (https://github.com/jacobsteringa/OdooClient/blob/master/Odoo.php#L352) the error is gone. No problem whatsoever, if I pass the exact same statement, before I create my OdooClient, the Odoo returns its server errors. Meaning the following voodoo:

$httpClient = new Client(null, [options]);
$odooClient = new OdooClient(...., $httpClient);

-> fails, above stated errors are thrown

And when I do this:

$httpClient = new Client(null, [options]);
$this->client = new XmlRpcClient($this->host . '/' . $path, $httpClient);

-> all works fine

I'm clueless as to why this happens, I've been browsing in the underlying classes to figure out why, but found no answer.

Solution

I looked into an eloquent solution and found my current state of the client is the most eloquent one, one that instead of passing an entire Http\Client, just sets the options post construct.

So if someone runs into these problems, this very well may be a fix. I've seen you added the setHttpClient as an addition to my PR, so I'm not going to PR it just yet. Just letting you know and perhaps you know what's going on under the Zend-hood.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant