From a3cc5cc9bb5a0cee18c39fa2707c3c60e05f0c32 Mon Sep 17 00:00:00 2001 From: Mike Jolley Date: Tue, 14 Mar 2017 16:49:13 +0000 Subject: [PATCH] has_meta -> meta_exists #13590 Avoid has_meta conflict with old method. #13581 --- includes/abstracts/abstract-wc-data.php | 2 +- includes/legacy/abstract-wc-legacy-order.php | 8 ++------ tests/unit-tests/crud/data.php | 6 +++--- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/includes/abstracts/abstract-wc-data.php b/includes/abstracts/abstract-wc-data.php index 30b9ca5ac38..72fc56b93b7 100644 --- a/includes/abstracts/abstract-wc-data.php +++ b/includes/abstracts/abstract-wc-data.php @@ -263,7 +263,7 @@ abstract class WC_Data { * @param string $key * @return boolean */ - public function has_meta( $key = '' ) { + public function meta_exists( $key = '' ) { $this->maybe_read_meta_data(); $array_keys = wp_list_pluck( $this->get_meta_data(), 'key' ); return in_array( $key, $array_keys ); diff --git a/includes/legacy/abstract-wc-legacy-order.php b/includes/legacy/abstract-wc-legacy-order.php index c3032653eed..e1f6ca17239 100644 --- a/includes/legacy/abstract-wc-legacy-order.php +++ b/includes/legacy/abstract-wc-legacy-order.php @@ -462,13 +462,9 @@ abstract class WC_Abstract_Legacy_Order extends WC_Data { * version and should be removed in future versions. * * @deprecated - * @return boolean|array of meta data. + * @return array of meta data. */ - public function has_meta( $key = '' ) { - if ( ! is_numeric( $key ) ) { - return parent::has_meta( $key ); - } - + public function has_meta( $order_item_id ) { global $wpdb; wc_deprecated_function( 'WC_Order::has_meta( $order_item_id )', '2.7', 'WC_Order_item::get_meta_data' ); diff --git a/tests/unit-tests/crud/data.php b/tests/unit-tests/crud/data.php index a48dcaba431..00e32864113 100644 --- a/tests/unit-tests/crud/data.php +++ b/tests/unit-tests/crud/data.php @@ -132,9 +132,9 @@ class WC_Tests_CRUD_Data extends WC_Unit_Test_Case { $object->save_meta_data(); $object = new WC_Mock_WC_Data( $object_id ); - $this->assertTrue( $object->has_meta( 'test_meta_key' ) ); - $this->assertTrue( $object->has_meta( 'test_multi_meta_key' ) ); - $this->assertFalse( $object->has_meta( 'thiskeyisnothere' ) ); + $this->assertTrue( $object->meta_exists( 'test_meta_key' ) ); + $this->assertTrue( $object->meta_exists( 'test_multi_meta_key' ) ); + $this->assertFalse( $object->meta_exists( 'thiskeyisnothere' ) ); } /**