Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Elementor Pro - Fatal Uncaught TypeError caused by empty settings in Loop Grid widget #27212

Open
6 tasks done
amyriounis opened this issue May 2, 2024 · 0 comments
Open
6 tasks done
Labels
status/awaiting_triage Indicates when an Issue, Pull Request, or Discussion awaits to be triaged.

Comments

@amyriounis
Copy link

amyriounis commented May 2, 2024

Prerequisites

  • I have searched for similar issues in open and closed tickets and cannot find a duplicate.
  • I have troubleshooted my issue, and it still exists against the latest stable version of Elementor.

Description

If in the loop-grid widget the "Items Per Page" or "Columns" settings are set to no value it will lead to a fatal Uncaught TypeError in /elementor-pro/modules/woocommerce/module.php at line 1601 inside the adjust_setting_for_product_renderer() function. This is because the ceil() function will be called with a string parameter instead of numeric.

ewf432

rtr45g

Possible solutions:

  • The settings should not be allowed to be left to empty value (i.e. required settings).
  • Switch the isset() to ! empty() since probably the 0 numeric value wouldn't make any difference to the rows calculation.
  • The empty string value should get a numeric representation if it's somehow meaningful to the rows calculation.
  • The if statement at line 1600 should check for empty string before trying to calculate the rows setting.

Here's the stack trace:

Fatal error: Uncaught TypeError: Unsupported operand types: int / string in ../wp-content/plugins/elementor-pro/modules/woocommerce/module.php:1601 Stack trace: #0 ../wp-content/plugins/elementor-pro/modules/woocommerce/module.php(1563): ElementorPro\Modules\Woocommerce\Module->adjust_setting_for_product_renderer() #1 ../wp-content/plugins/elementor-pro/modules/woocommerce/module.php(1553): ElementorPro\Modules\Woocommerce\Module->parse_loop_query_args() #2 ../wp-content/plugins/elementor-pro/modules/woocommerce/module.php(1504): ElementorPro\Modules\Woocommerce\Module->loop_query() #3 ../wp-includes/class-wp-hook.php(324): ElementorPro\Modules\Woocommerce\Module->ElementorPro\Modules\Woocommerce\{closure}() #4 ../wp-includes/plugin.php(205): WP_Hook->apply_filters() #5 ../wp-content/plugins/elementor-pro/modules/query-control/classes/elementor-post-query.php(154): apply_filters() #6 ../wp-content/plugins/elementor-pro/modules/query-control/classes/elementor-post-query.php(49): ElementorPro\Modules\QueryControl\Classes\Elementor_Post_Query->get_query_args() #7 ../wp-content/plugins/elementor-pro/modules/query-control/module.php(962): ElementorPro\Modules\QueryControl\Classes\Elementor_Post_Query->get_query() #8 ../wp-content/plugins/elementor-pro/modules/posts/widgets/posts.php(73): ElementorPro\Modules\QueryControl\Module->get_query() #9 ../wp-content/plugins/elementor-pro/modules/loop-builder/widgets/base.php(57): ElementorPro\Modules\Posts\Widgets\Posts->query_posts() #10 ../wp-content/plugins/elementor-pro/modules/posts/skins/skin-base.php(908): ElementorPro\Modules\LoopBuilder\Widgets\Base->query_posts() #11 ../wp-content/plugins/elementor-pro/modules/loop-builder/skins/skin-loop-base.php(123): ElementorPro\Modules\Posts\Skins\Skin_Base->render() #12 ../wp-content/plugins/elementor-pro/modules/woocommerce/skins/skin-loop-product.php(36): ElementorPro\Modules\LoopBuilder\Skins\Skin_Loop_Base->render() #13 ../wp-content/plugins/elementor/includes/base/skin-base.php(79): ElementorPro\Modules\WooCommerce\Skins\Skin_Loop_Product->render() #14 ../wp-content/plugins/elementor/includes/base/widget-base.php(632): Elementor\Skin_Base->render_by_mode() #15 ../wp-content/plugins/elementor/includes/base/widget-base.php(758): Elementor\Widget_Base->render_content() #16 ../wp-content/plugins/elementor/includes/base/element-base.php(551): Elementor\Widget_Base->get_raw_data() #17 ../wp-content/plugins/elementor/includes/base/element-base.php(551): Elementor\Element_Base->get_raw_data() #18 ../wp-content/plugins/elementor/core/base/document.php(1067): Elementor\Element_Base->get_raw_data() #19 ../wp-content/plugins/elementor/core/base/document.php(723): Elementor\Core\Base\Document->get_elements_raw_data() #20 ../wp-content/plugins/elementor/includes/base/controls-stack.php(1060): Elementor\Core\Base\Document->get_initial_config() #21 ../wp-content/plugins/elementor/core/editor/loader/common/editor-common-scripts-settings.php(37): Elementor\Controls_Stack->get_config() #22 ../wp-content/plugins/elementor/core/editor/loader/v1/editor-v1-loader.php(76): Elementor\Core\Editor\Loader\Common\Editor_Common_Scripts_Settings::get() #23 ../wp-content/plugins/elementor/core/editor/editor.php(358): Elementor\Core\Editor\Loader\V1\Editor_V1_Loader->enqueue_scripts() #24 ../wp-includes/class-wp-hook.php(324): Elementor\Core\Editor\Editor->enqueue_scripts() #25 ../wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters() #26 ../wp-includes/plugin.php(517): WP_Hook->do_action() #27 ../wp-includes/script-loader.php(2265): do_action() #28 ../wp-includes/class-wp-hook.php(324): wp_enqueue_scripts() #29 ../wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters() #30 ../wp-includes/plugin.php(517): WP_Hook->do_action() #31 ../wp-includes/general-template.php(3050): do_action() #32 ../wp-content/plugins/elementor/includes/editor-templates/editor-wrapper.php(31): wp_head() #33 ../wp-content/plugins/elementor/core/editor/loader/v1/editor-v1-loader.php(110): include('...') #34 ../wp-content/plugins/elementor/core/editor/editor.php(163): Elementor\Core\Editor\Loader\V1\Editor_V1_Loader->print_root_template() #35 ../wp-includes/class-wp-hook.php(324): Elementor\Core\Editor\Editor->init() #36 ../wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters() #37 ../wp-includes/plugin.php(517): WP_Hook->do_action() #38 ../wp-admin/admin.php(419): do_action() #39 ../wp-admin/post.php(12): require_once('...') #40 {main} thrown in ../wp-content/plugins/elementor-pro/modules/woocommerce/module.php on line 1601

Steps to reproduce

  1. Create a products template
  2. Add a loop-grid widget and use the products template
  3. Leave "Items per Page" or "Columns" setting empty
  4. Save and reload the editor page
  5. You should see the fatal.

Expected behavior

Expected behavior is for the code to not produce fatal errors and break people's sites.

Isolating the problem

  • This bug happens when only the Elementor (and Elementor Pro) plugins are active.
  • This bug happens with the Hello Elementor theme active.
  • I can reproduce this bug consistently by following the steps I described above.

Elementor System Info

Click to reveal
== Server Environment ==
	Operating System: Linux
	Software: Apache/2.4.59 (Ubuntu)
	MySQL version: (Ubuntu) v8.0.36
	PHP Version: 8.1.28
	PHP Memory Limit: 512M
	PHP Max Input Vars: 1000
	PHP Max Post Size: 8M
	GD Installed: No
	ZIP Installed: Yes
	Write Permissions: All right
	Elementor Library: Connected

== WordPress Environment ==
	Version: 6.5.2
	Site URL: http://test.demo.localhost
	Home URL: http://test.demo.localhost
	WP Multisite: No
	Max Upload Size: 2 MB
	Memory limit: 40M
	Max Memory limit: 512M
	Permalink Structure: /%year%/%monthnum%/%day%/%postname%/
	Language: en_US
	Timezone: 0
	Debug Mode: Active

== Theme ==
	Name: Hello Elementor
	Version: 3.0.1
	Author: Elementor Team
	Child Theme: No

== User ==
	Role: administrator
	WP Profile lang: en-US
	User Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36 Edg/124.0.0.0

== Active Plugins ==
	Elementor
		Version: 3.21.4
		Author: Elementor.com

	Elementor Pro
		Version: 3.21.2
		Author: Elementor.com

	WooCommerce
		Version: 8.8.3
		Author: Automattic


== Elements Usage ==
	
	header : 1
		button : 6
		call-to-action : 3
		container : 62
		fibosearch : 1
		heading : 7
		icon : 3
		icon-list : 1
		image : 10
		image-box : 1
		mega-menu : 2
		nav-menu : 7
		theme-site-logo : 2
		wc-categories : 4
		woocommerce-menu-cart : 2
	footer : 1
		button : 2
		container : 17
		divider : 1
		form : 1
		heading : 5
		nav-menu : 3
		social-icons : 1
		text-editor : 4
		theme-site-logo : 1
	page : 1
		button : 3
		container : 2
		heading : 1
		spacer : 1
		text-editor : 1
	popup : 3
		button : 6
		container : 8
		fibosearch : 1
		form : 1
		icon : 2
		login : 1
		spacer : 1
		text-editor : 2
		wc-categories : 1
	product : 1
		button : 4
		container : 10
		divider : 2
		heading : 5
		icon : 1
		loop-carousel : 3
		shortcode : 1
		spacer : 1
		text-editor : 1
		toggle : 1
		woocommerce-breadcrumb : 1
		woocommerce-notices : 1
		woocommerce-product-add-to-cart : 1
		woocommerce-product-additional-information : 1
		woocommerce-product-images : 1
		woocommerce-product-price : 1
		woocommerce-product-title : 1
	widget : 0
		spacer : 1
	wp-page : 29
		button : 29
		container : 162
		divider : 23
		form : 1
		heading : 65
		hotspot : 4
		icon : 14
		icon-box : 10
		icon-list : 1
		image : 19
		loop-carousel : 2
		loop-grid : 8
		sbi-widget : 1
		shortcode : 21
		slides : 1
		spacer : 4
		text-editor : 59
		theme-post-featured-image : 2
		wc-categories : 2
		wc-elements : 1
		woocommerce-cart : 1
		woocommerce-checkout-page : 1
		woocommerce-my-account : 1
		woocommerce-notices : 1
		woocommerce-product-price : 2
		woocommerce-purchase-summary : 1
		wp-widget-berocket_aapf_group : 6
	single-page : 3
		container : 9
		heading : 2
		spacer : 3
		theme-post-content : 3
		theme-post-title : 1
		woocommerce-breadcrumb : 2
	product-post : 0
		container : 7
		text-editor : 7
	product-archive : 1
		container : 5
		loop-grid : 1
		shortcode : 2
		spacer : 1
		theme-archive-title : 1
		woocommerce-breadcrumb : 1
		wp-widget-berocket_aapf_group : 1
	loop-item : 5
		container : 18
		heading : 8
		shortcode : 7
		theme-post-content : 1
		theme-post-featured-image : 4
		woocommerce-product-price : 3


== Settings ==
	
	cpt_support: post, page, product
	allow_tracking: yes
	unfiltered_files_upload: 1
	font_display: swap


== Features ==
	Custom Fonts: 0
	Custom Icons: 0

== Integrations ==
	
	woocommerce: Active


== Elementor Experiments ==
	Improved Asset Loading: Active by default
	Improved CSS Loading: Active
	Inline Font Icons: Active
	Additional Custom Breakpoints: Active
	admin_menu_rearrangement: Inactive by default
	Flexbox Container: Active
	Upgrade Swiper Library: Active
	Grid Container: Inactive
	Nested Elements Performance: Inactive by default
	Optimized Control Loading: Inactive
	Default to New Theme Builder: Active by default
	Hello Theme Header & Footer: Active by default
	Elementor Home Screen: Active by default
	Editor Top Bar: Inactive
	Build with AI: Inactive
	Landing Pages: Inactive
	Nested Elements: Active
	Lazy Load Background Images: Inactive
	Display Conditions: Inactive
	Form Submissions: Active by default
	Menu: Active
	Taxonomy Filter: Inactive


== Log ==
	


== Elementor - Compatibility Tag ==
	
	Elementor Pro: Compatible

== Elementor Pro - Compatibility Tag ==

Agreement

  • I agree that my issue may be closed without action if it doesn't meet all the requirements.
@amyriounis amyriounis added the status/awaiting_triage Indicates when an Issue, Pull Request, or Discussion awaits to be triaged. label May 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status/awaiting_triage Indicates when an Issue, Pull Request, or Discussion awaits to be triaged.
Projects
None yet
Development

No branches or pull requests

1 participant