From b8dff97e00f437907795f2cdce71307fcac4737f Mon Sep 17 00:00:00 2001 From: Peter Fabian Date: Mon, 3 Dec 2018 14:44:43 +0100 Subject: [PATCH] Fixed PHP 5.2 compatibility. --- .../class-wc-admin-reports-categories-data-store.php | 10 ++++++++++ .../data-stores/class-wc-admin-reports-data-store.php | 11 ----------- .../class-wc-admin-reports-orders-data-store.php | 10 ++++++++++ .../class-wc-admin-reports-products-data-store.php | 10 ++++++++++ .../class-wc-admin-reports-variations-data-store.php | 10 ++++++++++ 5 files changed, 40 insertions(+), 11 deletions(-) diff --git a/plugins/woocommerce-admin/includes/data-stores/class-wc-admin-reports-categories-data-store.php b/plugins/woocommerce-admin/includes/data-stores/class-wc-admin-reports-categories-data-store.php index 087c20921f0..7e0d1def9fe 100644 --- a/plugins/woocommerce-admin/includes/data-stores/class-wc-admin-reports-categories-data-store.php +++ b/plugins/woocommerce-admin/includes/data-stores/class-wc-admin-reports-categories-data-store.php @@ -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 ) ); + } + } diff --git a/plugins/woocommerce-admin/includes/data-stores/class-wc-admin-reports-data-store.php b/plugins/woocommerce-admin/includes/data-stores/class-wc-admin-reports-data-store.php index 4d2eaf91140..69e98bc2844 100644 --- a/plugins/woocommerce-admin/includes/data-stores/class-wc-admin-reports-data-store.php +++ b/plugins/woocommerce-admin/includes/data-stores/class-wc-admin-reports-data-store.php @@ -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. * diff --git a/plugins/woocommerce-admin/includes/data-stores/class-wc-admin-reports-orders-data-store.php b/plugins/woocommerce-admin/includes/data-stores/class-wc-admin-reports-orders-data-store.php index a24e100a3a7..e12ff19bf59 100644 --- a/plugins/woocommerce-admin/includes/data-stores/class-wc-admin-reports-orders-data-store.php +++ b/plugins/woocommerce-admin/includes/data-stores/class-wc-admin-reports-orders-data-store.php @@ -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 ) ); + } } diff --git a/plugins/woocommerce-admin/includes/data-stores/class-wc-admin-reports-products-data-store.php b/plugins/woocommerce-admin/includes/data-stores/class-wc-admin-reports-products-data-store.php index 81e255abc2d..689151dbb3a 100644 --- a/plugins/woocommerce-admin/includes/data-stores/class-wc-admin-reports-products-data-store.php +++ b/plugins/woocommerce-admin/includes/data-stores/class-wc-admin-reports-products-data-store.php @@ -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 ) ); + } + } diff --git a/plugins/woocommerce-admin/includes/data-stores/class-wc-admin-reports-variations-data-store.php b/plugins/woocommerce-admin/includes/data-stores/class-wc-admin-reports-variations-data-store.php index 17fcb9273b6..82293913042 100644 --- a/plugins/woocommerce-admin/includes/data-stores/class-wc-admin-reports-variations-data-store.php +++ b/plugins/woocommerce-admin/includes/data-stores/class-wc-admin-reports-variations-data-store.php @@ -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 ) ); + } + }