Fieldtype, Module


CE Tweet

ExpressionEngine 2

Back to this add-on's main page
View Other Add-ons From Causing Effect


Issue with CE Tweet 1.3.8 and runtime annotations in EE 2.9.0

Support Request

Patrick Reagan
Patrick Reagan

After upgrading to EE 2.9.0, we saw some error messages in the template logs that indicated that there were cache misses from CE Tweet when there shouldn’t be:

(0.686731 20.42MB)   ***  CE Tweet debugThe cache file "EE_SYSTEM_DIR/expressionengine/cache/ce_tweet/p_73b09fbfe3c702171f6068ad60f3976d" does not exist

Upon further investigation, we saw that the ‘cache/ce_tweet’ directory contained over 50,000 files due to cache misses creating new cache files (that were never used).  I confirmed this in my local development environment and tracked it down to the line that creates the filename for the cache file:

// ce_tweet/mod.ce_tweet.php
//the parsed cache filename
$cache_parsed 'p_' md5$this->EE->TMPL->tagchunk $unique ); 

From inspecting the value of `$this->EE->TMPL->tagchunk` I was able to see that, in some circumstances, ExpressioneEngine would inject an annotation into the tag chunk.  So a simple tag like:

{exp:ce_tweet:user_timeline screen_name="SCREEN_NAME"}
  {if count 
== '1'}first{if:else}other{/if}

Results in output like:

{exp:ce_tweet:user_timeline screen_name="SCREEN_NAME"}   {!-- ra:0000000010183f6f000000015c2737a4 --}{if count == '1'}first{if:else}other{/if} {/exp:ce_tweet:user_timeline} 

Causing the hashed filename to change on every request.  I found references to other people having problems with this new feature, but was unable to track down a global solution.  In the end, I resorted to stripping the annotations from the tag chunk prior to hashing:

diff --git a/third_party/ce_tweet/mod.ce_tweet.php b/third_party/ce_tweet/mod.ce_tweet.php
index c0f08f1
..9bfc7f2 100755
--- a/third_party/ce_tweet/mod.ce_tweet.php
+++ b/third_party/ce_tweet/mod.ce_tweet.php
@@ -783,11 +783,14 @@ class Ce_tweet {
unset( $settings );
// remove annotation from tagchunk (if present)
+      $tagchunk preg_replace('/\{!-- ra:(\w+) --\}/'''$this->EE->TMPL->tagchunk);
//the raw cache filename
$cache_raw 'r_' md5$unique );
//the parsed cache filename
-      $cache_parsed 'p_' md5$this->EE->TMPL->tagchunk $unique );
$cache_parsed 'p_' md5$tagchunk $unique );
//the cache base
$cache_base str_replace( array( '\\''/', ), DIRECTORY_SEPARATOR$this->remove_duplicate_slashesAPPPATH 'cache/ce_tweet/' ) ); 

Is there a better solution to avoid this undesired behavior?