Skip Navigation

PHP warning after updating The Events Calendar to version 6

Resolved

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

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 );

  • Sorry, my fix was for Toolset Views, not Toolset Blocks.

    Will this issue be fixed on Toolset Views too?

    • Yes, Toolset Blocks and Views use the same code base, just the default UI settings are different.

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

Comments are closed