Skip to content

Commit 051cae3

Browse files
committed
Cache: Ensure wp_using_ext_object_cache() returns a boolean
1 parent 4d3b0b9 commit 051cae3

1 file changed

Lines changed: 11 additions & 6 deletions

File tree

src/wp-includes/load.php

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -808,15 +808,20 @@ function wp_set_wpdb_vars() {
808808
* @return bool The current 'using' setting.
809809
*/
810810
function wp_using_ext_object_cache( $using = null ) {
811-
global $_wp_using_ext_object_cache;
811+
global $_wp_using_ext_object_cache;
812812

813-
$current_using = $_wp_using_ext_object_cache;
813+
// Save the current state to return later.
814+
$current_using = $_wp_using_ext_object_cache;
814815

815-
if ( null !== $using ) {
816-
$_wp_using_ext_object_cache = $using;
817-
}
816+
if ( null !== $using ) {
817+
$_wp_using_ext_object_cache = (bool) $using;
818+
}
818819

819-
return $current_using;
820+
/**
821+
* Ensure the returned value is always a boolean.
822+
* If the global is uninitialized, it could be null, which violates the type signature.
823+
*/
824+
return (bool) $current_using;
820825
}
821826

822827
/**

0 commit comments

Comments
 (0)