-
-
Notifications
You must be signed in to change notification settings - Fork 962
Description
API Platform version(s) affected: 4.2.15
Description
I am running on PHP 8.5 and my log fills up with these deprecation messages:
Using null as an array offset is deprecated, use an empty string instead
from vendor/api-platform/doctrine-orm/Filter/OrderFilter.php line 241
The part of the code causing this issue seems to be
$context['filters'][$parameter?->getProperty()]
Where in this case $parameter seems to be null, so it uses null as an array offset, which is deprecated since PHP 8.5:
https://www.php.net/manual/de/migration85.deprecated.php#migration85.deprecated.core.using-null-as-an-array-offset
As every request that uses this order filter triggers a deprecation warning, this fills up my deprecation log file quite a lot.
How to reproduce
This is caused by this ApiFilter attribute using the OrderFilter class:
#[ApiFilter(
filterClass: OrderFilter::class,
properties: [
'createdAt',
'updatedAt',
],
)]Possible Solution
Verify that the variable used as array offset is not null before trying to access the array offset.