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.
Comment | File | Size | Author |
---|---|---|---|
facebook_pull_stale_cache.patch | 1.15 KB | calebtr |
Comments
Comment #2
calebtr CreditAttribution: calebtr commentedComment #3
wranvaud CreditAttribution: wranvaud at Phase2 commentedActually + has precedence over < so this should be ok. I'm closing it but feel free to re-open.