Our code breaks with the latest version 5.0.19p.
While we’re fixing it, could you please send us the previous version:
Event Espresso 4 Core Regular v5.0.18.p
Extending on the break: with the latest version you enforce the type signature WP_POST for public function the_post(WP_Post &$post) within EE_CPT_Event_Strategy. Given that we’re using Timber, the type of the post is Timber\Post.
I think EE should loosen the constraint.
Fatal error: Uncaught Error: EE_CPT_Event_Strategy::the_post(): Argument #1 ($post) must be of type WP_Post, Timber\Post given, called in wp-includes/class-wp-hook.php on line 326
in wp-content/plugins/event-espresso-core-reg/core/CPTs/EE_CPT_Event_Strategy.core.php on line 251
We did some investigating for this and EE_CPT_Event_Strategy hooks into the_post for the above, the object passed to the_post should always be some form of WP_Post object, which Timber\Post is not.
So the issue here is something is returning a completely different object than what is expected for the_post filter, loosening the constraint within EE isn’t the right solution here.
On checking within the current Timber codebase I can’t find anywhere in which the_post would return a Timber\Post object so I’m guessing this is being set within your theme?
Our developer reached out to Timber to ask about this, this was the response:
I tried to reproduce the issue to see whether we missed something, but I can’t find an issue with Timber core itself. So I suspect that there’s something else going on.
It could be the theme or a plugin that adds a hook for the_post as well.
Because Timber v1 hooked into the_post every time a Timber\Post was instantiated, some developers might have applied fixes themselves. We resolved this issue in Timber 2.0 so that the_post action is only called when looping over posts. On singular templates, $post->setup() has to be called manually. So any custom fix for this might not be needed anymore.
The support post ‘Previous version’ is closed to new replies.
Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.
Support forum for Event Espresso 3 and Event Espresso 4.