I maintain a website on WordPress coded with Timber/Twig and ACF Blocks. Local installation runs on a Windows/Laragon with PHP 8 and is okay. Staging installation runs on a shared hosting A with PHP 7.4.x and is okay, too. Production however runs on a server B with PHP 7.2.x. When I try to upgrade to 7.4.x at least, I get a fatal error:
Fatal error: Uncaught Exception: Failed to load Twig template "templates/blocks/newsletter-form.twig", index "": cache might be corrupted in "templates/blocks/newsletter-form.twig".
in /www/[my_dir]/www/[my_domain]/public_html/wp-content/plugins/timber-library/vendor/twig/twig/src/Environment.php on line 502
Call stack:
Twig\Environment::loadClass()
wp-content/plugins/timber-library/vendor/twig/twig/src/Environment.php:445
Twig\Environment::loadTemplate()
wp-content/plugins/timber-library/vendor/twig/twig/src/Environment.php:423
Twig\Environment::load()
wp-content/plugins/timber-library/lib/Loader.php:78
Timber\Loader::render()
wp-content/plugins/timber-library/lib/Timber.php:334
Timber\Timber::compile()
wp-content/plugins/timber-library/lib/Timber.php:383
Timber\Timber::fetch()
wp-content/plugins/timber-library/lib/Timber.php:410
Timber\Timber::render()
wp-content/themes/pawilon-redux/vendor/palmiak/timber-acf-wp-blocks/timber-acf-wp-blocks.php:275
Timber_Acf_Wp_Blocks::timber_blocks_callback()
wp-content/plugins/advanced-custom-fields-pro/pro/blocks.php:350
acf_render_block()
wp-content/plugins/advanced-custom-fields-pro/pro/blocks.php:303
acf_rendered_block()
wp-includes/class-wp-block.php:258
WP_Block::render()
wp-includes/class-wp-block.php:244
WP_Block::render()
wp-includes/class-wp-block.php:244
WP_Block::render()
wp-includes/blocks.php:1072
render_block()
wp-includes/blocks.php:1110
do_blocks()
wp-content/themes/pawilon-redux/Chisel/Site.php:51
Chisel\Site::addToContext()
wp-includes/class-wp-hook.php:308
WP_Hook::apply_filters()
wp-includes/plugin.php:205
apply_filters()
wp-content/plugins/timber-library/lib/Timber.php:269
Timber\Timber::get_context()
wp-content/themes/pawilon-redux/page.php:22
include()
wp-includes/template-loader.php:106
require_once()
wp-blog-header.php:19
require()
index.php:17
The site is using Timber plugin for WP, version 1.22. I've been struggling with this issue for some time and run out of ideas. To my undertanding, it's not specifically a PHP issue, since both on local and staging installations I run exactly the same code on newer PHPs with no problems. (And yes, I know, that staging should theoretically be runned on the same hosting as production).
I tried to:
- Remove
templates/blocks/newsletter-form.twigtemplate, but then the problem jumps further topage.twig - Clear caches with
clear_cache_timber()andclear_cache_twig()methods - Reinstalling Timber plugin from scratch
None of the above worked. Obviously, keeping the website on PHP 7.2.x is not an option in the long run, so I need to solve this problem somehow.
Have any on you encountered a similar issue and found a working solution?