Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
Not sure when this started but some recent runs of PHP 8.1rc5 and SQLite have resulted in failures in Drupal\Tests\field\Functional\Number\NumberFieldTest:
Unsilenced deprecation notices (2)
1x: Implicit conversion from float 0.0001 to int loses precision
1x in NumberFieldTest::testCreateNumberFloatField from Drupal\Tests\field\Functional\Number
1x: Implicit conversion from float 0.1 to int loses precision
1x in NumberFieldTest::testCreateNumberDecimalField from Drupal\Tests\field\Functional\Number
Steps to reproduce
See e.g. https://www.drupal.org/pift-ci-job/2244674 or https://www.drupal.org/pift-ci-job/2244720
Proposed resolution
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
Comment | File | Size | Author |
---|---|---|---|
#5 | 3250743-5.patch | 2.35 KB | alexpott |
#4 | 3250743.will-fail-on-8.1.patch | 1.6 KB | alexpott |
#3 | 3250743.patch | 775 bytes | alexpott |
Comments
Comment #2
mondrakeComment #3
alexpottThis was caused by the incorrect typehint being added by #3138078: [D9.3 beta - w/c Nov 8, 2021] Add a 'void' return typehint to custom assert* methods
and
These are not ints.
Comment #4
alexpottOkay so why is this not being reported on other 8.1 environments - I couldn't get it to fail locally at all when it definitely should. Well that's because we have an incorrect regex in \Drupal\Tests\Listeners\DeprecationListenerTrait::isDeprecationSkipped() added by #3232131: [Symfony 5] Symfony's DebugClassLoader triggers deprecation messages for missing return type hints, where there is no deprecation.
Here's proof.
Comment #5
alexpottAnd now for both of the patches together.
Comment #6
alexpottThe skipping of this deprecation is caused by https://regex101.com/r/C9t00b/1
Comment #7
alexpottAh... #3232131: [Symfony 5] Symfony's DebugClassLoader triggers deprecation messages for missing return type hints, where there is no deprecation has only been committed to 9.4.x so that explains why we think this is an sqlite thing. It's not at all. It's just that 9.3 tests PHP 8.1 on SQLite and fails... but on 9.4 / PHP 8.1 / MySQL it doesn't fail because of the regex mess.
So we need to commit #3 to 9.3.x and #5 to 9.4.x
Comment #8
Gábor HojtsyBoth of the fixes look good, great debugging! Note:
Comment #9
longwaveRTBC+1, great work.
Comment #10
mondrakeWould typehinting to float instead of removing the typehint for good work?
Comment #13
catchCommitted/pushed #5 to 9.4.x and #3 to 9.3.x. Good finds.
Comment #14
alexpott@mondrake if we want to typehint to something actually string would be best as we're really using this value to put into forms.
Comment #15
mondrake#14 OK did not catch that