• 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 4 replies - 1 through 4 (of 4 total)
  • Plugin Author MyWorks

    (@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.

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

    Thread Starter Brian Henry

    (@brianhenryie)

    Here’s some additional information.

    The error is occurring during the mw_qbo_sync_queue_cron_hook action.

    Line 380 is (recursively) calling the current method _asXML_v3 with arguments 2, "SalesItemLineDetail", null, null

    Plugin Author MyWorks

    (@myworksdesign)

    @brianhenryie Thanks for the additional information! While we relay this to our dev/support teams, did you have a chance to open a ticket as mentioned above? If you have that ticket number, we can also escalate/prioritize that ticket for you.

    Thread Starter Brian Henry

    (@brianhenryie)

    I didn’t manage to open a ticket. The company’s account password has been changed since I last needed it! I’ll try get to it soon.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘quickbooks-lib error array/int’ is closed to new replies.