Skip to content

After update from version 2.20.0 to 2.20.1 the Hydratation generate unexpected Warning #11783

@tomasjanicek

Description

@tomasjanicek

Bug Report

Q A
Version 2.20.1
Previous Version if the bug is a regression 2.20.0

Summary

After updating to the latest version, hydration is not working properly. It generates a warning that ends up throwing an exception in the application.

Current behavior

The application runs on symfony 6.4 LTS. and PHP 8.4
we have ManyToMany connection between entitites...

class Lector {
   ...
    #[ORM\JoinTable(name: 'lector_domains')]
    #[ORM\ManyToMany(targetEntity: Domain::class, indexBy: 'id')]
    protected Collection $domains;
}

composer doctrine depedencies:

        "doctrine/dbal": "^3.5",
        "doctrine/doctrine-bundle": "^2.7",
        "doctrine/doctrine-fixtures-bundle": "^3.4",
        "doctrine/doctrine-migrations-bundle": "^3.2",
        "doctrine/mongodb-odm": "^2.4",
        "doctrine/orm": "2.20.1",

Stack trace:

ErrorException:
Warning: Undefined array key "id_1"

  at vendor/doctrine/orm/src/Internal/Hydration/ObjectHydrator.php:509
  at Doctrine\ORM\Internal\Hydration\ObjectHydrator->hydrateRowData()
     (vendor/doctrine/orm/src/Internal/Hydration/ObjectHydrator.php:149)
  at Doctrine\ORM\Internal\Hydration\ObjectHydrator->hydrateAllData()
     (vendor/doctrine/orm/src/Internal/Hydration/AbstractHydrator.php:272)
  at Doctrine\ORM\Internal\Hydration\AbstractHydrator->hydrateAll()
     (vendor/doctrine/orm/src/Persisters/Entity/BasicEntityPersister.php:1034)
  at Doctrine\ORM\Persisters\Entity\BasicEntityPersister->loadCollectionFromStatement()
     (vendor/doctrine/orm/src/Persisters/Entity/BasicEntityPersister.php:1044)
  at Doctrine\ORM\Persisters\Entity\BasicEntityPersister->loadManyToManyCollection()
     (vendor/doctrine/orm/src/UnitOfWork.php:3305)
  at Doctrine\ORM\UnitOfWork->loadCollection()
     (vendor/doctrine/orm/src/PersistentCollection.php:706)
  at Doctrine\ORM\PersistentCollection->doInitialize()
     (vendor/doctrine/orm/src/PersistentCollection.php:218)
  at Doctrine\ORM\PersistentCollection->initialize()
     (vendor/doctrine/collections/src/AbstractLazyCollection.php:157)
  at Doctrine\Common\Collections\AbstractLazyCollection->toArray()
     (src/Seduo/Core/Entity/WithDomainsTrait.php:22)
  at Seduo\Core\Entity\Lector->getDomains()
     (src/Seduo/Core/Entity/Course.php:445)
  at Seduo\Core\Entity\Course::{closure:Seduo\Core\Entity\Course::getLectors():444}()
  at array_filter()
     (vendor/doctrine/collections/src/ArrayCollection.php:381)
  at Doctrine\Common\Collections\ArrayCollection->filter()
     (vendor/doctrine/collections/src/AbstractLazyCollection.php:239)
  at Doctrine\Common\Collections\AbstractLazyCollection->filter()
     (src/Seduo/Core/Entity/Course.php:444)
  at Seduo\Core\Entity\Course->getLectors()
     (src/Seduo/Core/Entity/Course.php:457)
  at Seduo\Core\Entity\Course->hasLectors()
     (src/Seduo/AdminBundle/Grid/Courses/Builder/CourseRowBuilder.php:47)
  at Seduo\AdminBundle\Grid\Courses\Builder\CourseRowBuilder->buildFromObject()
     (src/Seduo/Grid/Factory/GridFactory.php:51)
  at Seduo\Grid\Factory\GridFactory->createGrid()
     (src/Seduo/AdminBundle/Grid/Courses/CoursesGridFactory.php:53)
  at Seduo\AdminBundle\Grid\Courses\CoursesGridFactory->create()
     (src/Seduo/AdminBundle/Controller/CoursesController.php:62)
  at Seduo\AdminBundle\Controller\CoursesController->filterableList()
     (vendor/symfony/http-kernel/HttpKernel.php:181)
  at Symfony\Component\HttpKernel\HttpKernel->handleRaw()
     (vendor/symfony/http-kernel/HttpKernel.php:76)
  at Symfony\Component\HttpKernel\HttpKernel->handle()
     (vendor/symfony/http-kernel/Kernel.php:197)
  at Symfony\Component\HttpKernel\Kernel->handle()
     (vendor/symfony/http-kernel/HttpCache/SubRequestHandler.php:86)
  at Symfony\Component\HttpKernel\HttpCache\SubRequestHandler::handle()
     (vendor/symfony/http-kernel/HttpCache/HttpCache.php:476)
  at Symfony\Component\HttpKernel\HttpCache\HttpCache->forward()
     (vendor/symfony/framework-bundle/HttpCache/HttpCache.php:68)
  at Symfony\Bundle\FrameworkBundle\HttpCache\HttpCache->forward()
     (vendor/symfony/http-kernel/HttpCache/HttpCache.php:451)
  at Symfony\Component\HttpKernel\HttpCache\HttpCache->fetch()
     (vendor/symfony/http-kernel/HttpCache/HttpCache.php:349)
  at Symfony\Component\HttpKernel\HttpCache\HttpCache->lookup()
     (vendor/symfony/http-kernel/HttpCache/HttpCache.php:222)
  at Symfony\Component\HttpKernel\HttpCache\HttpCache->handle()
     (vendor/symfony/runtime/Runner/Symfony/HttpKernelRunner.php:35)
  at Symfony\Component\Runtime\Runner\Symfony\HttpKernelRunner->run()
     (vendor/autoload_runtime.php:30)
  at require_once('/srv/www/seduo/vendor/autoload_runtime.php')
     (web/app_dev.php:7)                

Expected behavior

does not generate a warning..

How to reproduce

for us it was reflected in the fact that we updated from version 2.20.0 to 2.20.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions