Skip to content

Upgrade demo to Symfony 8#587

Draft
aaa2000 wants to merge 5 commits intoapi-platform:4.2from
aaa2000:sf8
Draft

Upgrade demo to Symfony 8#587
aaa2000 wants to merge 5 commits intoapi-platform:4.2from
aaa2000:sf8

Conversation

@aaa2000
Copy link
Contributor

@aaa2000 aaa2000 commented Feb 1, 2026

No description provided.

@alexislefebvre

This comment was marked as resolved.

@aaa2000 aaa2000 marked this pull request as draft February 3, 2026 21:07
"symfony/property-access": "8.0.*",
"symfony/runtime": "8.0.*",
"symfony/security-bundle": "8.0.*",
"symfony/serializer": "8.0.4",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

symfony/serializer v8.0.5 breaks the phpunit tests @see symfony/serializer@35b1aec

This comment was marked as resolved.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here are the test results


Runtime:       PHP 8.4.14
Configuration: /app/phpunit.xml.dist

NNNNNNNNNNNNNNNNNNNNNNNNNNN.................FF.....FF..........  63 / 123 ( 51%)
............................................................    123 / 123 (100%)

Faker seed: 952770

Time: 00:40.389, Memory: 125.00 MB

There were 4 failures:

1) App\Tests\Api\Admin\BookTest::asAdminUserICannotCreateABookWithInvalidData@empty data with data (['', ''], 422, ['ConstraintViolation', 'An error occurred', 'condition: This value should ...tring.', [['condition', 'The data must belong to a bac...dition']]], ...2 more elements)
Failed asserting that an array has the subset Array &0 [
    '@type' => 'ConstraintViolation',
    'hydra:title' => 'An error occurred',
    'hydra:description' => 'condition: This value should be of type int|string.',
    'violations' => Array &1 [
        0 => Array &2 [
            'propertyPath' => 'condition',
            'hint' => 'The data must belong to a backed enumeration of type App\Enum\BookCondition',
        ],
    ],
].
--- Expected
+++ Actual
@@ @@
       'propertyPath' => 'condition',
       'message' => 'This value should be of type .',
       'code' => 'ba785a8c-82cb-4283-967c-3cf342181b40',
-      'hint' => 'The data must belong to a backed enumeration of type App\\Enum\\BookCondition',
+      'hint' => 'The data must be one of the following values: \'https://schema.org/NewCondition\', \'https://schema.org/RefurbishedCondition\', \'https://schema.org/DamagedCondition\', \'https://schema.org/UsedCondition\'',
     ),
   ),
   'detail' => 'condition: This value should be of type .',
   'type' => '/validation_errors/ba785a8c-82cb-4283-967c-3cf342181b40',
-  'hydra:description' => 'condition: This value should be of type int|string.',
+  'hydra:description' => 'condition: This value should be of type .',
   'hydra:title' => 'An error occurred',
 )

/app/vendor/api-platform/symfony/Bundle/Test/Constraint/ArraySubsetTrait.php:63
/app/vendor/api-platform/symfony/Bundle/Test/Constraint/ArraySubset.php:32
/app/vendor/api-platform/symfony/Bundle/Test/ApiTestAssertionsTrait.php:106
/app/vendor/api-platform/symfony/Bundle/Test/ApiTestAssertionsTrait.php:65
/app/tests/Api/Admin/BookTest.php:282

2) App\Tests\Api\Admin\BookTest::asAdminUserICannotCreateABookWithInvalidData@invalid condition with data (['https://gutendex.com/books/31547.json', 'invalid condition'], 422, ['ConstraintViolation', 'An error occurred', 'condition: This value should ...tring.', [['condition', 'The data must belong to a bac...dition']]], ...2 more elements)
Failed asserting that an array has the subset Array &0 [
    '@type' => 'ConstraintViolation',
    'hydra:title' => 'An error occurred',
    'hydra:description' => 'condition: This value should be of type int|string.',
    'violations' => Array &1 [
        0 => Array &2 [
            'propertyPath' => 'condition',
            'hint' => 'The data must belong to a backed enumeration of type App\Enum\BookCondition',
        ],
    ],
].
--- Expected
+++ Actual
@@ @@
       'propertyPath' => 'condition',
       'message' => 'This value should be of type .',
       'code' => 'ba785a8c-82cb-4283-967c-3cf342181b40',
-      'hint' => 'The data must belong to a backed enumeration of type App\\Enum\\BookCondition',
+      'hint' => 'The data must be one of the following values: \'https://schema.org/NewCondition\', \'https://schema.org/RefurbishedCondition\', \'https://schema.org/DamagedCondition\', \'https://schema.org/UsedCondition\'',
     ),
   ),
   'detail' => 'condition: This value should be of type .',
   'type' => '/validation_errors/ba785a8c-82cb-4283-967c-3cf342181b40',
-  'hydra:description' => 'condition: This value should be of type int|string.',
+  'hydra:description' => 'condition: This value should be of type .',
   'hydra:title' => 'An error occurred',
 )

/app/vendor/api-platform/symfony/Bundle/Test/Constraint/ArraySubsetTrait.php:63
/app/vendor/api-platform/symfony/Bundle/Test/Constraint/ArraySubset.php:32
/app/vendor/api-platform/symfony/Bundle/Test/ApiTestAssertionsTrait.php:106
/app/vendor/api-platform/symfony/Bundle/Test/ApiTestAssertionsTrait.php:65
/app/tests/Api/Admin/BookTest.php:282

3) App\Tests\Api\Admin\BookTest::asAdminUserICannotUpdateABookWithInvalidData@empty data with data (['', ''], 422, ['ConstraintViolation', 'An error occurred', 'condition: This value should ...tring.', [['condition', 'The data must belong to a bac...dition']]], ...2 more elements)
Failed asserting that an array has the subset Array &0 [
    '@type' => 'ConstraintViolation',
    'hydra:title' => 'An error occurred',
    'hydra:description' => 'condition: This value should be of type int|string.',
    'violations' => Array &1 [
        0 => Array &2 [
            'propertyPath' => 'condition',
            'hint' => 'The data must belong to a backed enumeration of type App\Enum\BookCondition',
        ],
    ],
].
--- Expected
+++ Actual
@@ @@
       'propertyPath' => 'condition',
       'message' => 'This value should be of type .',
       'code' => 'ba785a8c-82cb-4283-967c-3cf342181b40',
-      'hint' => 'The data must belong to a backed enumeration of type App\\Enum\\BookCondition',
+      'hint' => 'The data must be one of the following values: \'https://schema.org/NewCondition\', \'https://schema.org/RefurbishedCondition\', \'https://schema.org/DamagedCondition\', \'https://schema.org/UsedCondition\'',
     ),
   ),
   'detail' => 'condition: This value should be of type .',
   'type' => '/validation_errors/ba785a8c-82cb-4283-967c-3cf342181b40',
-  'hydra:description' => 'condition: This value should be of type int|string.',
+  'hydra:description' => 'condition: This value should be of type .',
   'hydra:title' => 'An error occurred',
 )

/app/vendor/api-platform/symfony/Bundle/Test/Constraint/ArraySubsetTrait.php:63
/app/vendor/api-platform/symfony/Bundle/Test/Constraint/ArraySubset.php:32
/app/vendor/api-platform/symfony/Bundle/Test/ApiTestAssertionsTrait.php:106
/app/vendor/api-platform/symfony/Bundle/Test/ApiTestAssertionsTrait.php:65
/app/tests/Api/Admin/BookTest.php:493

4) App\Tests\Api\Admin\BookTest::asAdminUserICannotUpdateABookWithInvalidData@invalid condition with data (['https://gutendex.com/books/31547.json', 'invalid condition'], 422, ['ConstraintViolation', 'An error occurred', 'condition: This value should ...tring.', [['condition', 'The data must belong to a bac...dition']]], ...2 more elements)
Failed asserting that an array has the subset Array &0 [
    '@type' => 'ConstraintViolation',
    'hydra:title' => 'An error occurred',
    'hydra:description' => 'condition: This value should be of type int|string.',
    'violations' => Array &1 [
        0 => Array &2 [
            'propertyPath' => 'condition',
            'hint' => 'The data must belong to a backed enumeration of type App\Enum\BookCondition',
        ],
    ],
].
--- Expected
+++ Actual
@@ @@
       'propertyPath' => 'condition',
       'message' => 'This value should be of type .',
       'code' => 'ba785a8c-82cb-4283-967c-3cf342181b40',
-      'hint' => 'The data must belong to a backed enumeration of type App\\Enum\\BookCondition',
+      'hint' => 'The data must be one of the following values: \'https://schema.org/NewCondition\', \'https://schema.org/RefurbishedCondition\', \'https://schema.org/DamagedCondition\', \'https://schema.org/UsedCondition\'',
     ),
   ),
   'detail' => 'condition: This value should be of type .',
   'type' => '/validation_errors/ba785a8c-82cb-4283-967c-3cf342181b40',
-  'hydra:description' => 'condition: This value should be of type int|string.',
+  'hydra:description' => 'condition: This value should be of type .',
   'hydra:title' => 'An error occurred',
 )

/app/vendor/api-platform/symfony/Bundle/Test/Constraint/ArraySubsetTrait.php:63
/app/vendor/api-platform/symfony/Bundle/Test/Constraint/ArraySubset.php:32
/app/vendor/api-platform/symfony/Bundle/Test/ApiTestAssertionsTrait.php:106
/app/vendor/api-platform/symfony/Bundle/Test/ApiTestAssertionsTrait.php:65
/app/tests/Api/Admin/BookTest.php:493

FAILURES!
Tests: 123, Assertions: 546, Failures: 4, PHPUnit Notices: 27.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with these changes:

-      'hint' => 'The data must belong to a backed enumeration of type App\\Enum\\BookCondition',
+      'hint' => 'The data must be one of the following values: \'https://schema.org/NewCondition\', \'https://schema.org/RefurbishedCondition\', \'https://schema.org/DamagedCondition\', \'https://schema.org/UsedCondition\'',

The problem is about those changes, which are incomplete:

-  'hydra:description' => 'condition: This value should be of type int|string.',
+  'hydra:description' => 'condition: This value should be of type .',

So indeed you can set symfony/serializer: <8.0.5, and then you (or I, if you don't have time) can investigate for a fix on Symfony/API Platform (depends where the problem is).

Copy link
Contributor

@vincentchalamon vincentchalamon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't the symfony.lock be updated too?


E2E tests because of the following error:

PHP Fatal error: Uncaught Error: Class "Runtime\FrankenPhpSymfony\Runtime" not found in /app/vendor/autoload_runtime.php:19\nStack trace:\n#0 /app/public/index.php(7): require_once()\n#1 {main}\n thrown in /app/vendor/autoload_runtime.php on line 19

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use short syntax: Book instead of \App\Entity\Book (same for Proxy).

(same comments for other Foundry factories)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same problem than #580 (comment)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to https://symfony.com/blog/new-in-symfony-7-4-better-php-configuration, the composer.json file must be updated accordingly:

You should commit it to your repository and optionally add a new entry in the autoload section of composer.json (for example, "classmap": ["config/"]).

"symfony/property-access": "8.0.*",
"symfony/runtime": "8.0.*",
"symfony/security-bundle": "8.0.*",
"symfony/serializer": "8.0.4",

This comment was marked as resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants