Doctrine 1
  1. Doctrine 1
  2. DC-22

Record instances are shared; local data is overwritten.

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Blocker Blocker
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Record
    • Labels:
      None
    • Environment:
      LAMP, PHP 5.2.9 & 5.3.0

      Description

      If I make changes to the properties of an instance of a record but don't persist them (so the record's dirty), then in a separate process hydrate another record instance, the original record instance's properties are altered.

      I'm not aware of all the instances in which this happens, but it definitely occurs when finding records through a DQL query or loading related records.

      This is particularly troublesome since we're experiencing the loading of one record affecting another instance thousands of lines of code away. It seems like the records are shared somehow. This occurs without any caching of any kind.

      I'd really appreciate someone taking a look at this. Example and test attached.

      1. 2486TestCase.php
        3 kB
        Craig Marvelley
      2. index.php
        2 kB
        Craig Marvelley

        Activity

        Hide
        Roman S. Borschel added a comment -

        This is unfortunately the default behavior of Doctrine 1.x. Because of backwards compatibility this default behavior can not be easily changed. However, some time ago a new attribute was introduced: Doctrine::ATTR_HYDRATE_OVERWRITE. You can set this to FALSE which does what you want I think. Doctrine 2 already behaves this way by default.

        Show
        Roman S. Borschel added a comment - This is unfortunately the default behavior of Doctrine 1.x. Because of backwards compatibility this default behavior can not be easily changed. However, some time ago a new attribute was introduced: Doctrine::ATTR_HYDRATE_OVERWRITE. You can set this to FALSE which does what you want I think. Doctrine 2 already behaves this way by default.
        Hide
        Craig Marvelley added a comment -

        Ah, fab. Sounds like what I need! Missed it in the docs, sorry. Is there a list somewhere of all the settings and what they do? That would be handy if not, since they seem to be dotted around the manual at the moment so they're easy to miss. Are there any other side effects I should be expecting if I turn that setting on? Thanks!

        Show
        Craig Marvelley added a comment - Ah, fab. Sounds like what I need! Missed it in the docs, sorry. Is there a list somewhere of all the settings and what they do? That would be handy if not, since they seem to be dotted around the manual at the moment so they're easy to miss. Are there any other side effects I should be expecting if I turn that setting on? Thanks!
        Hide
        Roman S. Borschel added a comment -

        I dont think any such list exists. As you said all of the attributes are spread throughout the documentation. You can create an issue as an enhancement request for the documentation for that.

        Setting that attribute to false should have no other side effects. It really only affects hydration and controls whether the values from the database or the local values should be considered "newer" and therefore kept around.

        I will close this issue. If the attribute does not solve your issue, please let us know.

        Show
        Roman S. Borschel added a comment - I dont think any such list exists. As you said all of the attributes are spread throughout the documentation. You can create an issue as an enhancement request for the documentation for that. Setting that attribute to false should have no other side effects. It really only affects hydration and controls whether the values from the database or the local values should be considered "newer" and therefore kept around. I will close this issue. If the attribute does not solve your issue, please let us know.

          People

          • Assignee:
            Roman S. Borschel
            Reporter:
            Craig Marvelley
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: