• Resolved mumbomedia

    (@mumbomedia)


    Today I found an annoying bug.

    The warning Warning: A non-numeric value encountered in wp-content/plugins/woocommerce/includes/class-wc-cart-totals.php on line 234 was shown after I logged out from wordpress.

    I’ve look into the class-wc-cart-totals.php on line 234 and decide to look what the value of $cart_item. So I write the content of $cart_item into a log file.

    Then I saw what was causing it.

    A product has a price of “-“!
    This is of course not a number:

    I wonder why such input isn’t prevent.
    Then I think what about negative numbers like -1.
    So I enter it.
    Oh my god, I could store it.
    On frontend the price is shown as 0 and there a no warnings if I logged out.
    But this values are unlogical and entering / storing it should be prevented.

    Therefore, I would recommend updating the admin js to check the price fields for illogical values so that this annoying error could no longer occur.

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Support EtienneP a11n

    (@etiennep)

    Hi there!

    Thank you for bringing this to our attention!

    I was able to replicate this behavior and have reported it as a bug.

    You can follow the progress here – https://github.com/woocommerce/woocommerce/issues/23696

    Thread Starter mumbomedia

    (@mumbomedia)

    @etiennep

    Glad to hear that.

    I’m also curous that this issue was shown althought WP_DEBUG is set to false which should prevent such issues to be shown to the website visitors or potential hackers.
    I’ve filed a ticket about this issue also.
    I assume that with PHP 7 the messages are thrown as exceptions instead of errors so a exception handler needs to be defined. Maybe this is missing.

    Plugin Support EtienneP a11n

    (@etiennep)

    I just tested this on my site and to hide the warnings, WP_DEBUG will actually need to be set to true, and then WP_DEBUG_DISPLAY set to false.

    define( 'WP_DEBUG', true );
    define( 'WP_DEBUG_DISPLAY', false );
    Thread Starter mumbomedia

    (@mumbomedia)

    @etiennep

    Thanks for pointing this out.
    I will change this on our installations.

    Strange, in old wp-versions I don’t have to set up these defines:
    I believe this correct behaviour has taken place with the opportunity to set WP_DEBUG_LOG to a file path.

    As the most installation are live these defines should become standard for wp-config.php. Warnining, notices and errors should only be shown on testing instances.

    Plugin Support EtienneP a11n

    (@etiennep)

    Yeah, by default WP_DEBUG would be set to false and would need to be manually set to true. WP_DEBUG_DISPLAY is by default set to true if WP_DEBUG is enabled.

    Plugin Support EtienneP a11n

    (@etiennep)

    @mumbomedia, we haven’t heard back from you in a while, so I’m going to mark this as resolved – if you have any further questions, you can start a new thread.

    Thread Starter mumbomedia

    (@mumbomedia)

    Yes, it’s resolved.

    Also I could figure out why WP_DEBUG didn’t work as expected.
    The global setting for display_errors was set to true in the php.ini.
    By changed it to false, which should be the default on live servers, everything works like expected.

    Plugin Support EtienneP a11n

    (@etiennep)

    Thanks for letting me know!

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Warning: A non-numeric value encountered in class-wc-cart-totals.php on line 234’ is closed to new replies.