consolibyte / quickbooks-php

QuickBooks Integration for PHP
Eclipse Public License 1.0
458 stars 338 forks source link

Prevent fatal error when QuickBooks Online returns incomplete XML #316

Open emilebourquin opened 2 years ago

emilebourquin commented 2 years 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 2 years 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.