Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-168

serialization/unserialization of ClassMetadata lose reflFields order causing insertSql statement to fail

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Critical Critical
    • Resolution: Fixed
    • Affects Version/s: 2.0-ALPHA4
    • Fix Version/s: 2.0-ALPHA4
    • Component/s: ORM
    • Security Level: All
    • Labels:
      None

      Description

      This problem will be difficult to reproduce for you, but I isolated the exact cause of it.

      To reproduce

      • Use any MetadataCache
      • Create a complex entity with some inheritance. (I may detail in later if your really need it)
      • Create an element of this entity with persist.
      • Create an other element of this entity but not on the same php run. (ex: reload the page)
      • The insert statement will fail because field names will not match parameters.

      I narrowed it down to a serialization issue.

      When you serialize an MetadataInfo, you don't serialize reflFields.
      When you unserizlize you regenerate this value using ReflectionClass
      That sound's like a good optimization.

      The problem is that somehow, the reflection class can return the fields not in the same order that they were at the initial creation of the MetadataInfo.

      Because the insertSql value is not re-generated, it can be out of sync with the new fields order.

      The solution :
      Call something like MetadataInfoFactory::_generateStaticSql (whish is private but ...) at wakeup time.

        Activity

        Hide
        Eric Durand-Tremblay added a comment -
           
            [1] => 1  (fna_parent_record_id)
        (expected record_id)
            [2] => George Simard2 (display_name)
            [3] => Simard2 (last_name)
            [4] => (maiden_name)
            [5] => George (first_name)
            [6] => (civility)
            [7] => MALE (gender)
            [8] => 1962-09-14 (birthdate)
            [9] => Plomberie ABC Inc. (employer)
            [10] => Plombier (employment)
            [11] => (employment_from)
            [12] => MARRIED (civil_status)
            [13] => (civil_status_from)
            [14] => INSURABLE (insurability)
            [15] => 5 (rev_no)
            [16] => 2009-12-07 08:54:46 (created_at)
            [17] => 2009-12-07 08:54:46 (modified_at)
            [18] =>  Eric Durand-Tremblay (created_by)
            [19] =>  Eric Durand-Tremblay (modified_by)
            [20] => 1 (record_id) !! Should be in position  2
            [21] => (fna_client_fna_id)
            [22] => (fna_spouse_fna_id)
        
        
        Show
        Eric Durand-Tremblay added a comment - [1] => 1 (fna_parent_record_id) (expected record_id) [2] => George Simard2 (display_name) [3] => Simard2 (last_name) [4] => (maiden_name) [5] => George (first_name) [6] => (civility) [7] => MALE (gender) [8] => 1962-09-14 (birthdate) [9] => Plomberie ABC Inc. (employer) [10] => Plombier (employment) [11] => (employment_from) [12] => MARRIED (civil_status) [13] => (civil_status_from) [14] => INSURABLE (insurability) [15] => 5 (rev_no) [16] => 2009-12-07 08:54:46 (created_at) [17] => 2009-12-07 08:54:46 (modified_at) [18] => Eric Durand-Tremblay (created_by) [19] => Eric Durand-Tremblay (modified_by) [20] => 1 (record_id) !! Should be in position 2 [21] => (fna_client_fna_id) [22] => (fna_spouse_fna_id)
        Hide
        Benjamin Eberlei added a comment -

        I could reproduce the issue and generated a failing test for this. We already discussed how this might be fixed.

        Show
        Benjamin Eberlei added a comment - I could reproduce the issue and generated a failing test for this. We already discussed how this might be fixed.
        Hide
        Eric Durand-Tremblay added a comment -

        This is a very good news !

        Show
        Eric Durand-Tremblay added a comment - This is a very good news !
        Hide
        Roman S. Borschel added a comment -

        Should be fixed now.

        Show
        Roman S. Borschel added a comment - Should be fixed now.
        Hide
        Eric Durand-Tremblay added a comment -

        Resolution confirmed.

        Thank your for your great work !

        Show
        Eric Durand-Tremblay added a comment - Resolution confirmed. Thank your for your great work !

          People

          • Assignee:
            Roman S. Borschel
            Reporter:
            Eric Durand-Tremblay
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: