[wp-trac] [WordPress Trac] #16296: Transient API key length could result in uncacheable data

WordPress Trac wp-trac at lists.automattic.com
Wed Jan 19 06:28:57 UTC 2011


#16296: Transient API key length could result in uncacheable data
--------------------------+--------------------------------
 Reporter:  archon810     |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Cache         |    Version:  3.0.4
 Severity:  normal        |   Keywords:  transient, caching
--------------------------+--------------------------------
 I was just writing a caching layer for some plugin code using the
 Transient API and found that while caching was created, it was immediately
 discarded and re-cached. Upon further examination, I found that the
 transient key was different for the data itself compared to the timeout
 key. Specifically, the transient timeout key was longer due to the
 presence of the word "timeout" in it and was running into the MySQL key
 length limit of 64 characters, getting silently truncated.

 Therefore, the key for the timeout was different than the key for the
 data, resulting in both rows being deleted every time get_transient() is
 called.

 A solution would involve checking for the key length and possibly
 truncating the data key so that it wouldn't truncate the timeout key, but
 this solution could be confusing to the plugin writer who is expecting a
 certain key.

 Sorry if I was confusing in describing the bug. tl;dr: transient key and
 transient timeout could end up being different and prevent caching from
 working.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/16296>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list