| @@ -389,8 +389,12 @@ | ||
| 389 | 389 | if ( empty( $servers ) || ! is_array( $servers ) ) { |
| 390 | 390 | continue; |
| 391 | 391 | } |
| 392 | 392 | $first = (string) ( $servers[0] ?? '' ); |
| 393 | + // A Redis socket imports whole, so there is nothing to warn about. | |
| 394 | + if ( 'redis' === $engine && '' !== Redis_Client::socket_path( $first ) ) { | |
| 395 | + continue; | |
| 396 | + } | |
| 393 | 397 | if ( ! preg_match( '#^([a-z][a-z0-9+.-]*)://#i', $first, $m ) ) { |
| 394 | 398 | continue; |
| 395 | 399 | } |
| 396 | 400 | $notes[] = sprintf( |
| @@ -744,10 +748,14 @@ | ||
| 744 | 748 | if ( ! class_exists( __NAMESPACE__ . '\\Object_Cache' ) ) { |
| 745 | 749 | return $result; |
| 746 | 750 | } |
| 747 | 751 | |
| 748 | - $opts = (array) Settings_Manager::get( 'object-cache' ); | |
| 749 | - $state = Object_Cache::enable( $opts ); | |
| 752 | + $opts = (array) Settings_Manager::get( 'object-cache' ); | |
| 753 | + // An import IS the user switching away from the source plugin, so it | |
| 754 | + // takes the same switch path: the source's own object cache is turned | |
| 755 | + // off through its settings (or the plugin deactivated) before ours goes | |
| 756 | + // in, instead of being overwritten while it stays on. (#686) | |
| 757 | + $state = Object_Cache::enable( $opts, array( 'takeover' => true ) ); | |
| 750 | 758 | |
| 751 | 759 | $result['ok'] = ! empty( $state['ok'] ); |
| 752 | 760 | $result['object_cache_ready'] = ! empty( $state['ok'] ); |
| 753 | 761 | if ( empty( $state['ok'] ) ) { |
| @@ -1065,8 +1073,16 @@ | ||
| 1065 | 1073 | // drop-in's WP_REDIS_HOST, so the imported object cache could |
| 1066 | 1074 | // never connect. A managed Redis on TLS is the common case. |
| 1067 | 1075 | // Bracketed IPv6 is left alone — stream_socket_client() wants |
| 1068 | 1076 | // the brackets. (#224) |
| 1077 | + // W3TC writes a unix socket as `unix:/path`. Split on the | |
| 1078 | + // colon like a host:port, it imported host "unix" and port 0. | |
| 1079 | + // A socket carries no port, so only the host is set. (#566) | |
| 1080 | + $socket = 'redis' === $engine ? Redis_Client::socket_path( $first ) : ''; | |
| 1081 | + if ( '' !== $socket ) { | |
| 1082 | + $patch['object-cache']['redis_host'] = $socket; | |
| 1083 | + $first = ''; | |
| 1084 | + } | |
| 1069 | 1085 | $first = (string) preg_replace( '#^[a-z][a-z0-9+.-]*://#i', '', $first ); |
| 1070 | 1086 | $separator = strrpos( $first, ':' ); |
| 1071 | 1087 | if ( false !== $separator ) { |
| 1072 | 1088 | $host = substr( $first, 0, $separator ); |