Skip to content

Loading…

Problem with $xero->Payments #7

Open
swordfox opened this Issue · 6 comments

6 participants

@swordfox

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

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

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

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

@dmytton

I've commited Nick's fix for this here: dmytton@054c459

@eugeneius

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

Thanks for posting this fix. Much obliged.

@lloydhazlett lloydhazlett referenced this issue in XeroAPI/XeroOAuth-PHP
Merged

Fix PUT, update README #12

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.