Skip Navigation

PHP warning after updating The Events Calendar to version 6

Open

Symptoms

After updating the Events Calendar plugin to version 6 a PHP warning can occur when using Views:

PHP Warning:  call_user_func_array() expects parameter 1 to be a valid callback, class 'Tribe__Events__Query' does not have a method 'pre_get_posts' in /Users/nigelanderson/OnTheGo/Sites/events/wp-includes/class-wp-hook.php on line 307

Prior to version 6 the Events Calendar used pre_get_posts to hijack any query for its event post type, and Views/Blocks has a compatibility layer to workaround this to be able to create Views of event posts.

The warning occurs because of a change in The Events Calendar which means this is no longer needed.

Workaround

We will fix this in a plugin update, but for now you can use a modified version of the file responsible for the compatibility layer which adds a version check.

Download and unzip this file.

Replace the file with the same name at plugins/toolset-blocks/application/controllers/compatibility/ (or plugins/wp-views/application/controllers/compatibility/).

5 thought on PHP warning after updating The Events Calendar to version 6

  • ok … I replaced the file as detailed and the errors went away …

    thank you or your help if figuring this out!

  • We had the same issue, but in PHP8 this is not a warning, it totally breaks the page with a php fatal error.

    Our workaround was to add the following code to functions.php as we prefer not to directly edit the plugin files as any change will be lost on the next update. Maybe somebody will find this alternative useful.

    /**
    * Toolset Views: Fix compatibility with The Events Calendar.
    *
    * Toolset Views causes a php fatal error by adding an action to pre_get_posts using a function from The Events Calendar
    * that was recently removed (Tribe__Events__Query::pre_get_posts).
    */
    add_filter( 'wpv_filter_query_post_process', function( $query, $view_settings, $id ) {
    remove_action( 'pre_get_posts', array( 'Tribe__Events__Query', 'pre_get_posts' ), 50 );
    return $query;
    }, 11, 3 );

  • Can you all patch the current version 3.6.3 of wp views and bump version so i can pick up via composer

Leave
a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>