Support » Plugin: WooCommerce Sync for QuickBooks Online - by MyWorks Software » quickbooks-lib error array/int

  • Brian Henry

    (@brianhenryie)


    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 the else 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?

Viewing 1 replies (of 1 total)
  • Plugin Author MyWorks Software

    (@myworksdesign)

    Brian,

    Thanks for reaching out! Agreed that’s a little unexpected – not something we’ve seen in testing on our internal sites.

    If you’re able to open a ticket with us within your account, we can help take a closer look at this on your site as well, while we review your above information in the meantime.

    http://support.myworks.software/hc/en-us

Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.