Support Forum
I'm using MB Views to create a header for my Post pages. And I've got some additional Twig-based functionality on the site that requires Timber.
Everything seems to work fine until I add a date field with a filter to MB Views. Then my front-end templates throw an error.
The specific error is:
Fatal error: Uncaught TypeError: Argument 1 passed to twig_date_format_filter() must be an instance of Twig\Environment, instance of MetaBox\Dependencies\Twig\Environment given, called in /Users/matt/Local Sites/center-blueprint/app/public/wp-content/plugins/meta-box-aio/vendor/meta-box/mb-views/dependencies/Twig/Environment.php(358) : eval()'d code on line 37 and defined in /Users/matt/Local Sites/center-blueprint/app/public/wp-content/plugins/timber-library/vendor/twig/twig/src/Extension/CoreExtension.php on line 41
I've posted the full call trace here.
I've removed all other plugins besides Meta Box and Timber and the problem persists. I've reduced my MB Views template to just the date field: {{ post.date | date( 'F j, Y' ) }}
and it is clearly the date field that triggers it.
I'm using MB AIO 1.15.2 and Timber 1.19.1, which I think are the latest versions of each.
I don't know if my issue is related to this one, but it sounds like it could be.
Hi,
The plugin Timber uses the Twig version 1.42.5 while MB Views uses the newer version 3.2.1 so I think it could be a conflict between the two versions.
You can try to deactivate the plugin Timber to re-check the issue.
Thanks for the reply, Long. It makes sense to me that the different versions might conflict in unexpected ways.
Deactivating Timber does fix the issue, but then I lose the other functionality.
Is there a way to scope/namespace/prefix the MB Twig usage?
I found an issue on the Timber repo showing how another plugin handled a similar conflict. I don't know enough about MB development to know whether that would be appropriate or even possible.
Hi,
FYI, the MB Views plugin runs Twig functions/classes under the namespace MBViews
. Please contact Timber plugin support to ask for help with this issue.
Thanks, Long. That's helpful to know. I'll ask the Timber folks.