From 053b59a9336ac5211b5772ccb58407caf62232cd Mon Sep 17 00:00:00 2001 From: Stefan Kalscheuer Date: Fri, 29 Mar 2024 13:37:24 +0100 Subject: [PATCH] fix some inconsistent return values --- inc/class-cachify-apc.php | 2 +- inc/class-cachify-db.php | 11 ++++++----- inc/class-cachify-hdd.php | 6 +++--- inc/class-cachify-memcached.php | 4 ++-- inc/class-cachify-redis.php | 2 +- inc/class-cachify.php | 2 +- 6 files changed, 14 insertions(+), 13 deletions(-) diff --git a/inc/class-cachify-apc.php b/inc/class-cachify-apc.php index 0e8c17c9..7992e54c 100644 --- a/inc/class-cachify-apc.php +++ b/inc/class-cachify-apc.php @@ -105,7 +105,7 @@ public static function clear_cache() { * @since 2.0 */ public static function print_cache() { - return; + // Not supported. } /** diff --git a/inc/class-cachify-db.php b/inc/class-cachify-db.php index 003c0394..ddbb9b6f 100644 --- a/inc/class-cachify-db.php +++ b/inc/class-cachify-db.php @@ -146,9 +146,10 @@ public static function get_stats() { global $wpdb; /* Read */ - - return $wpdb->get_var( - 'SELECT SUM( CHAR_LENGTH(option_value) ) FROM `' . $wpdb->options . "` WHERE `option_name` LIKE ('\_transient%.cachify')" + return intval( + $wpdb->get_var( + 'SELECT SUM( CHAR_LENGTH(option_value) ) FROM `' . $wpdb->options . "` WHERE `option_name` LIKE ('\_transient%.cachify')" + ) ); } @@ -166,7 +167,7 @@ public static function get_stats() { private static function _cache_signature( $detail, $meta ) { /* No array? */ if ( ! is_array( $meta ) ) { - return; + return ''; } if ( $detail ) { @@ -218,7 +219,7 @@ private static function _page_queries() { /** * Return execution time * - * @return int Execution time in seconds + * @return string Execution time in seconds * * @since 0.1 */ diff --git a/inc/class-cachify-hdd.php b/inc/class-cachify-hdd.php index 04e6a887..361e8f0b 100644 --- a/inc/class-cachify-hdd.php +++ b/inc/class-cachify-hdd.php @@ -275,14 +275,14 @@ private static function _clear_dir( $dir, $recursive = false ) { * * @param string $dir Directory path. * - * @return mixed Directory size + * @return int|false Directory size * * @since 2.0 */ public static function _dir_size( $dir = '.' ) { /* Is directory? */ if ( ! is_dir( $dir ) ) { - return; + return false; } /* Read */ @@ -293,7 +293,7 @@ public static function _dir_size( $dir = '.' ) { /* Empty? */ if ( empty( $objects ) ) { - return; + return false; } /* Init */ diff --git a/inc/class-cachify-memcached.php b/inc/class-cachify-memcached.php index cc5be81f..88d536a2 100644 --- a/inc/class-cachify-memcached.php +++ b/inc/class-cachify-memcached.php @@ -89,7 +89,7 @@ public static function store_item( $hash, $data, $lifetime, $sig_detail ) { public static function get_item( $hash ) { /* Server connect */ if ( ! self::_connect_server() ) { - return; + return null; } /* Get item */ @@ -143,7 +143,7 @@ public static function clear_cache() { * @since 2.0.7 */ public static function print_cache() { - return; + // Not supported. } /** diff --git a/inc/class-cachify-redis.php b/inc/class-cachify-redis.php index df29673d..d32c1a5b 100644 --- a/inc/class-cachify-redis.php +++ b/inc/class-cachify-redis.php @@ -77,7 +77,7 @@ public static function store_item( $hash, $data, $lifetime, $sig_detail ) { public static function get_item( $hash ) { /* Server connect */ if ( ! self::_connect_server() ) { - return; + return null; } /* Get item */ diff --git a/inc/class-cachify.php b/inc/class-cachify.php index 4a709357..52aee24c 100644 --- a/inc/class-cachify.php +++ b/inc/class-cachify.php @@ -874,7 +874,7 @@ public static function flush_cache() { public static function flush_notice() { /* No admin */ if ( ! is_admin_bar_showing() || ! apply_filters( 'cachify_user_can_flush_cache', current_user_can( 'manage_options' ) ) ) { - return false; + return; } printf(