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

Problem with $xero->Payments #7

Open
swordfox opened this issue Jan 6, 2011 · 6 comments
Open

Problem with $xero->Payments #7

swordfox opened this issue Jan 6, 2011 · 6 comments

Comments

@swordfox
Copy link

swordfox commented Jan 6, 2011

All methods seem to work fine except $xero->Payments

The screen just goes blank after calling the following method with print_r. I've PHP error values set to show all & it's still blank.

$payment_result = $xero->Payments( $new_payment );
print_r($payment_result);

Any ideas?

@nickteagle
Copy link

Hi I've just starting using this and I get a Segmentation fault (i'm test using the command line) when adding a new payment but both adding a new Contact and Invoice and listing my Accounts all work fine. I've also emailed xero to see if its anything at there end Note the xero status for these are 400 but i can't see anything wrong.
It crash's here
$xero_response = curl_exec($ch) (line 309 approx)
I've also copy my code to my laptop which is a ubuntu 10.10 php 5.3.3 and it crash's on there as well.

Nick

@relaxomatic
Copy link

I seem to be having the same issue, what I have noticed is that on my development machine which runs windows 7 it works fine, but on our production machine which runs Debian it is having issues when it reaches that line $xero_response = curl_exec($ch).

@nickteagle
Copy link

I've got mine to work by using fsocket for the put message if you email me I can send you my xero.php. nickteagle (at) gmail.com. I'm also tried installing the latest version of php and curl and I still have the error so i'm going to raise a bug on curl and see if that helps. Nick

@davidmytton
Copy link

I've commited Nick's fix for this here: https://github.com/dmytton/PHP-Xero/commit/054c45906aa1d9d0b70d49ed133081464810436a

@eugeneius
Copy link

What's happening is that the memory-mapped file is closed before curl has a chance to read it - it's a problem with the xero library, not curl. Here's a patch:

diff --git a/xero.php b/xero.php
index 3afa43d..1215780 100644
--- a/xero.php
+++ b/xero.php
@@ -303,10 +303,13 @@ class Xero {
                                curl_setopt($ch, CURLOPT_INFILE, $fh);
                                curl_setopt($ch, CURLOPT_INFILESIZE, strlen($xml));
                                curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
-                               fclose($fh);
                        }
                        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
                        $xero_response = curl_exec($ch);
+                       if (isset($fh))
+                       {
+                               fclose($fh);
+                       }
                        $xero_xml = simplexml_load_string( $xero_response );
                        if (!$xero_xml) {
                                return $xero_response;

I've opened a new pull request (#13) with this change as well.

@calvinfroedge
Copy link

Thanks for posting this fix. Much obliged.

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

6 participants