Skip to content

Commit

Permalink
fix some inconsistent return values
Browse files Browse the repository at this point in the history
  • Loading branch information
stklcode committed Mar 29, 2024
1 parent 87b5b03 commit 053b59a
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 13 deletions.
2 changes: 1 addition & 1 deletion inc/class-cachify-apc.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public static function clear_cache() {
* @since 2.0
*/
public static function print_cache() {
return;
// Not supported.
}

/**
Expand Down
11 changes: 6 additions & 5 deletions inc/class-cachify-db.php
Original file line number Diff line number Diff line change
Expand Up @@ -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')"
)
);
}

Expand All @@ -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 ) {
Expand Down Expand Up @@ -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
*/
Expand Down
6 changes: 3 additions & 3 deletions inc/class-cachify-hdd.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand All @@ -293,7 +293,7 @@ public static function _dir_size( $dir = '.' ) {

/* Empty? */
if ( empty( $objects ) ) {
return;
return false;
}

/* Init */
Expand Down
4 changes: 2 additions & 2 deletions inc/class-cachify-memcached.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -143,7 +143,7 @@ public static function clear_cache() {
* @since 2.0.7
*/
public static function print_cache() {
return;
// Not supported.
}

/**
Expand Down
2 changes: 1 addition & 1 deletion inc/class-cachify-redis.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
2 changes: 1 addition & 1 deletion inc/class-cachify.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 053b59a

Please sign in to comment.