Skip Navigation

[Resolved] Fatal Error

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.

This topic contains 10 replies, has 2 voices.

Last updated by Christopher Amirian 1 year, 8 months ago.

Assisted by: Christopher Amirian.

Author
Posts
#2586905
Screenshot 2023-04-04 122558.png

I am trying to:
edit a brand

Link to a page where the issue can be seen:
(hidden link)

I expected to see:
the typical admin dashboard for toolset types.

Instead, I got:
a blank screen

Une erreur de type E_ERROR a été causée dans la ligne 193 du fichier /home/qcac/webapps/qcac/public/wp-content/plugins/types/application/controllers/utils/utils.php. Message d’erreur : Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, null given in /home/qcac/webapps/qcac/public/wp-content/plugins/types/application/controllers/utils/utils.php:193
Stack trace:
#0 /home/qcac/webapps/qcac/public/wp-content/plugins/types/vendor/toolset/types/embedded/classes/gui/term_field_editing.php(414): Types_Utils::insert_at_position()
#1 /home/qcac/webapps/qcac/public/wp-includes/class-wp-hook.php(308): WPCF_GUI_Term_Field_Editing->manage_term_listing_columns()
#2 /home/qcac/webapps/qcac/public/wp-includes/plugin.php(205): WP_Hook->apply_filters()
#3 /home/qcac/webapps/qcac/public/wp-admin/includes/screen.php(37): apply_filters()
#4 /home/qcac/webapps/qcac/public/wp-admin/includes/class-wp-screen.php(998): get_column_headers()
#5 /home/qcac/webapps/qcac/public/wp-admin/includes/class-wp-screen.php(959): WP_Screen->show_screen_options()
#6 /home/qcac/webapps/qcac/public/wp-admin/admin-header.php(281): WP_Screen->render_screen_meta()
#7 /home/qcac/webapps/qcac/public/wp-admin/term.php(73): require_once('...')
#8 {main}
thrown

#2587347

Christopher Amirian
Supporter

Languages: English (English )

Hi there,

The error that you have shared seems to be related to a bad data added that causes the exception, but to make sure that we do the troubleshooting steps correctly, I'd appreciate it that you check the steps below first:

- IMPORTANT STEP! Create a backup of your website, or it is better to have a staging version of the website
- Switch to the default theme such as "TwentyTwenty" by going to "WordPress Dashboard > Appearance > themes".
- Go to "WordPress Dashboard > Plugins" and deactivate all plugins except Toolset and its add-ons.
- Check if you can still recreate the issue.
- If not, re-activate your plugins one by one and check the issue each time to find out the plugin that causes the problem.

If the problem persists, I'd appreciate it if you could give me the URL/User/Pass of your WordPress dashboard after you make sure that you have a backup of your website.
It is absolutely important that you give us a guarantee that you have a backup so if something happens you will have a point of restore.

Make sure you set the next reply as private.

Also, we will need your permission to copy your website to our server.

Thanks.

#2592157
Screenshot 2023-04-12 115315.png
Screenshot 2023-04-12 115253.png

Hello,

I took the time to change the Theme, and deactivate all plugins aside from the necessary to test

  • Toolset Types
  • WooCommerce
  • WooCommerce Brands

The error occurs when attempting to edit a Product `Brands`

We are still getting the same error:

PHP Fatal error: Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, null given in /var/www/html/site/public_html/wp-content/plugins/types/application/controllers/utils/utils.php:193
Stack trace:
#0 /var/www/html/site/public_html/wp-content/plugins/types/vendor/toolset/types/embedded/classes/gui/term_field_editing.php(414): Types_Utils::insert_at_position(NULL, Array, -1)
#1 /var/www/html/site/public_html/wp-includes/class-wp-hook.php(308): WPCF_GUI_Term_Field_Editing->manage_term_listing_columns(NULL)
#2 /var/www/html/site/public_html/wp-includes/plugin.php(205): WP_Hook->apply_filters(NULL, Array)
#3 /var/www/html/site/public_html/wp-admin/includes/screen.php(37): apply_filters('manage_edit-pro...', Array)
#4 /var/www/html/site/public_html/wp-admin/includes/class-wp-screen.php(998): get_column_headers(Object(WP_Screen))
#5 /var/www/html/site/public_html/wp-admin/includes/class-wp-screen.php(959): WP_Screen->show_screen_options()
#6 /var/www/html/site/public_html/wp-admin/admin-header.php(281): WP_Screen->render_screen_meta()
#7 /var/www/html/site/public_html/wp-admin/term.php(73): require_once('/var/www/html/s...')
#8 {main}
thrown in /var/www/html/site/public_html/wp-content/plugins/types/application/controllers/utils/utils.php on line 193

#2592731

Christopher Amirian
Supporter

Languages: English (English )

Hi there,

Thank you for the check, so this is a compatibility issue with the Woocomemrce Brands plugin.

We do not have any official compatibility with that plugin but I will do my best to report this for further investigation.

To be able to report the compatibility issues we need to replicate the issue on a clean installation.

I created a clean installation of WordPress, Woocommerce, and all necessary Toolset plugins.

I also imported some sample products to work with.

You can access the WordPress dashboard using the link below:

hidden link

Kindly follow the steps below:

- Install the Woocommerce Brands plugins.
- Add a brand and see if the same issue is happening when trying to access Woocommerce > Brands

This will help us to report the probable issue to the compatibility team and solve the possible problem faster.

#2593189

Thank you for the staging site to perform the exercise. We are not encountering the same problems here.
Your debug logs may reveal more.
The problem occurs specifically when we "Edit" a brand. A prolonged load time, eventually rendering an empty wordpress admin dashboard page.

Once again, this was not the case on the staging site you provided, but when reproducing the exercise on our staging site, with only the plugins mentioned and a basic theme activated, we still encountered the problem.

We noticed that the PHP version you are using on the staging site provided was 7.44, which is deprecated. Our sites have been upgraded to PHP version 8.0.

Would it be possible to provide a staging site with PHP version 8.0 for us to test with you?

#2595973

Christopher Amirian
Supporter

Languages: English (English )

Hi there,

Thank you for providing the login information on a staging website.

I tested and the issue is happening with Toolset Types and Woocommerce Brands plugin, so it is a compatibility issue.

I reported this to the second-tier and they will look into the issue to see if there is something on our side that can be done.

Along the way, we may need to create a dump of the website for further investigation. I want to have your permission for that.

Thank you.

#2596193

Thank you. You have the go-ahead for dumping the site if needed.

#2596195

Christopher Amirian
Supporter

Languages: English (English )

Hi there,

Our awesome development team has a workaround. Here is their answer:

The problem lies in the WC Branding plugin code.

The file woocommerce-brands/includes/class-wc-brands-admin.php defines a method columns. This is added as a callback to a filter relating to the edit taxonomy term page.

	/**
	 * columns function.
	 *
	 * @access public
	 * @param mixed $columns
	 */
	function columns( $columns ) {
		if ( empty( $columns ) ) {
			return;
		}
...

The problem lies in that first return statement.

When $columns is passed as an empty array the function columns will convert that to null rather than returning it as the same empty array, potentially breaking any subsequent code that hooks into the same filter (which any plugin that modifies taxonomy edit pages may do, including Types).

(The return statement on its own—without specifying a return value—will return null; see hidden link.)

The plugin authors should modify the code like so so that when passed an empty array as an argument it will return the same, which they can do with this simple change:

	/**
	 * columns function.
	 *
	 * @access public
	 * @param mixed $columns
	 */
	function columns( $columns ) {
		if ( empty( $columns ) ) {
			return $columns; // return an empty array if passed an empty array, rather than returning null
		}
...

So please change the code as mentioned above in Woocommerce Brands plugin, and I do encourage you to contact their support and give the information above so they can add a permanent solution to this.

Thank you.

#2597007
Screenshot 2023-04-19 110057.png

Thank you for taking the time.

I have communicated with WooCommerce concerning the recommendation.
That being said, did the Dev team test the modification of the WooCommerce Brands code?

I went ahead a modified the return statement for testing purposes, and the same fatal error is thrown by Toolset, stating that a null is returned when a Countable|array is expected.

This is quite embarassing, seeing as how I've pointed the blame at WooCommerce, but the proposed fix on their end would not resolve the issue.

---

[19-Apr-2023 14:56:46 UTC] PHP Fatal error: Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, null given in /home/quebecacoustic/webapps/quebecacoustic/public/wp-content/plugins/types/application/controllers/utils/utils.php:193
Stack trace:
#0 /home/quebecacoustic/webapps/quebecacoustic/public/wp-content/plugins/types/vendor/toolset/types/embedded/classes/gui/term_field_editing.php(414): Types_Utils::insert_at_position()
#1 /home/quebecacoustic/webapps/quebecacoustic/public/wp-includes/class-wp-hook.php(308): WPCF_GUI_Term_Field_Editing->manage_term_listing_columns()
#2 /home/quebecacoustic/webapps/quebecacoustic/public/wp-includes/plugin.php(205): WP_Hook->apply_filters()
#3 /home/quebecacoustic/webapps/quebecacoustic/public/wp-admin/includes/screen.php(37): apply_filters()
#4 /home/quebecacoustic/webapps/quebecacoustic/public/wp-admin/includes/class-wp-screen.php(998): get_column_headers()
#5 /home/quebecacoustic/webapps/quebecacoustic/public/wp-admin/includes/class-wp-screen.php(959): WP_Screen->show_screen_options()
#6 /home/quebecacoustic/webapps/quebecacoustic/public/wp-admin/admin-header.php(281): WP_Screen->render_screen_meta()
#7 /home/quebecacoustic/webapps/quebecacoustic/public/wp-admin/term.php(73): require_once('...')
#8 {main}
thrown in /home/quebecacoustic/webapps/quebecacoustic/public/wp-content/plugins/types/application/controllers/utils/utils.php on line 193

#2597097
Screenshot 2023-04-19 110057.png

Thank you for taking the time.

I have communicated with WooCommerce concerning the recommendation.
That being said, did the Dev team test the modification of the WooCommerce Brands code?

I went ahead a modified the return statement for testing purposes, and the same fatal error is thrown by Toolset, stating that a null is returned when a Countable|array is expected.

This is quite embarassing, seeing as how I've pointed the blame at WooCommerce, but the proposed fix on their end would not resolve the issue.

---

[19-Apr-2023 14:56:46 UTC] PHP Fatal error: Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, null given in /home/quebecacoustic/webapps/quebecacoustic/public/wp-content/plugins/types/application/controllers/utils/utils.php:193
Stack trace:
#0 /home/quebecacoustic/webapps/quebecacoustic/public/wp-content/plugins/types/vendor/toolset/types/embedded/classes/gui/term_field_editing.php(414): Types_Utils::insert_at_position()
#1 /home/quebecacoustic/webapps/quebecacoustic/public/wp-includes/class-wp-hook.php(308): WPCF_GUI_Term_Field_Editing->manage_term_listing_columns()
#2 /home/quebecacoustic/webapps/quebecacoustic/public/wp-includes/plugin.php(205): WP_Hook->apply_filters()
#3 /home/quebecacoustic/webapps/quebecacoustic/public/wp-admin/includes/screen.php(37): apply_filters()
#4 /home/quebecacoustic/webapps/quebecacoustic/public/wp-admin/includes/class-wp-screen.php(998): get_column_headers()
#5 /home/quebecacoustic/webapps/quebecacoustic/public/wp-admin/includes/class-wp-screen.php(959): WP_Screen->show_screen_options()
#6 /home/quebecacoustic/webapps/quebecacoustic/public/wp-admin/admin-header.php(281): WP_Screen->render_screen_meta()
#7 /home/quebecacoustic/webapps/quebecacoustic/public/wp-admin/term.php(73): require_once('...')
#8 {main}
thrown in /home/quebecacoustic/webapps/quebecacoustic/public/wp-content/plugins/types/application/controllers/utils/utils.php on line 193

#2597373

Christopher Amirian
Supporter

Languages: English (English )

Screenshot 2023-04-20 at 16.47.37.png

Hi there,

It seems that you changed the wrong code. In the screenshot you shared, you changed a function called product_columns.

That is not the function you should change, the change should be done on line 433 for the column function.

I went to the staging website that you provided and changed the code in the correct place.

No if you check a brand edit screen it works ok.

Thank you.