Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
define('DISABLE_WP_CRON', true);
require_once "wp-load.php";
add_filter("pre_get_table_charset", "fail_in_get_table_charset", 10);
simulate possible failure in,
but only when invoked from sanitize_option()
function fail_in_get_table_charset()
$trace = debug_backtrace();
foreach ($trace as $call) {
if ($call["function"] == "sanitize_option") {
return new WP_Error( 'wpdb_get_table_charset_failure' );
return null;
$opt = get_option("siteurl");
echo "- Original siteurl value: \n\n";
echo "\n";
update_option("siteurl", $opt);
echo "- After updating with a failure in get_table_charset: \n\n";
echo "\n";
remove_filter("pre_get_table_charset", "fail_in_get_table_charset", 10);
// revert things back to allow for easy re-running
update_option("siteurl", $opt);
echo "- After updating with without failure in get_table_charset: \n\n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment