Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save JRGould/7414b0abfe091bd6d83d7bd871c90b35 to your computer and use it in GitHub Desktop.
Save JRGould/7414b0abfe091bd6d83d7bd871c90b35 to your computer and use it in GitHub Desktop.
<?php
/*
Plugin Name: WP Migrate DB Pro Tweak: Skip Serialized Refs in Options Table
Plugin URI: http://github.com/deliciousbrains/wp-migrate-db-pro-tweaks
Description: Skip unserializing / replacing data that contains serialized references as this can cause an infinite loop.
Author: Delicious Brains
Version: 1
Author URI: http://deliciousbrains.com
*/
add_filter( 'wpmdb_pre_recursive_unserialize_replace', function ( $pre, $data, $wpmdb_replace ) {
if ( false !== $pre ) {
return $pre;
}
if ( empty( $data ) ) {
return $pre;
}
if ( $wpmdb_replace->table_is( 'options' ) && 'option_value' === $wpmdb_replace->get_column() && is_serialized( $data ) ) {
if ( preg_match( '/r\:\d+/i', $data ) ) {
return $data;
}
}
return $pre;
}, 10, 3 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment