Skip Navigation

[Resolved] Ajax filter is getting a 500 server error instead of updating results

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 Jamal 2 months ago.

Assigned support staff: Jamal.

Author
Posts
#2116939

I am trying to:
We have a variety of filters in Views and custom Archives and normally a change in a filter value updates the results properly. Today they are failing and javascript console shows a 500 error trying to access ajax-admin. We haven't changed anything since it was working yesterday. I tried restarting the server with no improvement. I also replaced all WordPress core files, stripped .htaccess down to the minimum and turned off a series of plugins to see if any of those were the cause. No change.

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

I expected to see:
Checking a box in the filters should update the results.

Instead, I got:
Results do not update. Javascript console shows:
Failed to load resource: the server responded with a status of 500 (Internal Server Error) for /wp-admin/admin-ajax.php:1

#2116943

Update: I determined this issue is caused by the WooCommerce update that fixed a big security issue. I can't rollback WooCommerce because it'll open up a now well known security hole. Not sure if you or WooCommerce needs to fix something but it doesn't seem to be something I can fix from my end. Hoping you can work on this very quickly!

#2117313

Jamal
Supporter

Languages: English (English ) French (Français )

Timezone: Africa/Casablanca (GMT+01:00)

Hello and thank you for contacting Toolset support.

I can't tell if the issue is from Toolset or WooCommerce without some debugging. Can you prepare a staging site and let me analyze this issue on it? To understand the cause of a 500 error, I'll need to activate PHP debugging and check the logs. I am setting your next reply to be private to let you share credentials to the staging site.

If you can't have a staging site, I'll need to take a copy of your website and analyze it locally or in our online platform.

However, I wonder where did you get the 5.5.1 version of WooCommerce? According to their website and Github repository, this version is not yet released:
- hidden link
- hidden link

#2117399

Jamal
Supporter

Languages: English (English ) French (Français )

Timezone: Africa/Casablanca (GMT+01:00)

The FTP credentials are not working for me, so I installed Filester plugin to be able to activate PHP debugging and check the logs. Unfortunately, the debug.log file is not generated. And without logs, I can't really tell what's happening.

I deactivated most of the plugins and switched to a default theme, but the issue is still happening. I deactivated the mu-plugins, but did not help either.

Can I take a copy of your website and check it in my local dev environement?

#2117405

You can take a copy. Not sure it'll help. I tried debugging on the live and staging sites and didn't log anything helpful in either case.

#2117497

Jamal
Supporter

Languages: English (English ) French (Français )

Timezone: Africa/Casablanca (GMT+01:00)

The debug.log file was generated on my local environement. I suspect that your hosting provider has disabled it at the server level, that's why we did not get any logs even though the debugging is activated.

And this is the error that I got:

[17-Jul-2021 14:51:47 UTC] PHP Fatal error:  Uncaught Error: Call to a member function filtering_via_lookup_table_is_active() on null in C:\sites\clone-2116939\wp-content\plugins\woocommerce\includes\class-wc-query.php:769
Stack trace:
#0 C:\sites\clone-2116939\wp-content\plugins\toolset-blocks\application\models\WooCommerce\WcQuery.php(287): WC_Query->get_tax_query(Array, true)
#1 C:\sites\clone-2116939\wp-content\plugins\toolset-blocks\application\models\WooCommerce\WcQuery.php(259): OTGS\Toolset\Views\Model\WooCommerce\WcQuery->product_query(Object(WP_Query))
#2 C:\sites\clone-2116939\wp-includes\class-wp-hook.php(292): OTGS\Toolset\Views\Model\WooCommerce\WcQuery->pre_get_posts(Object(WP_Query))
#3 C:\sites\clone-2116939\wp-includes\class-wp-hook.php(316): WP_Hook->apply_filters(NULL, Array)
#4 C:\sites\clone-2116939\wp-includes\plugin.php(551): WP_Hook->do_action(Array)
#5 C:\sites\clone-2116939\wp-includes\class-wp-query.php(1784): do_action_ref_array('pre_get_posts', Array)
#6 C:\sites\clone-2116939\wp-includes\class-wp-query.php(3465): WP_Query- in C:\sites\clone-2116939\wp-content\plugins\woocommerce\includes\class-wc-query.php on line 769

The error is generated if we select an option, and when we deselect it. This gets me thinking that this issue will happen with any AJAX request that should return products.

I need to reproduce this on a clean install before being sure. So, I am creating a new WordPress installation with the required plugins. Please help us reproduce this issue on this install hidden link

If the issue is reproduced, I'll escalate it to our 2nd Tier for further analysis. If it is not, I'll assume that it happens on your website because of something else, and I'll try to find out what, or escalate it to our 2nd Tier for assistance.

#2117669

I added a few products and categories to your test site and then setup a Products archive with a filter for category. If you choose a category with the filter, the spinners spins and never finishes so I think we're seeing the same issue as on my client's site.

You can see it here: hidden link

#2117935

Jamal
Supporter

Languages: English (English ) French (Français )

Timezone: Africa/Casablanca (GMT+01:00)

Thank you for your collaboration. It is, indeed, the same issue. I am going to escalate to our 2nd Tier for further analysis, and I'll get back to you as soon as possible.

#2119049

Jamal
Supporter

Languages: English (English ) French (Français )

Timezone: Africa/Casablanca (GMT+01:00)

Hello again!

Our developers have produced a fix for this issue and it will be released in the next version of Toolset Blocks.

In the meantime, you can apply the patch discussed in this reply https://toolset.com/forums/topic/php-fatal-error-with-ajax-filtering/#post-2118845
The patched file can be downloaded from here hidden link

Let me know if that fixes the issue for you.

#2119143

My issue is resolved now. Thank you!

#2125549

Jamal
Supporter

Languages: English (English ) French (Français )

Timezone: Africa/Casablanca (GMT+01:00)

Hello there!

I just want to let you know that the issue has been fixed in last week's update. ** Please make a full backup before updating your website. **