The module uses a stale cache even when the 20-minute cache expiration has passed.

In _facebook_pull_notes_cached() and _facebook_pull_feed_cached(), the logic for deciding whether or not to use the cached data data always evaluates to true.

PHP will interpret the less than sign (<) before the plus sign (+) in the following code:

if (!$cache || $cache->created + FACEBOOK_PULL_CACHETIME < REQUEST_TIME) {

The first operator evaluated here is < (http://php.net/manual/en/language.operators.precedence.php), which simplifies this expression to:

if (!$cache || $cache->created + TRUE) {

PHP's dynamic/weak typing means that adding TRUE to an integer evaluates to the integer +1.

if (!$cache || $cache->created + 1) {

A positive integer will evaluate to true:

if (!$cache || TRUE) {

I am attaching a patch.

CommentFileSizeAuthor
facebook_pull_stale_cache.patch1.15 KBcalebtr
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

calebtr created an issue. See original summary.

calebtr’s picture

Title: cache logic always » stale cache always used if available
wranvaud’s picture

Status: Active » Closed (works as designed)

Actually + has precedence over < so this should be ok. I'm closing it but feel free to re-open.