Support » Plugin: W3 Total Cache » Cache zero values on object cache

  • Hi,

    I’m having hard time to cache zero values on object cache.

    After debugging I noticed that when W3_ObjectCache tries to get a value, check the if its a null value to avoid return it. But this check does not make a strict compare, so, a zero value is not returned too (lib\W3\ObjectCache.php, line 168).

    Is this a bug or there is a workaround to this issue?

    https://wordpress.org/plugins/w3-total-cache/

Viewing 1 replies (of 1 total)
  • This is a terrible bug, you really need to fix. The codex recommended way to check for expired transients is a strict compare against false:
    if ( false === ( $valid = get_site_transient( $key ) ) ) {

    But if you save a 0 to it, in the same page load it will return 0, but on subsequent it will return false. That means that the entire transient API is broken by this object cache right now in very common use cases.

    This caused untold headaches for our popular WP Smush plugin, with 300k active installs. A few thousand of them were using your file-based object cache and the API calls were no longer getting cached in transients. So we started getting API calls from every page load!
    https://www.evernote.com/l/AImEDerGbO1Ay6_OrA6jvbNZmP6xm57rMk4B/image.png

Viewing 1 replies (of 1 total)
  • The topic ‘Cache zero values on object cache’ is closed to new replies.