From 2a5cb2fd154991f54214110b80deaae2136a51a4 Mon Sep 17 00:00:00 2001 From: Dimitrios Pantazis Date: Wed, 29 Jan 2025 18:17:42 +0200 Subject: [PATCH 1/4] Fix init of TC module --- src/Tickets/Commerce/Provider.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Tickets/Commerce/Provider.php b/src/Tickets/Commerce/Provider.php index 108a5f80f7..0d96410d1e 100644 --- a/src/Tickets/Commerce/Provider.php +++ b/src/Tickets/Commerce/Provider.php @@ -61,6 +61,9 @@ public function register() { $this->container->singleton( Notice_Handler::class ); $this->container->singleton( Module::class ); + // We need to init for the registration as a module to take place early. + $this->container->get( Module::class ); + $this->container->singleton( Attendee::class ); $this->container->singleton( Order::class ); $this->container->singleton( Ticket::class ); From b747df1b71f4fe02cd66158760488bb2f2d817c6 Mon Sep 17 00:00:00 2001 From: Dimitrios Pantazis Date: Wed, 29 Jan 2025 18:24:04 +0200 Subject: [PATCH 2/4] added changelog --- changelog/fix-init-of-tc-module | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 changelog/fix-init-of-tc-module diff --git a/changelog/fix-init-of-tc-module b/changelog/fix-init-of-tc-module new file mode 100644 index 0000000000..8a63044f59 --- /dev/null +++ b/changelog/fix-init-of-tc-module @@ -0,0 +1,4 @@ +Significance: patch +Type: tweak + +Init TicketsCommerce Module as soon as possible. [ETP-972] From 19cfbc601fdb20e30ba6eb0bc014d2caed2a0a9f Mon Sep 17 00:00:00 2001 From: Dimitrios Pantazis Date: Wed, 29 Jan 2025 18:30:51 +0200 Subject: [PATCH 3/4] Added testcase to cover it --- .../_Load/CommerceModuleLoaded_Test.php | 13 +++++++++++++ tests/commerce_integration/_bootstrap.php | 1 - 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 tests/commerce_integration/_Load/CommerceModuleLoaded_Test.php diff --git a/tests/commerce_integration/_Load/CommerceModuleLoaded_Test.php b/tests/commerce_integration/_Load/CommerceModuleLoaded_Test.php new file mode 100644 index 0000000000..94d1440a95 --- /dev/null +++ b/tests/commerce_integration/_Load/CommerceModuleLoaded_Test.php @@ -0,0 +1,13 @@ +assertArrayHasKey( Module::class, Tickets::modules() ); + } +} diff --git a/tests/commerce_integration/_bootstrap.php b/tests/commerce_integration/_bootstrap.php index 08f855595a..a88ef8530a 100644 --- a/tests/commerce_integration/_bootstrap.php +++ b/tests/commerce_integration/_bootstrap.php @@ -1,7 +1,6 @@ Date: Wed, 29 Jan 2025 19:01:09 +0200 Subject: [PATCH 4/4] deprecate on-demand load of Module --- src/Tickets/Commerce/Hooks.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Tickets/Commerce/Hooks.php b/src/Tickets/Commerce/Hooks.php index 6b99b0f624..deab716989 100644 --- a/src/Tickets/Commerce/Hooks.php +++ b/src/Tickets/Commerce/Hooks.php @@ -65,8 +65,6 @@ protected function add_actions() { // Compatibility Hooks add_action( 'init', [ $this, 'register_event_compatibility_hooks' ] ); - add_action( 'tribe_common_loaded', [ $this, 'load_commerce_module' ] ); - add_action( 'template_redirect', [ $this, 'do_cart_parse_request' ] ); add_action( 'template_redirect', [ $this, 'do_checkout_parse_request' ] ); @@ -482,9 +480,11 @@ public function filter_payments_tab_settings( $settings ) { * Initializes the Module Class. * * @since 5.1.9 + * + * @deprecated TBD */ public function load_commerce_module() { - $this->container->make( Module::class ); + _deprecated_function( __METHOD__, 'TBD' ); } /**