core icon indicating copy to clipboard operation
core copied to clipboard

Filters incompatible with PHP 8.2.20 and 8.3.8

Open jamesisaac opened this issue 1 year ago • 18 comments

API Platform version(s) affected: 3.1, 3.2, 3.3

Description

After CircleCI has released images for PHP patch versions 8.3.8 and 8.2.20 (today), we are seeing new errors on our test suite related to operations with filters.

Stack traces from APIP 3.3.5

Error: Call to protected method ApiPlatform\Doctrine\Orm\Filter\SearchFilter::splitPropertyParts() from scope ApiPlatform\Doctrine\Orm\Filter\AbstractFilter

/home/circleci/project/vendor/api-platform/core/src/Doctrine/Orm/PropertyHelperTrait.php:66
/home/circleci/project/vendor/api-platform/core/src/Doctrine/Orm/Filter/SearchFilter.php:186
/home/circleci/project/vendor/api-platform/core/src/Doctrine/Orm/Filter/AbstractFilter.php:44
/home/circleci/project/vendor/api-platform/core/src/Doctrine/Orm/Extension/FilterExtension.php:63
/home/circleci/project/vendor/api-platform/core/src/Doctrine/Orm/State/CollectionProvider.php:74
/home/circleci/project/vendor/api-platform/core/src/State/CallableProvider.php:43
/home/circleci/project/vendor/api-platform/core/src/State/Provider/ReadProvider.php:76
/home/circleci/project/vendor/api-platform/core/src/State/Provider/ParameterProvider.php:99
/home/circleci/project/vendor/api-platform/core/src/Symfony/Validator/State/ParameterValidatorProvider.php:39
/home/circleci/project/vendor/api-platform/core/src/Symfony/Bundle/SwaggerUi/SwaggerUiProvider.php:48
/home/circleci/project/vendor/api-platform/core/src/Symfony/Security/State/AccessCheckerProvider.php:53
/home/circleci/project/vendor/api-platform/core/src/Symfony/EventListener/ReadListener.php:95
/home/circleci/project/vendor/symfony/event-dispatcher/Debug/WrappedListener.php:116
/home/circleci/project/vendor/symfony/event-dispatcher/EventDispatcher.php:220
/home/circleci/project/vendor/symfony/event-dispatcher/EventDispatcher.php:56
/home/circleci/project/vendor/symfony/event-dispatcher/Debug/TraceableEventDispatcher.php:139
/home/circleci/project/vendor/symfony/http-kernel/HttpKernel.php:157
/home/circleci/project/vendor/symfony/http-kernel/HttpKernel.php:76
/home/circleci/project/vendor/symfony/http-kernel/Kernel.php:197
/home/circleci/project/vendor/symfony/http-kernel/HttpKernelBrowser.php:65
/home/circleci/project/vendor/symfony/framework-bundle/KernelBrowser.php:175
/home/circleci/project/vendor/symfony/browser-kit/AbstractBrowser.php:385
/home/circleci/project/vendor/api-platform/core/src/Symfony/Bundle/Test/Client.php:116
Error: Call to protected method ApiPlatform\Doctrine\Orm\Filter\BooleanFilter::splitPropertyParts() from scope ApiPlatform\Doctrine\Orm\Filter\AbstractFilter

/home/circleci/project/vendor/api-platform/core/src/Doctrine/Orm/PropertyHelperTrait.php:66
/home/circleci/project/vendor/api-platform/core/src/Doctrine/Orm/Filter/BooleanFilter.php:139
/home/circleci/project/vendor/api-platform/core/src/Doctrine/Orm/Filter/AbstractFilter.php:44
/home/circleci/project/vendor/api-platform/core/src/Doctrine/Orm/Extension/FilterExtension.php:63
/home/circleci/project/vendor/api-platform/core/src/Doctrine/Orm/State/CollectionProvider.php:74
/home/circleci/project/vendor/api-platform/core/src/State/CallableProvider.php:43
/home/circleci/project/vendor/api-platform/core/src/State/Provider/ReadProvider.php:76
/home/circleci/project/vendor/api-platform/core/src/State/Provider/ParameterProvider.php:99
/home/circleci/project/vendor/api-platform/core/src/Symfony/Validator/State/ParameterValidatorProvider.php:39
/home/circleci/project/vendor/api-platform/core/src/Symfony/Bundle/SwaggerUi/SwaggerUiProvider.php:48
/home/circleci/project/vendor/api-platform/core/src/Symfony/Security/State/AccessCheckerProvider.php:53
/home/circleci/project/vendor/api-platform/core/src/Symfony/EventListener/ReadListener.php:95
/home/circleci/project/vendor/symfony/event-dispatcher/Debug/WrappedListener.php:116
/home/circleci/project/vendor/symfony/event-dispatcher/EventDispatcher.php:220
/home/circleci/project/vendor/symfony/event-dispatcher/EventDispatcher.php:56
/home/circleci/project/vendor/symfony/event-dispatcher/Debug/TraceableEventDispatcher.php:139
/home/circleci/project/vendor/symfony/http-kernel/HttpKernel.php:157
/home/circleci/project/vendor/symfony/http-kernel/HttpKernel.php:76
/home/circleci/project/vendor/symfony/http-kernel/Kernel.php:197
/home/circleci/project/vendor/symfony/http-kernel/HttpKernelBrowser.php:65
/home/circleci/project/vendor/symfony/framework-bundle/KernelBrowser.php:175
/home/circleci/project/vendor/symfony/browser-kit/AbstractBrowser.php:385
/home/circleci/project/vendor/api-platform/core/src/Symfony/Bundle/Test/Client.php:116

The errors disappear if we lock the PHP version down to 8.3.7 or 8.2.19.

Seems to affect the latest versions on all minor versions of APIP (3.3.5 etc).

How to reproduce

Let me know if a reproduction is needed.

Possible Solution

Additional Context

jamesisaac avatar Jun 05 '24 15:06 jamesisaac

Ah I see someone opened an issue in php-src: https://github.com/php/php-src/issues/14480

jamesisaac avatar Jun 05 '24 15:06 jamesisaac

So apparently the PHP fix won't appear until the following release, v8.3.9. Which means on an environment that auto-applies patch versions of PHP, there would be a period of APIP projects running into errors until PHP 8.3.9/8.2.21 are released. So it may still be worth working around the PHP bug from the APIP side?

jamesisaac avatar Jun 06 '24 12:06 jamesisaac

So apparently the PHP fix won't appear until the following release, v8.3.9. Which means on an environment that auto-applies patch versions of PHP, there would be a period of APIP projects running into errors until PHP 8.3.9/8.2.21 are released. So it may still be worth working around the PHP bug from the APIP side?

Just lost an afternoon to debugging this (admittedly should have viewed the project issues page earlier) but agree with above, if there is anything we can do in the core code to mitigate this issue and make visibility paths a bit clearer (navigating all those traits isn't the easiest) and bulletproof then in my view we absolutely should.

JParkinson1991 avatar Jun 07 '24 16:06 JParkinson1991

Hi,

we had the same Problem last week and today it is solved. Its like magic :)

kurt-junker avatar Jun 10 '24 07:06 kurt-junker

If you are using PHP from ondrej sury, you might be lucky: https://github.com/php/php-src/issues/14480#issuecomment-2156115468

macghriogair avatar Jun 10 '24 08:06 macghriogair

Same here - php 8.2.20

sivanovDespark avatar Jun 11 '24 07:06 sivanovDespark

same here - php 8.8.20 / api platform 3.3.5

esauvage1978 avatar Jun 11 '24 11:06 esauvage1978

Same here: PHP 8.2.20 - Api Platform 3.2.23. Reverting on PHP 8.2.19 and 8.3.7 fixed the issue.

ambroisemaupate avatar Jun 11 '24 11:06 ambroisemaupate

Same here: PHP 8.2.20

a-dasilva avatar Jun 11 '24 13:06 a-dasilva

Same here: after downgrading PHP to 8.2.19 everything worked.

ReneStefancik avatar Jun 12 '24 10:06 ReneStefancik

As @macghriogair said, upgrading to the new 8.2.20-2 version from the ondrej ppa seemed to fix the issue.

fattybenji avatar Jun 12 '24 12:06 fattybenji

Same here: After upgrading from PHP 8.2.19 to 8.2.20, the error occured. The error seems to be due to importing multiple traits defining the same method:

The class ApiPlatform\Doctrine\Orm\Filter\AbstractFilter uses the two traits:

  • ApiPlatform\Doctrine\Orm\PropertyHelperTrait
  • ApiPlatform\Doctrine\Common\PropertyHelperTrait

The method splitPropertyParts is defined abstract in the first, but has a concrete implementation in the second class. Since 8.2.20 also the abstract method gets called from the class ApiPlatform\Doctrine\Orm\Filter\SearchFilter resulting in the above error.

However, when changing the use-order in the AbstractFilter class from this original version

use OrmPropertyHelperTrait;
use PropertyHelperTrait;

to this:

use PropertyHelperTrait;
use OrmPropertyHelperTrait;

This specific error does not occur, but then another issue with the same cause follows. There might be a general solution needed for this.

seigoryu avatar Jun 12 '24 14:06 seigoryu

Not sure if this is related, but since PHP 8.2.20, calling any endpoint of my API with a nested parameter (field.prop=, order[field.prop]=) lead a SIGSEGV from PHP and a 502 error.

Everything works fine after downgrading to 8.2.19.

jzecca avatar Jun 12 '24 15:06 jzecca

I don't see an easy way to fix this on our side. While waiting for the next patch PHP release, the workaround is to downgrade or recompile PHP with the fix.

dunglas avatar Jun 13 '24 07:06 dunglas

On Symfony Docker I try to swicth version from dunglas/frankenphp:1-php8.3 to dunglas/frankenphp:1-php8.3.4-alpine. It's working

yossakornTae avatar Jun 14 '24 08:06 yossakornTae

is there a solution without downgrading php

sasa1007 avatar Jun 19 '24 07:06 sasa1007

It is still unclear to me, if this a PHP or a API-Platform issue? Can someone from the core team pl. provide some comment here?

Will this be fixed in the next PHP-releases?

dreamworks avatar Jun 22 '24 11:06 dreamworks

It is still unclear to me, if this a PHP or a API-Platform issue? Can someone from the core team pl. provide some comment here?

Will this be fixed in the next PHP-releases?

This is definitely a PHP issue: https://github.com/php/php-src/issues/14480 This will be fixed in PHP v8.3.9 and v8.2.21.

These versions are not released yet, but there are RC ongoing: https://hub.docker.com/_/php/tags?page=&page_size=&ordering=&name=8.3

For the moment, the easier fix is to downgrade to 8.3.7 and 8.2.19. If you are using docker base images, it's the easiest way.

ambroisemaupate avatar Jun 24 '24 11:06 ambroisemaupate

Hi ! Fixed by downgrading PHP 8.3 to 8.2.19 in composer AND in the Dockerfile on PHP 8.3.7

Lucien-Arb avatar Jul 05 '24 15:07 Lucien-Arb

Hi

PHP 8.3.9 is officially released https://hub.docker.com/_/php/tags?page=&page_size=&ordering=&name=8.3.9

Does this fix the issue?

ambroisemaupate avatar Jul 10 '24 12:07 ambroisemaupate

@ambroisemaupate it does,

ghost avatar Jul 10 '24 13:07 ghost

Hi

PHP 8.3.9 is officially released https://hub.docker.com/_/php/tags?page=&page_size=&ordering=&name=8.3.9

Does this fix the issue?

Yes, on dunglas/frankenphp:php8.3.9-alpine works well!

wow-apps avatar Jul 23 '24 13:07 wow-apps

Hi all, I have the same issue, running PHP 8.3.13 and API platform 4.0 What's weird is that it was working yesterday. Not a single change has been made and today it throws this error. it throws it when trying to filter by a relation, ie &relation.id=2

I tried on another computer, same PHP version, all the same, and it works. But in my current computer, where it was totally working, now it throws Call to protected method ApiPlatform\\Doctrine\\Orm\\Filter\\SearchFilter::splitPropertyParts() from scope ApiPlatform\\Doctrine\\Orm\\Filter\\AbstractFilter

germi avatar Nov 12 '24 11:11 germi