Skip to content

Instantly share code, notes, and snippets.

@rmccue
Created July 8, 2014 05:54
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rmccue/4a0dadc68aa4e75c851f to your computer and use it in GitHub Desktop.
Save rmccue/4a0dadc68aa4e75c851f to your computer and use it in GitHub Desktop.
<?php
namespace HM\Hotfix;
add_action( 'deleted_option', __NAMESPACE__ . '\\workaround_28701' );
/**
* Workaround cache deletion issue
*
* Ensures that the singular
* @link https://core.trac.wordpress.org/ticket/28701
* @param string $option Option key
*/
function workaround_28701( $option ) {
if ( defined( 'WP_INSTALLING' ) ) {
return;
}
// Check alloptions
// Uses array_key_exists instead of isset to detect the key
$alloptions = wp_load_alloptions();
if ( is_array( $alloptions ) && array_key_exists( $option, $alloptions ) ) {
unset( $alloptions[$option] );
wp_cache_set( 'alloptions', $alloptions, 'options' );
}
// Always clear the option key
wp_cache_delete( $option, 'options' );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment