From 0d181cf97fb0d419c9b7aa354085d30837964087 Mon Sep 17 00:00:00 2001 From: Kruti Dugade Date: Mon, 7 Aug 2023 19:29:32 +0100 Subject: [PATCH 1/7] Fixes dynamic property creation deprecation errors found during PHP8.2 compatibility testing. --- class-wc-facebookcommerce.php | 6 ++++++ facebook-commerce-messenger-chat.php | 6 ++++++ facebook-commerce.php | 9 +++++++++ includes/Admin.php | 2 ++ includes/fbbackground.php | 5 +++++ 5 files changed, 28 insertions(+) diff --git a/class-wc-facebookcommerce.php b/class-wc-facebookcommerce.php index 09f3b976b..02ec386c3 100644 --- a/class-wc-facebookcommerce.php +++ b/class-wc-facebookcommerce.php @@ -106,6 +106,12 @@ class WC_Facebookcommerce extends WooCommerce\Facebook\Framework\Plugin { /** @var WooCommerce\Facebook\ExternalVersionUpdate */ private $external_version_update; + /** @var WooCommerce\Facebook\Feed\FeedConfigurationDetection instance. */ + private $configuration_detection; + + /** @var WooCommerce\Facebook\Products\FBCategories instance. */ + private $fb_categories; + /** * The Debug tools instance. * diff --git a/facebook-commerce-messenger-chat.php b/facebook-commerce-messenger-chat.php index 56ea5152d..1b4330811 100755 --- a/facebook-commerce-messenger-chat.php +++ b/facebook-commerce-messenger-chat.php @@ -22,6 +22,12 @@ */ class WC_Facebookcommerce_MessengerChat { + /** @var Facebook Page ID. */ + private $page_id; + + /** @var JS SDK Version. */ + private $jssdk_version; + /** * Class constructor. * diff --git a/facebook-commerce.php b/facebook-commerce.php index db9c82518..22cd5f789 100644 --- a/facebook-commerce.php +++ b/facebook-commerce.php @@ -181,6 +181,15 @@ class WC_Facebookcommerce_Integration extends WC_Integration { /** @var WC_Facebookcommerce */ private $facebook_for_woocommerce; + /** @var WC_Facebookcommerce_EventsTracker instance. */ + private $events_tracker; + + /** @var WC_Facebookcommerce_MessengerChat instance. */ + private $messenger_chat; + + /** @var WC_Facebookcommerce_Background_Process instance. */ + private $background_processor; + /** * Init and hook in the integration. * diff --git a/includes/Admin.php b/includes/Admin.php index 7307e999a..5afc38dd5 100644 --- a/includes/Admin.php +++ b/includes/Admin.php @@ -39,6 +39,8 @@ class Admin { /** @var array screens ids where to include scripts */ protected $screen_ids = []; + /** @var Product_Sets the product set admin handler. */ + protected $product_sets; /** * Admin constructor. diff --git a/includes/fbbackground.php b/includes/fbbackground.php index 1bfceacfb..e04ab37f5 100644 --- a/includes/fbbackground.php +++ b/includes/fbbackground.php @@ -18,6 +18,11 @@ class WC_Facebookcommerce_Background_Process extends WP_Background_Process { + /** + * @var WC_Facebookcommerce_Integration instance. + */ + private $commerce; + public function __construct( $commerce ) { $this->commerce = $commerce; // Full WC_Facebookcommerce_Integration obj } From 9809f30863a8fb202bb1bc88fa92107e2a014a9e Mon Sep 17 00:00:00 2001 From: Kruti Dugade Date: Mon, 7 Aug 2023 20:41:31 +0100 Subject: [PATCH 2/7] Adds variable type in comment. --- facebook-commerce-messenger-chat.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/facebook-commerce-messenger-chat.php b/facebook-commerce-messenger-chat.php index 1b4330811..89e0aba97 100755 --- a/facebook-commerce-messenger-chat.php +++ b/facebook-commerce-messenger-chat.php @@ -22,10 +22,10 @@ */ class WC_Facebookcommerce_MessengerChat { - /** @var Facebook Page ID. */ + /** @var string Facebook Page ID. */ private $page_id; - /** @var JS SDK Version. */ + /** @var string|null JS SDK Version. */ private $jssdk_version; /** From 3c857a494d52534d6c878c4f7e6e7b8ea0f3f295 Mon Sep 17 00:00:00 2001 From: Kruti Dugade Date: Mon, 7 Aug 2023 23:07:54 +0100 Subject: [PATCH 3/7] Makes background_processor accessible in unit test with help of Reflection Class. --- tests/Unit/WCFacebookCommerceIntegrationTest.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/Unit/WCFacebookCommerceIntegrationTest.php b/tests/Unit/WCFacebookCommerceIntegrationTest.php index 968691072..5ccc626fa 100644 --- a/tests/Unit/WCFacebookCommerceIntegrationTest.php +++ b/tests/Unit/WCFacebookCommerceIntegrationTest.php @@ -218,7 +218,12 @@ function ( $use_pii ) { public function test_load_background_sync_process() { $this->integration->load_background_sync_process(); - $this->assertInstanceOf( WC_Facebookcommerce_Background_Process::class, $this->integration->background_processor ); + $ref = new \ReflectionClass( $this->integration ); + $background_processor_prop = $ref->getProperty( 'background_processor' ); + $background_processor_prop->setAccessible( true ); + $background_processor = $background_processor_prop->getValue( $this->integration ); + + $this->assertInstanceOf(WC_Facebookcommerce_Background_Process::class, $background_processor); $this->assertEquals( 10, has_action( From 2ac77bf036fdf85d6badafa8975b3ef59f79bb67 Mon Sep 17 00:00:00 2001 From: Kruti Dugade Date: Tue, 8 Aug 2023 15:12:19 +0100 Subject: [PATCH 4/7] Fixes dynamic property creation deprecation errors on All Products page for PHP8.2. --- includes/ProductSync/ProductValidator.php | 7 ++++ includes/fbproduct.php | 40 +++++++++++++++++++++++ 2 files changed, 47 insertions(+) diff --git a/includes/ProductSync/ProductValidator.php b/includes/ProductSync/ProductValidator.php index 77e3362fa..585881421 100644 --- a/includes/ProductSync/ProductValidator.php +++ b/includes/ProductSync/ProductValidator.php @@ -77,6 +77,13 @@ class ProductValidator { */ protected $fb_product_parent; + /** + * The product object to validate. + * + * @var WC_Facebook_Product + */ + protected $facebook_product; + /** * ProductValidator constructor. * diff --git a/includes/fbproduct.php b/includes/fbproduct.php index 2532c6419..b5e3185d5 100644 --- a/includes/fbproduct.php +++ b/includes/fbproduct.php @@ -48,6 +48,46 @@ class WC_Facebook_Product { 'variation' => 1, ); + /** + * @var int Facebook Product ID. + */ + protected $id; + + /** + * @var WC_Product + */ + protected $woo_product; + + /** + * @var string Facebook Product Description. + */ + protected $fb_description; + + /** + * @var array Gallery URLs. + */ + protected $gallery_urls; + + /** + * @var bool Use parent image for variable products. + */ + protected $fb_use_parent_image; + + /** + * @var string Product Description. + */ + protected $main_description; + + /** + * @var bool Sync short description. + */ + protected $sync_short_description; + + /** + * @var bool Product visibility on Facebook. + */ + protected $fb_visibility; + public function __construct( $wpid, $parent_product = null ) { if ( $wpid instanceof WC_Product ) { From 90aa3aa1b0b7a2650284d56d1b39de6356bd5bd5 Mon Sep 17 00:00:00 2001 From: Kruti Dugade Date: Tue, 8 Aug 2023 15:18:12 +0100 Subject: [PATCH 5/7] Makes properties private. --- includes/fbproduct.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/includes/fbproduct.php b/includes/fbproduct.php index b5e3185d5..fd2066fc1 100644 --- a/includes/fbproduct.php +++ b/includes/fbproduct.php @@ -61,27 +61,27 @@ class WC_Facebook_Product { /** * @var string Facebook Product Description. */ - protected $fb_description; + private $fb_description; /** * @var array Gallery URLs. */ - protected $gallery_urls; + private $gallery_urls; /** * @var bool Use parent image for variable products. */ - protected $fb_use_parent_image; + private $fb_use_parent_image; /** * @var string Product Description. */ - protected $main_description; + private $main_description; /** * @var bool Sync short description. */ - protected $sync_short_description; + private $sync_short_description; /** * @var bool Product visibility on Facebook. From d0a66acafea609f912beb082ccd861642b5dad7a Mon Sep 17 00:00:00 2001 From: Kruti Dugade Date: Tue, 8 Aug 2023 16:59:37 +0100 Subject: [PATCH 6/7] Changed fb_visibility and woo_product property access to public. --- includes/fbproduct.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/includes/fbproduct.php b/includes/fbproduct.php index fd2066fc1..c1a990075 100644 --- a/includes/fbproduct.php +++ b/includes/fbproduct.php @@ -49,14 +49,14 @@ class WC_Facebook_Product { ); /** - * @var int Facebook Product ID. + * @var int WC_Product ID. */ - protected $id; + private $id; /** * @var WC_Product */ - protected $woo_product; + public $woo_product; /** * @var string Facebook Product Description. @@ -86,7 +86,7 @@ class WC_Facebook_Product { /** * @var bool Product visibility on Facebook. */ - protected $fb_visibility; + public $fb_visibility; public function __construct( $wpid, $parent_product = null ) { From c35d94ff3d982efec428a286fe8cce58559b4551 Mon Sep 17 00:00:00 2001 From: Kruti Dugade Date: Tue, 8 Aug 2023 17:23:54 +0100 Subject: [PATCH 7/7] Eliminates dynamic property deprecation warnings with PHP8.2 for FB tab on Add New or Edit product page. --- .../Enhanced_Catalog_Attribute_Fields.php | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/includes/Admin/Enhanced_Catalog_Attribute_Fields.php b/includes/Admin/Enhanced_Catalog_Attribute_Fields.php index f31bd1c41..6bfff865f 100644 --- a/includes/Admin/Enhanced_Catalog_Attribute_Fields.php +++ b/includes/Admin/Enhanced_Catalog_Attribute_Fields.php @@ -27,6 +27,26 @@ class Enhanced_Catalog_Attribute_Fields { const PAGE_TYPE_ADD_CATEGORY = 'add_category'; const PAGE_TYPE_EDIT_PRODUCT = 'edit_product'; + /** + * @var string Facebook page type. + */ + private $page_type; + + /** + * @var \WP_Term + */ + private $term; + + /** + * @var \WC_Product + */ + private $product; + + /** + * @var \WooCommerce\Facebook\Products\FBCategories + */ + private $category_handler; + public function __construct( $page_type, \WP_Term $term = null, \WC_Product $product = null ) { $this->page_type = $page_type; $this->term = $term;