Bug Summary
Local / MacBookPro / Life link on any browser
Steps to reproduce
nothing spécial
Environment Info
Last OS on macbook pro, WP 7 , Divi5,
Supporting info
Bug: unserialize() warning caused by make_link_local() in live-link-helper.php
When using Live Links, a PHP warning appears at the top of every page:
Warning: unserialize(): Error at offset 5489 of 5512 bytes in .../local-by-flywheel-live-link-helper.php on line 198
Root cause:
In the make_link_local() method, when the option is not a string, the code:
- Serializes the value with
serialize() - Replaces the URL via string replacement (which changes string lengths)
- Calls
unserialize()on the result
Step 3 fails because PHP serialization uses byte-length prefixes (s:XX:) that are no longer correct after the URL replacement.
Fix:
Replace the serialize/unserialize cycle with a recursive traversal that replaces URLs directly in strings, without touching serialization:
public function make_link_local( $option ) {
if ( gettype( $option ) !== 'string' ) {
return $this->replace_host_in_value( $this->get_tunnel_host(), $this->home_domain, $option );
}
return $this->replace_host( $this->get_tunnel_host(), $this->home_domain, $option );
}
private function replace_host_in_value( $from, $to, $data ) {
if ( is_array( $data ) ) {
foreach ( $data as $key => $value ) {
$data[ $key ] = $this->replace_host_in_value( $from, $to, $value );
}
} elseif ( is_object( $data ) ) {
foreach ( get_object_vars( $data ) as $key => $value ) {
$data->$key = $this->replace_host_in_value( $from, $to, $value );
}
} elseif ( is_string( $data ) ) {
$data = $this->replace_host( $from, $to, $data );
}
return $data;
}
This fix has been tested and resolves the warning completely.
Environment: macOS, Local 9.x, PHP 8.x, WordPress 7 with Divi theme + Complianz plugin.