Making WordPress.org

Changeset 7131


Ignore:
Timestamp:
04/18/2018 10:11:44 PM (6 years ago)
Author:
coreymckrill
Message:

WordCamp Site Cloner: Cache site list in an option instead of a transient

Having the site list in a transient was unstable because occasionally the
transient had expired but the cache hadn't been primed again yet.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-site-cloner/wordcamp-site-cloner.php

    r5456 r7131  
    1414
    1515const PRIME_SITES_CRON_ACTION      = 'wcsc_prime_sites';
    16 const WORDCAMP_SITES_TRANSIENT_KEY = 'wcsc_sites';
     16const WORDCAMP_SITES_OPTION_KEY = 'wcsc_sites';
    1717
    1818/**
     
    168168function sites_endpoint() {
    169169    $sites        = array();
    170     $cached_sites = get_site_transient( WORDCAMP_SITES_TRANSIENT_KEY );
     170    $cached_sites = get_site_option( WORDCAMP_SITES_OPTION_KEY, array() );
    171171
    172172    if ( $cached_sites ) {
     
    193193    }
    194194
    195     // Keep the cache longer than needed, just to be sure that it doesn't expire before the cron job runs again
    196     // todo This shouldn't be a transient, it should just be a regular option.
    197     //      Transients aren't guaranteed to exist until they expire, so it could expire before the next cron runs
    198     set_site_transient( WORDCAMP_SITES_TRANSIENT_KEY, get_wordcamp_sites(), DAY_IN_SECONDS * 2 );
     195    update_site_option( WORDCAMP_SITES_OPTION_KEY, get_wordcamp_sites() );
    199196}
    200197
Note: See TracChangeset for help on using the changeset viewer.