File tree 2 files changed +11
-3
lines changed
2 files changed +11
-3
lines changed Original file line number Diff line number Diff line change 1
1
# Changelog
2
2
3
+ ## Unreleased
4
+
5
+ - Fixed ` wp_cache_flush_group ` issue with Predis and replication connection
6
+
3
7
## 2.5.2
4
8
5
9
- Respect ` WP_REDIS_FLUSH_TIMEOUT ` in Lua flush scripts
Original file line number Diff line number Diff line change @@ -1612,8 +1612,12 @@ protected function execute_lua_script( $script ) {
1612
1612
$ flushTimeout = defined ( 'WP_REDIS_FLUSH_TIMEOUT ' ) ? WP_REDIS_FLUSH_TIMEOUT : 5 ;
1613
1613
1614
1614
if ( $ this ->is_predis () ) {
1615
- $ timeout = $ this ->redis ->getConnection ()->getParameters ()->read_write_timeout ?? ini_get ( 'default_socket_timeout ' );
1616
- stream_set_timeout ( $ this ->redis ->getConnection ()->getResource (), $ flushTimeout );
1615
+ $ connection = $ this ->redis ->getConnection ();
1616
+ if ($ connection instanceof Predis \Connection \Replication \ReplicationInterface) {
1617
+ $ connection = $ connection ->getMaster ();
1618
+ }
1619
+ $ timeout = $ connection ->getParameters ()->read_write_timeout ?? ini_get ( 'default_socket_timeout ' );
1620
+ stream_set_timeout ( $ connection ->getResource (), $ flushTimeout );
1617
1621
} else {
1618
1622
$ timeout = $ this ->redis ->getOption ( Redis::OPT_READ_TIMEOUT );
1619
1623
$ this ->redis ->setOption ( Redis::OPT_READ_TIMEOUT , $ flushTimeout );
@@ -1627,7 +1631,7 @@ protected function execute_lua_script( $script ) {
1627
1631
}
1628
1632
1629
1633
if ( $ this ->is_predis () ) {
1630
- stream_set_timeout ( $ this -> redis -> getConnection () ->getResource (), $ timeout );
1634
+ stream_set_timeout ( $ connection ->getResource (), $ timeout );
1631
1635
} else {
1632
1636
$ this ->redis ->setOption ( Redis::OPT_READ_TIMEOUT , $ timeout );
1633
1637
}
You can’t perform that action at this time.
0 commit comments