[wp-trac] [WordPress Trac] #34322: set_transient and get_transient don't seem to be working for some users since WP 4.3

WordPress Trac noreply at wordpress.org
Fri Oct 16 04:07:36 UTC 2015


#34322: set_transient and get_transient don't seem to be working for some users
since WP 4.3
--------------------------+-----------------------------
 Reporter:  smashballoon  |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  General       |    Version:  4.3
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 I'm the developer of a social media plugin which relies on the WordPress
 set_transient and get_transient functions to temporarily cache data in the
 user's database. Since the WordPress 4.3 update, we've had reports of the
 cache not clearing automatically as it should, meaning that the transients
 aren't expiring correctly in the database. This seems to only be happening
 on some servers as I haven't been able to replicate the issue on my own
 test site, but have confirmed it on user sites, and looks like it could be
 related to [https://make.wordpress.org/core/2015/07/30/get_transient-is-
 now-more-strict-in-4-3/ this thread]. The same problem seems to be
 happening to other developers of similar plugins, and I've had some users
 report that other unrelated WordPress plugins they're using are also not
 automatically updating either any more, which I'm assuming is caused by
 the same issue. I've been able to confirm the problem on user sites by
 using a page template containing the following basic code. I've commented
 it to explain what it does and can provide a Facebook Access Token
 privately if needed, although I included a link on how to obtain your own.
 The transient set using the script below should expire every 30 minutes
 and then the script should check the URL again for new data, but it
 doesn't unless I delete the transient manually.

 {{{
 <?php
 /* Template Name: Transient test */

 //Facebook URL to get data from. You can get an Access Token to use in the
 URL by following the directions here: https://smashballoon.com/custom-
 facebook-feed/access-token/
 $url = 'https://graph.facebook.com/cnn/posts?access_token=ACCESS_TOKEN';

 //Check the database for the transient containing the data
 $transient = get_transient( 'test_transient_expiration' );

 if( ! empty( $transient ) ) {
   //The transient was found in the database
         echo 'Got the existing transient from the database <br />';
   //Show the date the data was last updated from Facebook
   echo 'Last updated: ' . json_decode( json_encode($transient)
 )->headers->date;
 } else {
   //No transient in the database - get the data from Facebook
   $facebook_data = wp_remote_get( $url );
   //Cache the data in the database
   set_transient( 'test_transient_expiration', $facebook_data, 1800 );
         echo 'Got the data from the URL <br />';
   //Show the date the data was last updated from Facebook
   echo 'Last updated: ' . json_decode( json_encode($facebook_data)
 )->headers->date;
 }

 ?>
 }}}

 I was in two minds whether to report this as a bug as I've never reported
 one before, however it definitely seems like this could be a bug as the
 above code should work, but doesn't on some user's sites. I use code very
 similar to the above in my plugin and nothing has been changed in that
 code, but users started reporting an issue shortly after the WordPress 4.3
 update was released. Through reading the change logs for the 4.3 update I
 know some changes were made to transients and so I'm wondering if that's
 what caused this problem.

 Sorry for the long post!

 John

--
Ticket URL: <https://core.trac.wordpress.org/ticket/34322>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list