soflyy / breakdance-bugs

Bug reports from Breakdance users.
38 stars 6 forks source link

Missing parameter in WP filter leading to incompatibility with YITH Ajax Product filter #1059

Open rickydwilson-dcs opened 2 months ago

rickydwilson-dcs commented 2 months ago

I have been diagnosing an incompatibility with YITH Ajax Filter plugin and Breakdance. This manifests itself on post archive page (blog).

The YITH support team shared the information at the bottom of this bug report explaining their view of the issue ... essentially there code expects 2 elements to be present in the hook but Breakdance doesn't provide them both. They have "amended" Breakdance hook so this works in this staging site as part of their investigation.

For example:

  1. Visit Blog page https://www.staging3.cuddleplushfabrics.co.uk/blog/.
  2. No header or any page elements other than some oversized images are loaded

The blog page returns an error in Breakdance builder: ArgumentCountError: Too few arguments to function YITH_WCAN_Variations_Filtering::filter_loop_title(), 1 passed in /home/customer/www/staging3.cuddleplushfabrics.co.uk/public_html/wp-includes/class-wp-hook.php on line 324 and exactly 2 expected in /home/customer/www/staging3.cuddleplushfabrics.co.uk/public_html/wp-content/plugins/yith-woocommerce-ajax-product-filter-premium/includes/class-yith-wcan-variations-filtering.php on 192

Screenshot

-------- YITH SUPPORT REPORT ----------- YITH Support Team (YITH Support Team) Apr 28, 2024, 10:29 GMT+2

Hi there,

Thank you for reaching out and tell us your issue.

We took a look at your problem and we could see that there is a problem between our "Variation filtering" from our plugin and your page builder element for the posts ( if you disable this option from our plugin, the problem dissapears ).

This problem requires to talk about WordPress hooks and might seems a bit technical:

After taking a quick look at your page builder, we could see that is using WordPress filters in their elements, but they don't provide the parameters that WordPress does, parameters that our plugin expects. If you take a look into the the hook that your page builder use:

https://developer.wordpress.org/reference/hooks/the_title/#:~:text=the_title%20is%20a%20filter%20applied,string)%20from%20the%20filter%20function.

Screenshot

It gives two parameters, the title and the post ID ( in our case the post ID or the object post will work for our functions ). However your page builder only offers the title:

Screenshot

For that reason as our function is expecting those 2 parameters ( the second specially, to know if the object is a post or a product ), so the notifies this through an error as it breaks our functionality.

I added the second parameter in the element of the page builder and now the page works with our plugin and the variation filtering enabled:

Screenshot

Screenshot

However this changes will be removed when you update the page builder plugin ( also we are not sure if other elements have this problem too ) so I suggest to contact your page builder developers and ask them to follow the same structure of WordPress and add this second parameter.

----- END OF YITH SUPPORT -----

You should also include the following information: