Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
Problem/Motivation
Running core/modules/migrate/tests/src/Unit/process/MakeUniqueEntityFieldTest.php
and core/modules/migrate/tests/src/Unit/MigrateSqlIdMapEnsureTablesTest.php
on PHP 8.1 triggers deprecations.
MigrateSqlIdMapEnsureTablesTest is due to the database prefix method returning a NULL.
MakeUniqueEntityFieldTest is due to $start being NULL and passed to mb_substr().
Steps to reproduce
Run the tests on PHP 8.1
Proposed resolution
Fix the tests.
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
Comment | File | Size | Author |
---|---|---|---|
#2 | 3241130-2.patch | 1.98 KB | alexpott |
Comments
Comment #2
alexpottComment #3
alexpottComment #4
daffie CreditAttribution: daffie commentedLooks good to me.
The third parameter of
mb_substr()
is allowed to be NULL. Therefor no change needed for the variable $length.Comment #5
larowlanIs this change required?
Comment #6
alexpott@larowlan yes. That method shoudl return a string but our mock returns a NULL so we need to fix that. See \Drupal\Core\Database\Connection::setPrefix() and \Drupal\Core\Database\Connection::tablePrefix(). The method will always return a string in reality because
$this->prefixes[$table];
or$this->prefixes['default'];
is always set.Comment #8
larowlanThanks for the explanation @alexpott
Committed 8ce8eb9 and pushed to 9.3.x. Thanks!