Problem/Motivation
\Drupal\Core\Datetime\Element\Datelist
, \Drupal\Core\Datetime\DrupalDateTime
and \Drupal\Core\Datetime\DateFormatter::formatInterval() all trigger deprecation notices in PHP 8.1. Handling them together because they are all in the same component.
\Drupal\Core\Datetime\Element\Datelist::checkEmptyInputs()
results in deprecations because it passes non strings in strlen()
. $input['object']
is set to the date object and should not be checked.
\Drupal\Core\Datetime\DrupalDateTime::format()
passes $format to preg_replace_callback() after calling \Drupal\Component\Datetime\DateTimePlus::format() which can result in $format being set to NULL if there are errors.
Steps to reproduce
See test runs on #3220021: [meta] Ensure compatibility of Drupal 9 with PHP 8.1 (as it evolves)
Proposed resolution
Avoid calling code that expects a string with NULL values.
Remaining tasks
User interface changes
None
API changes
None
Data model changes
None
Release notes snippet
Comment | File | Size | Author |
---|---|---|---|
#4 | 3236796-4.patch | 3.23 KB | alexpott |
#4 | 2-4-interdiff.txt | 603 bytes | alexpott |
#2 | 3236796-2.patch | 3.82 KB | alexpott |
Comments
Comment #2
alexpottHere's the working fixes from #3220021: [meta] Ensure compatibility of Drupal 9 with PHP 8.1 (as it evolves) - I'm unsure of the fix to \Drupal\Core\Datetime\DateFormatter::formatInterval(). Ideally we'd be able to change the typehint on this param to int so I think maybe we should fix this in the callers...
Comment #3
alexpottDecided to handle #3236798: \Drupal\Core\Datetime\DateFormatter::formatInterval() causes deprecations in PHP 8.1 on its own.
Comment #4
alexpottComment #5
larowlanLooks good to me
Comment #7
catchCommitted 1d75ddb and pushed to 9.3.x. Thanks!