Skip Navigation

[Resolved] Getting an error when using Toolset View block and event calendar pro plugins

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
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9: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/Hong_Kong (GMT+08:00)

This topic contains 12 replies, has 2 voices.

Last updated by Paul Marconi 1 year, 9 months ago.

Assisted by: Luo Yang.

Author
Posts
#2561231
Capture.PNG

Hi there,

I am using the Toolset View to create a search filter for events. I am also using the event calendar pro plugin to create the events. Apparently, I am getting an error on the page when I have a toolset view added to the page.

This is the error:
Deprecated: Function Tribe__Events__Query::pre_get_posts is deprecated since version 6.0.0! Use No replacement avaialble. instead. in /home/sprucedev/public_html/sites/eventtest.isunderconstruction.com/wp-includes/functions.php on line 5383

This is my test page:
hidden link

This test site is a fresh install of WordPress. I only installed 4 plugins on the site, and I am using the WordPress default 2021 theme, nothing else. Below are the plugins that I have installed.
-The Events Calendar
-The Events Calendar PRO
-Toolset Types
-Toolset Views

Theme: WP 2021 theme
Wordpress : Version 6.1.1

I have already contacted the event calendar pro support team, and this is their response:

"We are 100% sure that the two Toolset plugins are using that deprecated function:
The errors only show on a page that uses the Toolset view block.

It’s very likely one or both of those plugins are using the method Tribe__Events__Query::pre_get_posts which is deprecated. That’s why it’s showing the deprecation error.

Unfortunately, there is no replacement available for that method. Perhaps a dev could help find a way to replace the use of that method in that plugin. "

Is this an issue that can be fixed?
I can share my WP login credentials so you can look into this.

Thank you!

#2562187

Hello,

Yes, in Toolset Views/Blocks plugin, due to some compatibility issue with Events Calendarplugin:

When loading the output of a View with post selection coming from the custom post type of The Events Calendar, the third-party plugin hijacks the query and injects "where" values that prevent the View to properly fetch the needed posts. We are temporarily removing the "pre_get_posts" action while the View is rendered and we are restoring it later.

See plugin file of Toolset Blocks plugin: \plugins\toolset-blocks\application\controllers\compatibility\the-event-calendar.php, line 45~48.

If you don't need to display Views in Event posts, you can disable it by this, add below codes into your theme file "functions.php":

remove_action( 'pre_get_posts', array( 'Tribe__Events__Query', 'pre_get_posts' ), 50 );

If you need it, since it is just a Deprecated message, you can just turn off the WordPress debug message in frontend:
https://wordpress.org/documentation/article/debugging-in-wordpress/

#2562373

Thank you Luo! We will need to use the Toolset Views block, and since we are currently developing this site, we need to enable debugging for now. Would you know when this issue will be fixed? On the next release?

Thanks!

#2562677

It seems that the "event calendar pro plugin" changed something recently, since I don't have a copy of "event calendar pro plugin" in my localhost, can you try as I mentioned above:

1) add below codes into your theme file "functions.php":

remove_action( 'pre_get_posts', array( 'Tribe__Events__Query', 'pre_get_posts' ), 50 );

Check if the problem is fixed.

2) in single "event" post, display a Toolset post view, check if it works correctly.

#2562975
code.PNG

Hi Luo,

The Toolset View is actually on a wordpress page, not in a single event post. This is the page:
hidden link

I did add that code to the functions.php file, but it did not resolve the issue.
I have uploaded the "event calendar pro plugin to dropbox, please find the sharable link to download it:
hidden link

Thanks!

#2563519

Here is a sandbox website:
Login URL:
hidden link

Please try to reproduce the same problem in above website, I need to test and debug in a live website, thanks

#2563931
Capture.PNG

Hi Luo,

Sure, I can reproduce the same problem in your sandbox website, but can you also install the Toolset Views plugin. I am using the latest version.

Thanks!

#2564397

I have installed Toolset Views plugin in above sandbox website, please try to reproduce the problem in it, thanks

#2564773

Hi Luo,

I have created a view (using Posts), created a new page and added in the view block in your sandbox website.
hidden link

Weird that I don't see the error message on your site.

This is the error on my end (hidden link):
Deprecated: Function Tribe__Events__Query::pre_get_posts is deprecated since version 6.0.0! Use No replacement avaialble. instead. in xxxxx/wp-includes/functions.php on line 5383

My test site is a fresh install of WordPress. I have only 4 plugins installed on the site, and I am using the WordPress default 2021 theme, nothing else (no custom codes added). Below are the plugins that I have installed.
-The Events Calendar
-The Events Calendar PRO
-Toolset Types
-Toolset Views

Theme: WP 2021 theme
Wordpress : Version 6.1.1

What is wrong?

Also, below is the site php info :
hidden link

Am I missing anything?

Thank you!

#2565059

I have tried these in above sandbox website:
1) Edit wp-config.php, lines 153~155:
hidden link
Enable WordPress debug mode, and display the error message in frontend:

define( 'WP_DEBUG', true );
define( 'WP_DEBUG_DISPLAY', true );
@ini_set( 'display_errors', 1 );

2) Try to edit page you mentioned:
hidden link
I can see those PHP messages.

3)Edit theme file "functions.php",
hidden link
Add below lines 658~661:

add_filter('wpv_filter_query_post_process',  function($query){
	remove_action( 'pre_get_posts', array( 'Tribe__Events__Query', 'pre_get_posts' ), 50 );
	return $query;
}, 11);

It works fine, see the result page:
hidden link

So you just need to try the step 3) in your own website, and check if it is fixed.

#2565525

Thank you Luo! I added in the code in step 3 and the error is gone. Just a quick question, is the error "Deprecated: Function Tribe__Events__Query::pre_get_posts is deprecated since version 6.0.0! Use No replacement available" going to be fixed in the future so we don't need to add the 'wpv_filter_query_post_process' filter code?

#2566547

Can you confirm it works in your website? And I will escalate this issue, currently, please try the workaround I provided above.

#2567001

Hi Luo,
Yes, it works on my site.

Just wondering is the error "Deprecated: Function Tribe__Events__Query::pre_get_posts is deprecated since version 6.0.0! Use No replacement available" going to be fixed in the future so we don't need to add the 'wpv_filter_query_post_process' filter code?

Thank you!