Fixed PHP 5.2 compatibility.

This commit is contained in:
Peter Fabian 2018-12-03 14:44:43 +01:00
parent 6e68247701
commit b8dff97e00
5 changed files with 40 additions and 11 deletions

View File

@ -262,4 +262,14 @@ class WC_Admin_Reports_Categories_Data_Store extends WC_Admin_Reports_Data_Store
return $data;
}
/**
* Returns string to be used as cache key for the data.
*
* @param array $params Query parameters.
* @return string
*/
protected function get_cache_key( $params ) {
return 'woocommerce_' . self::TABLE_NAME . '_' . md5( wp_json_encode( $params ) );
}
}

View File

@ -282,17 +282,6 @@ class WC_Admin_Reports_Data_Store {
}
}
/**
* Returns string to be used as cache key for the data.
*
* @param array $params Query parameters.
* @return string
*/
protected function get_cache_key( $params ) {
// TODO: this is not working in PHP 5.2 (but revenue class has static methods, so it cannot use object property).
return 'woocommerce_' . $this::TABLE_NAME . '_' . md5( wp_json_encode( $params ) ); // phpcs:ignore PHPCompatibility.Syntax.NewDynamicAccessToStatic
}
/**
* Casts strings returned from the database to appropriate data types for output.
*

View File

@ -531,4 +531,14 @@ class WC_Admin_Reports_Orders_Data_Store extends WC_Admin_Reports_Data_Store imp
return count( $customer_orders ) > 1;
}
/**
* Returns string to be used as cache key for the data.
*
* @param array $params Query parameters.
* @return string
*/
protected function get_cache_key( $params ) {
return 'woocommerce_' . self::TABLE_NAME . '_' . md5( wp_json_encode( $params ) );
}
}

View File

@ -261,4 +261,14 @@ class WC_Admin_Reports_Products_Data_Store extends WC_Admin_Reports_Data_Store i
return $data;
}
/**
* Returns string to be used as cache key for the data.
*
* @param array $params Query parameters.
* @return string
*/
protected function get_cache_key( $params ) {
return 'woocommerce_' . self::TABLE_NAME . '_' . md5( wp_json_encode( $params ) );
}
}

View File

@ -261,4 +261,14 @@ class WC_Admin_Reports_Variations_Data_Store extends WC_Admin_Reports_Data_Store
return $data;
}
/**
* Returns string to be used as cache key for the data.
*
* @param array $params Query parameters.
* @return string
*/
protected function get_cache_key( $params ) {
return 'woocommerce_' . self::TABLE_NAME . '_' . md5( wp_json_encode( $params ) );
}
}