Support » Fixing WordPress » set_transient not expiring in the database since WP 4.3

  • I’m wondering if anyone else has ran into this issue since the WordPress 4.3 update. I’m the developer of a social media plugin which relies on the WordPress set_transient function 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 the bug reported in this ticket. The same problem seems to be happening to other developers of similar plugins, and I’ve had 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:

    <?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;
    }
    
    ?>

    The transient should expire every 30 minutes and check the URL again for new data, but it doesn’t unless I delete the transient manually.

    Has anyone else experienced the same problem? I’m about to try creating a basic cron job to see if I can manually clear the transients for those users who are having this problem, but that obviously isn’t an ideal solution. I was thinking of reporting it as a bug to Trac but wanted to post it here first to see whether it was something other people were running into or able to replicate.

    John

Viewing 1 replies (of 1 total)
  • Anyone else experiencing the same problem? I’ll likely go ahead and just file a WordPress bug report seeing as it seems to be related to the recent 4.3 update.

Viewing 1 replies (of 1 total)
  • The topic ‘set_transient not expiring in the database since WP 4.3’ is closed to new replies.