Skip to content

Commit

Permalink
Fix cached false condition
Browse files Browse the repository at this point in the history
Since we're using (string) '0' to cache the false condition, a strict equality check won't work here.

1. When we create a coauthor, we check that the slug is not already taken. Since it's not, we cache '0'.
2. Next time we need to get that coauthor `false !== ( $retval = wp_cache_get( $cache_key, self::$cache_group ) )`. Since `false !== '0'`, that passes. Since '0' is not an object, we return false. The cache will never have a chance to get fixed.

We don't want to use the cache if it's any version of false (0, '0', false).

Ref: 6a9f4c2
  • Loading branch information
joshbetz committed May 31, 2014
1 parent 6fbf1dc commit 6ad24ff
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion php/class-coauthors-guest-authors.php
Expand Up @@ -779,7 +779,7 @@ function get_guest_author_by( $key, $value, $force = false ) {

$cache_key = $this->get_cache_key( $key, $value );

if ( false == $force && false !== ( $retval = wp_cache_get( $cache_key, self::$cache_group ) ) ) {
if ( false == $force && false != ( $retval = wp_cache_get( $cache_key, self::$cache_group ) ) ) {
// Properly catch our false condition cache
if ( is_object( $retval ) )
return $retval;
Expand Down

0 comments on commit 6ad24ff

Please sign in to comment.