Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-2953

ArrayHydrator: Not all items hydrated while orderBy

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Critical Critical
    • Resolution: Unresolved
    • Affects Version/s: 2.3.4, 2.4.1
    • Fix Version/s: None
    • Component/s: ORM
    • Security Level: All
    • Labels:
    • Environment:
      Linux and Windows, PHP5

      Description

      I will explain the problem using example and pseudo-code:

      I have query like that:
      SELECT (...) FROM order LEFT JOIN person LEFT JOIN identifier (...) order by (...)

      The rows returned by query are following (the order is very important):
      order_id|person_id|identifier_id|
      12 |21 |33 |
      12 |21 |34 |
      11 |21 |35 |
      11 |21 |33 |
      11 |21 |34 |
      12 |21 |35 |

      After hydration the result is like:
      result[0][person][identifier][0][id]=33
      result[0][person][identifier][0][id]=34
      result[1][person][identifier][0][id]=35
      result[1][person][identifier][0][id]=34

      But it should be:
      result[0][person][identifier][0][id]=33
      result[0][person][identifier][0][id]=34
      result[0][person][identifier][0][id]=35
      result[1][person][identifier][0][id]=35
      result[1][person][identifier][0][id]=34
      result[1][person][identifier][0][id]=33

      The reason is that ArrayHydrator::_identifierMap contains only object id and parents object id. In may example there is difference in parents parent (grandparent) id.

      1. Array_hydrator_4.2_bugfix.php
        12 kB
        Mariusz Jaskółka
      2. Array_Hydrator_4.2.php
        11 kB
        Mariusz Jaskółka
      3. ArrayHydrator.php
        12 kB
        Mariusz Jaskółka

        Activity

        Hide
        Marco Pivetta added a comment - - edited

        Mariusz Jaskółka, I've applied your hotfix at https://github.com/doctrine/doctrine2/commit/c05921032ff6947daca2d7275031e5cde4700634 and the tests seem to pass on my system and on travis. You may want to check it out and see if it works for your use case.

        Show
        Marco Pivetta added a comment - - edited Mariusz Jaskółka , I've applied your hotfix at https://github.com/doctrine/doctrine2/commit/c05921032ff6947daca2d7275031e5cde4700634 and the tests seem to pass on my system and on travis. You may want to check it out and see if it works for your use case.
        Hide
        Mariusz Jaskółka added a comment -

        It works for my use case correctly. You apparently forgot to remove/comment line 82 which is not necessary now.

        Show
        Mariusz Jaskółka added a comment - It works for my use case correctly. You apparently forgot to remove/comment line 82 which is not necessary now.
        Hide
        Marco Pivetta added a comment -

        Mariusz Jaskółka fixed, thanks!

        Show
        Marco Pivetta added a comment - Mariusz Jaskółka fixed, thanks!
        Hide
        Marco Pivetta added a comment -

        I don't think we'll have a fix for this issue for 2.5, as it will probably require a complete rewrite of the array hydrator

        Show
        Marco Pivetta added a comment - I don't think we'll have a fix for this issue for 2.5, as it will probably require a complete rewrite of the array hydrator
        Hide
        Guilherme Blanco added a comment -

        ... and introducing BC breaks.

        Show
        Guilherme Blanco added a comment - ... and introducing BC breaks.

          People

          • Assignee:
            Guilherme Blanco
            Reporter:
            Mariusz Jaskółka
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated: