Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-2784

Invalid cache entries on 32bit arch when PHP_MAX_INT is hit

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Can't Fix
    • Affects Version/s: 2.3.1
    • Fix Version/s: None
    • Component/s: ORM
    • Security Level: All
    • Labels:
    • Environment:

      Description

      On machines which max int size is 2147483647, when entry from the database is hydrated and it's id goes thru convertToPHPValue of IntegerType, integer overflow occurs which leads to wrong entry returned from the gatherRowData() method in the AbstractHydrator

      When the result from the repository is requested as Object, the whole object is returned from the cache which leads to wrong data returned from the repository.

      string(10) "2186935411"
      string(31) "Doctrine\DBAL\Types\IntegerType"
      int(2147483647)
      
      Raw Data:
      Array
      (
          [id0] => 2186935411
      ....
      )
      
      Hydrated Data:
      array(1) {
        'r' =>
        array(6) {
          'id' =>
          int(2147483647)
      

      When the result is hydrated as scalar or array, only the id of the entry remains same, the data is fetched correctly from the table.

      Workaround would be to stop looking into the cache when the id of the result hits the PHP_MAX_INT of the system.

        Activity

        Hide
        Marco Pivetta added a comment -

        Julian Ivanov shouldn't you map the field as a `decimal` or as a `string` when you hit those barriers?

        Show
        Marco Pivetta added a comment - Julian Ivanov shouldn't you map the field as a `decimal` or as a `string` when you hit those barriers?
        Hide
        Julian Ivanov added a comment -

        Yes this really helps. But the default behaviour is a little bit tricky and can lead to nasty bugs in production. You can consider this as "known issue" then.

        Show
        Julian Ivanov added a comment - Yes this really helps. But the default behaviour is a little bit tricky and can lead to nasty bugs in production. You can consider this as "known issue" then.
        Hide
        Marco Pivetta added a comment -

        Marking as can't fix: if we hit limitations of the engine about usage of integers, we need to use strings for storing larger numbers.

        Show
        Marco Pivetta added a comment - Marking as can't fix: if we hit limitations of the engine about usage of integers, we need to use strings for storing larger numbers.

          People

          • Assignee:
            Marco Pivetta
            Reporter:
            Julian Ivanov
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: