Closed (fixed)
Project:
Drupal core
Version:
9.3.x-dev
Component:
render system
Priority:
Critical
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
28 Sep 2021 at 23:47 UTC
Updated:
13 Oct 2021 at 09:24 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
alexpottComment #3
daffie commentedLets see if a string type casting will fix the problem.
Comment #4
alexpott@daffie #3 fixes it for sure. That's what is in #3220021: [meta] Ensure compatibility of Drupal 9 with PHP 8.1 (as it evolves) - I did #2 to see where and why we have the issue.
Comment #5
daffie commentedThe testbot returns 3,388 failures for the run with the patch from comment #2. The patch from comment #3 should therefor fix a lot of errors for PHP 8.1.
Comment #6
alexpott@daffie yes we know that already. The patch in #3 is exactly what the patch on #3220021: [meta] Ensure compatibility of Drupal 9 with PHP 8.1 (as it evolves) does to fix this on PHP 8.1.
What I'm trying to explore here is what is the best fix. The first step to that it to understand why $this->value is not a string sometimes. Here's why...
Tests are failing in #2 not because of NULLs but because of integers... for example:
in template_preprocess_table() is one cause. Another is checkbox values that are often integers.
I've considered overriding the
\Drupal\Core\Template\AttributeValueBaseconstructor with something like:This would eventually allow us to add the string typehint to $value but this would have a behaviour change side-effect of changing the type when the raw value is returned by \Drupal\Core\Template\AttributeValueBase::value() so I think we should go for the solution in #3 and cross this bridge when we think more about primitive typehints.
Comment #8
catch#3 seems like a good choice.
Committed 85b3e9c and pushed to 9.3.x. Thanks!