• Hi,

    every now & then this pops up:

    PHP Warning: Attempt to read property “post_type” on string in /srv/wp-content/plugins/woo-custom-and-sequential-order-number/includes/classes/class-wcson-order-number.php on line 68

    Unfortunately I only see it later in the logs, without knowing how to reproduce it. Fortunately, ultimately no negative effects as far as I can tell.

    From a first look, it seems something calls wcson_order_number with its second $post parameter as the default empty string, and that’s then attempted to be compared to 'shop_order' === $post->post_type in that line.

    Version info:
    WCaSON: 2.6.0
    WC 6.3.1
    WP 5.9.3
    PHP 8.0.17`

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter isarisar

    (@isarisar)

    It’s indeed a bug from two interconnected issues:

    • $post as string is not handled at all in wcson_order_number (despite it being set as default), and so the invalid property read can occur.
    • The woocommerce_before_resend_order_emails action that the function is registered for, however, is meant to be invoked with a string – especially by WooCommerce itself: here and here – and so the error occurs.
    Plugin Author vjinfotech

    (@vjinfotech)

    Hi,

    Thanks for getting in touch.

    I will check issue as soon as possible and release new update for it

    Thanks and have a nice day

    Thread Starter isarisar

    (@isarisar)

    I added an error_log for cases of $post being string.

    The warning is thrown for $post being customer_invoice. IOW, it’s indeed caused by the standard woocommerce_before_resend_order_emails WooCommerce action linked in my prior comment.

    If the plugin is meant to do nothing in these cases – as is the current flow – why not just prepend that part of the if condition with !is_string($post)?

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘PHP Warning: Attempt to read property “post_type” on string’ is closed to new replies.