quickbooks-lib error array/int
-
PHP Notice: Trying to access array offset on value of type int in /path/to/wp-content/plugins/myworks-woo-sync-for-quickbooks-online/includes/lib/quickbooks-lib/QuickBooks/IPP/Object.php on line 451
The offending code is part of an if/elseif/else block, which contains
else if (is_array($value))
and the error occurs inside theelse
part.Object.php:451:
if (substr($key, -3, 3) == 'Ref' and $svalue[0] == '{')
So this code doesn’t make sense. If
$value
were an array, it would be handled at line 374:else if (is_array($value))
So any code in the
else
block should not treat$value
as an array.Looking at the original library on GitHub (https://github.com/consolibyte/quickbooks-php/blob/b0834b79fee4509261a932b26b11bf2807cc4b29/QuickBooks/IPP/Object.php#L447), that line of code is
if (substr($key, -3, 3) == 'Ref' and $value{0} == '{')
I’m guessing you guys got the PHP deprecation warning about curly brace syntax and made a change or used a fork.
$value{0}
means give me the first character of the string.
$value[0]
means give me the first element in the array.So if we convert the string to an array, we can fix that problem:
$value_array = str_split( $value ); if (substr($key, -3, 3) == 'Ref' and $value_array[0] == '{') ... and further replacements
But the error message actually says
value of type int
. I tested curly syntax on an int and it returned null. I’m not sure if the int is a problem here. Could you please look into it?
- The topic ‘quickbooks-lib error array/int’ is closed to new replies.