Created
July 8, 2014 05:54
-
-
Save rmccue/4a0dadc68aa4e75c851f to your computer and use it in GitHub Desktop.
Work around https://core.trac.wordpress.org/ticket/28701
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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