Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Attempt to read property "content" in JetpackWooCommerceAnalytics.php #11750

Closed
Lockoloop opened this issue Nov 13, 2023 · 1 comment
Closed
Labels
type: bug The issue/PR concerns a confirmed bug. type: community contribution

Comments

@Lockoloop
Copy link

Lockoloop commented Nov 13, 2023

Describe the bug

Tested with theme 2023, with all plugins turned off except for Woocommerce and Woocommerce Blocks.

I used to get a warning once a day, each time I would land on my homepage for the first time of the day.
Warning: Undefined array key 1 woo-gutenberg-products-block/src/BlockTemplatesController.php on line 184 as well.
It was accompanied of 4 warnings regarding Jetpack:
Attempt to read property “content” on null in /jetpack/modules/woocommerce-analytics/classes/class-jetpack-woocommerce-analytics-trait.php on lines 219, 220, 221, 222


Now, I'm guessing due to a recent update of Blocks, the warning "Undefined array key 1" has disappeared, and the other error messages are not linked to the Jetpack plugin but link to a new file in Blocks. However, the code is pretty similar:

Attempt to read property "content" on null in /woo-gutenberg-products-block/src/Domain/Services/JetpackWooCommerceAnalytics.php on lines [282, 283, 284, 285, 287, 291]

These are the incriminated lines:

$info = array(
			'cart_page_contains_cart_block'             => str_contains( $cart_template->content, '<!-- wp:woocommerce/cart' ),
			'cart_page_contains_cart_shortcode'         => str_contains( $cart_template->content, '[woocommerce_cart]' ),
			'checkout_page_contains_checkout_block'     => str_contains( $checkout_template->content, '<!-- wp:woocommerce/checkout' ),
			'checkout_page_contains_checkout_shortcode' => str_contains( $checkout_template->content, '[woocommerce_checkout]' ),
			'additional_blocks_on_cart_page'            => $this->get_additional_blocks(
				$cart_template->content,
				array( 'woocommerce/cart' )
			),
			'additional_blocks_on_checkout_page'        => $this->get_additional_blocks(
				$checkout_template->content,
				array( 'woocommerce/checkout' )
			),

Here a link to the old issue:
https://wordpress.org/support/topic/undefined-array-key-1-in-blocktemplatescontroller-php

To reproduce

  1. Go to the homepage
  2. See error in backend
  3. Only happens once a day

Expected behavior

No error

WordPress (please complete the following information):

  • WordPress version: 6.4
  • WooCommerce version: 8.2.2
  • WooCommerce Blocks version: 11.5.1
@opr
Copy link
Contributor

opr commented Nov 14, 2023

This is fixed by #11707

@opr opr closed this as completed Nov 14, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: bug The issue/PR concerns a confirmed bug. type: community contribution
Projects
None yet
Development

No branches or pull requests

2 participants