Skip Navigation

[Resolved] Fatal error when viewing a single product

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 14 replies, has 3 voices.

Last updated by Nigel 3 months ago.

Assisted by: Minesh.

Author
Posts
#2710880

I am trying to: view a single product on the front end

Link to a page where the issue can be seen:
hidden link
I expected to see: The single product page front end

Instead, I got: the WordPress message "A critical error has occurred"

Debug.log:

[01-Aug-2024 11:38:36 UTC] PHP Fatal error: Uncaught TypeError: call_user_func_array(): Argument #1 ($callback) must be a valid callback, function "<div class="container">" not found or invalid function name in /home/mnn/public_html/wp-includes/class-wp-hook.php:324
Stack trace:
#0 /home/mnn/public_html/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters()
#1 /home/mnn/public_html/wp-includes/plugin.php(517): WP_Hook->do_action()
#2 /home/mnn/public_html/wp-content/plugins/woocommerce-views/library/toolset/woocommerce-views/templates/single-product.php(39): do_action()
#3 /home/mnn/public_html/wp-content/plugins/woocommerce-views/application/Templates/Loader.php(85): include_once('/home/mnn/publi...')
#4 /home/mnn/public_html/wp-content/plugins/woocommerce-views/application/Templates/Loader.php(54): WooViews\Templates\Loader->load()
#5 /home/mnn/public_html/wp-includes/class-wp-hook.php(324): WooViews\Templates\Loader->override()
#6 /home/mnn/public_html/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters()
#7 /home/mnn/public_html/wp-includes/plugin.php(517): WP_Hook->do_action()
#8 /home/mnn/public_html/wp-includes/template-loader.php(13): do_action()
#9 /home/mnn/public_html/wp-blog-header.php(19): require_once('/home/mnn/publi...')
#10 /home/mnn/public_html/index.php(17): require('/home/mnn/publi...')
#11 {main}
thrown in /home/mnn/public_html/wp-includes/class-wp-hook.php on line 324

This happened after upgrading the server to PHP 8.2.11

The files mentioned in the stack trace are all unaltered.

As this is a live site, I want to wait for the respons of the Support team before deciding about granting access or providing a duplicate.

#2710924

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

As you can see with our server requirement Doc:
- https://toolset.com/toolset-requirements/

Important notes:
We tested Toolset plugins up to PHP version 8.1. Issues may arise with PHP 8.2 and we deal with them as they are reported.

So, this seems to be one of the case.

However - do you know how to reproduce the issue with brand new WordPress installation with only Toolset plugins active?

Could you please try to resolve your issue by deactivating all third-party plugins as well as the default theme to check for any possible conflicts with any of the plugins or themes?
- Do you see any difference?

Do you have any information how to reproduce the issue? If no:

*** Please make a FULL BACKUP of your database and website.***

I will require duplicator package and steps in order to see the issue.

More info:
=> https://toolset.com/faq/provide-supporters-copy-site/

I have set the next reply to private which means only you and I have access to it.

#2711299

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

I would like to take your permission - Can I take duplicator copy of your site? or can you send me duplicator copy of your site?

More info:
=> https://toolset.com/faq/provide-supporters-copy-site/

I have set the next reply to private which means only you and I have access to it.

#2712902

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

I checked and I see the same thing what you noticed.

It seems to be theme issue with WordPress Version. I do not have any input on this as its working as expected with default twentytwentytwo theme. If I downgrade the WordPress version to 5.x.x I can see the page working as expected.

There is nothing much I can do here as you will have to play with this and update the theme code as required that should work with current latest WordPress version.

#2712904

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

I checked and I see the same thing what you noticed.

It seems to be theme issue with WordPress Version. I do not have any input on this as its working as expected with default twentytwentytwo theme. If I downgrade the WordPress version to 5.x.x I can see the page working as expected.

There is nothing much I can do here as you will have to play with this and update the theme code as required that should work with current latest WordPress version.

#2712905

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

I checked and I see the same thing what you noticed.

It seems to be theme issue with WordPress Version. I do not have any input on this as its working as expected with default twentytwentytwo theme. If I downgrade the WordPress version to 5.x.x I can see the page working as expected.

There is nothing much I can do here as you will have to play with this and update the theme code as required that should work with current latest WordPress version.

#2712906

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

I checked and I see the same thing what you noticed.

It seems to be theme issue with WordPress Version. I do not have any input on this as its working as expected with default twentytwentytwo theme. If I downgrade the WordPress version to 5.x.x I can see the page working as expected.

There is nothing much I can do here as you will have to play with this and update the theme code as required that should work with current latest WordPress version.

#2712907

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

I checked and I see the same thing what you noticed.

It seems to be theme issue with WordPress Version. I do not have any input on this as its working as expected with default twentytwentytwo theme. If I downgrade the WordPress version to 5.x.x I can see the page working as expected.

There is nothing much I can do here as you will have to play with this and update the theme code as required that should work with current latest WordPress version.

#2712914

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

I checked and I see the same thing what you noticed.

It seems to be theme issue with WordPress Version. I do not have any input on this as its working as expected with default twentytwentytwo theme. If I downgrade the WordPress version to 5.x.x I can see the page working as expected.

There is nothing much I can do here as you will have to play with this and update the theme code as required that should work with current latest WordPress version.

#2714994
3 do_action calls commented out.png
Template header of single-product.php.png

As the theme used for this site is Minimax, which was provided by Toolset, I was hoping you could help me solving this issue. Could you perhaps point me in the direction where I should update the theme code?

By the way, I found out that the template single-product.php located in plugins/woocomerce-views/library/toolset/woocommerce-views/templates/single-product.php when copied to the themefolder themes/minimax/woocommerce/single-product.php is not overridden by the copy, as it should be according to the template header (see screenshot).

I did comment the 3 lines with do_action() calls in the Template copy in my theme Minimax/woocommerce/single-product.php (see screenshot)but the fatal error persisted and mentioned in the stack trace that the template was still loaded from the original loocation plugins/woocomerce-views/library/toolset/woocommerce-views/templates/single-product.php.

After I changed the filename of the template in this original location plugins/woocomerce-views/library/toolset/woocommerce-views/templates/single-product.php~ AND with the outcommented 3 do_action() calls applied in the template copy in minimax/woocommerce/single-product.php the error is gone and the product displays correctly at the front side.

So I have 2 additional questions:
1. Why doesn't the override work?
2. Why do the do_action() calls cause the fatal error?

#2715775

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

So I have 2 additional questions:
1. Why doesn't the override work?
2. Why do the do_action() calls cause the fatal error?
=====>
I'm not sure but it happens due to the latest WordPress version.

Because WordPress is moving in the direction of Gutenberg block editor, we are supporting that shift by making it possible to design Content Templates using Gutenberg blocks, which might be a good substitute for Layouts.

You can see the old blog post here:
- https://toolset.com/2019/04/toolset-blocks-visual-design-dynamic-content/

In current situation - I would like to inform you that Toolset Layouts plugin is on maintenance mode, that means we are not going to add any new features to it and hence I suggest you should go with Toolset content template instead of using Toolset Layouts.

Sooner or later you will have to take this decision so may be it would be good if you take now and use the Content template instead of Layouts. You may acknowledge that the fix may take longer time then expected due to pre-defined priorities.

You may use the following things as reference:
- https://toolset.com/course/custom-woocommerce-sites
- https://discover-wp.com/site-types/toolset-blocks-and-woocommerce

If you still want to stick with Toolset Layouts - then you can expect such possible error in future as well due to updates of WordPress or PHP.

So - please let us know if you still stick with Layouts or switch to content templates.

#2715778

I am not at all satisfied with this answer. This means backwards compatibility has been abandoned by Toolset, while I have built many client sites with Layouts, sites that are still running. It would be an enormous amount of work to rebuild all those sites in blocks.

And then: what guarantee would I have that a company that abandoned it's backwards compatibility promises of the past won't do the same again in the future?

Very disappointing.

#2715779

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Ok - in that case I will take this to next steps and check what we can do. We are bound to offer hotfixes for Toolset Layouts so there is no worries. It was just to inform you that there is new way to build the site using content templates instead of using Layouts plugin that is put into maintenance mode. Maintenance mode does not mean that we will not support it.

Please hold on for further updates as I will have to troubleshoot in depth and escalate it in front of our next level support.

I will get in touch with you as soon as I've update on this.

#2717895

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

I suspect this looks like the issue from the minimax theme you used, however - I've escalated the issue in front of our next level support.

Please hold on until further updates.

#2724569

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi Erik

Minesh is on vacation, let me step in here.

The problem only occurs with the MiniMax1 theme, not with the Toolset Starter Theme, for example.

On the test site Minesh prepared I don't know if the copy of the MiniMax1 theme is the original theme or an edited version, but, in any case, the problem arises because of some poor coding in the functions.php file.

Edit the theme's functions.php file and locate these lines:

	/* 
	 * Then hook in our own functions to display the wrappers our theme requires:
	 */
	add_action('woocommerce_before_main_content', '<div class="container">', 10);
	add_action('woocommerce_after_main_content', '</div><!-- #container -->', 10);

Deleting those will solve the errors, though you may want to edit them so that you add a callback function to each line instead of HTML markup.

See https://developer.wordpress.org/plugins/hooks/