consolibyte / quickbooks-php

QuickBooks Integration for PHP
Eclipse Public License 1.0
455 stars 337 forks source link

Prevent fatal error when QuickBooks Online returns incomplete XML #316

Open emilebourquin opened 1 year ago

emilebourquin commented 1 year ago

This diff looks much bloodier than it is. All I did was wrap the call to $List = $Root->getChildAt('IntuitResponse QueryResponse') in an IF, and return false in the ELSE.

Prevents a fatal error when QuickBooks Online returns incomplete XML, and the call to $List = $Root->getChildAt('IntuitResponse QueryResponse') returns FALSE, so $List->attributes() throws an error.

emilebourquin commented 1 year ago

I guess I shouldn't say QuickBooks Online was offline, but rather QuickBooks Online was returning XML such that $Doc = $Parser->parse($errnum, $errmsg) and $Root = $Doc->getRoot(); were succeeding, but $List = $Root->getChildAt('IntuitResponse QueryResponse') was false, and $attrs = $List->attributes(); caused a fatal error.