Problem/Motivation
After upgrading a D7 site to PHP 8.0, views_embed_view is not loading template.
Steps to reproduce
We are using a template that has this code:
views_embed_view('usercomments', 'block');
And the view has a template "views-view--usercomments--block.tpl.php"
The first time the view is render correctly with this template.
If we reload the page , then the view does not load the template, and paints without template.
Regards,
Jordi
JOINSO
| Comment | File | Size | Author |
|---|---|---|---|
| #23 | views-n3316582-23.patch | 1.01 KB | damienmckenna |
| #17 | views-n3316582-17.patch | 2.36 KB | damienmckenna |
| #7 | views-view--usercomments--block.tpl_.txt | 4.17 KB | joinso |
| #5 | usercomments-view.txt | 8.92 KB | joinso |
Comments
Comment #2
damienmckennaThank you for reporting this bug.
There are a lot of things that could cause this.
Can you reproduce the problem on a bare install of Drupal 7 with one of the core themes and the default views that are included with the module?
Comment #3
joinso commentedHi!
I cannot reproduce on a bare install of Drupal 7.
If I test the same code in PHP 7.4 it works.
Also, If I clear the cache (memcache) of Drupal in PHP 8.0, the view is rendered correctly with the template.
Regards,
Jordi
JOINSO
Comment #4
damienmckennaCan you please upload the view as a text file so we can review it? Are you doing any preprocessing on the output?
Comment #5
joinso commentedI attached the view and the template.
Regards,
Jordi
JOINSO
Comment #6
damienmckennaThanks for posting the view. Can you please post the template too?
Comment #7
joinso commentedHere is the template.
Comment #8
damienmckennaI would suggest trying the site with a different theme to see if the problem persists with the default output.
Comment #9
joinso commentedI test with Bartik and I have the same issue: the template of the view is not loaded.
Regards,
Jordi
JOINSO
Comment #10
museumboy commentedI'm using this script in rules to add a view to an email. It is no longer working now that I'm on php 8.0
Comment #11
damienmckenna@museumboy: I suggest reviewing your custom code, there might be something that needs to be fixed in it.
Comment #12
damienmckenna@JOINSO: please test the latest dev release, see if it resolves the problem.
Comment #13
joinso commented@DamienMcKenna:
Thanks for the tip.
Few months ago, we released the new version of our site that is working with PHP 8.0 and D7.
Our solution was change this:
echo views_embed_view('usercomments', 'block');To this:
At the moment I am not going to make more test because I am focused in migrating D7 to D10.
Hope this workaround can help other ones to fix the issue.
Regards,
Jordi
JOINSO
Comment #14
damienmckennaI noticed that there's no test coverage for views_embed_view(), so let's add some.
Comment #15
damienmckennaComment #16
damienmckennaComment #17
damienmckennaA starting point for test coverage on views_embed_view().
Comment #18
damienmckennaI've set the tests to run against both PHP 7.4 and 8.0, so we'll see if a basic view works as expected.
Comment #19
damienmckennaThe test coverage shows the same output working for both PHP 7.4 and 8.0. I suggest you both look into the specific views that are failing for you and see if any of them include custom PHP code, that could be the culprit.
Comment #20
joseph.olstadComment #21
joseph.olstadComment #22
joseph.olstadOops
Comment #23
damienmckennaThe correct test patch.