Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?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
You can’t perform that action at this time.