Doctrine 1
  1. Doctrine 1
  2. DC-1056

Doctrine is not compatible with PHP 5.4 due to change in serialize() behaviour.

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 1.2.3
    • Fix Version/s: None
    • Component/s: Record, Relations
    • Labels:
      None
    • Environment:
      PHP 5.4+

      Description

      In PHP 5.4 there is a change in the way the object references are serialized:

      Quote:
      "Support for object references in recursive serialize() calls
      Prior to PHP 5.4, object references where not saved in recursive serialize calls."

      This minor change, breaks down serialization of collections when column of type "array" is present - double serialization occurs.
      I'm attaching a patch fixing the issue.

        Activity

        Marcin Gil created issue -
        Marcin Gil made changes -
        Field Original Value New Value
        Description In PHP 5.4 there is a change in the way the object references are serialized:

        Quote:
        "Support for object references in recursive serialize() calls
        Prior to PHP 5.4, object references where not saved in recursive serialize calls."

        This minor change, which is in fact a resolution of a bug report ( https://bugs.php.net/bug.php?id=36424 ), breaks down possibility to serialize collections together with relations ( by usage of ->serializeReferences(true); ).
        This issue results in absense of some of the referenced objects upon unserialization.
        The missing objects are objects which are present more than once (more than one record has the same relation), only the first occurence of the object is preserved.

        The below DIFF explains the difference between PHP 5.3 and PHP 5.3 serialization output on the example of doctrine collection:
        http://diffchecker.com/9L51AtF6

        I tried to create a testCase to debug this issue (attached), however I still must be missing a key difference between Doctrine and the testCase, as the testCase maintains all the referenced objects.

        I am afraid that many Doctrine users may encounter this issue when it is too late (PHP may be automatically updated to 5.4 on some servers).
        I would be grateful is someone could look into the issue, it is possible I have failed to notice something trivial.

        In PHP 5.4 there is a change in the way the object references are serialized:

        Quote:
        "Support for object references in recursive serialize() calls
        Prior to PHP 5.4, object references where not saved in recursive serialize calls."

        This minor change, breaks down serialization of collections when column of type "array" is present - double serialization occurs.
        I'm attaching a patch fixing the issue.

        Attachment Record.php.patch [ 11197 ]
        Marcin Gil made changes -
        Attachment testCase1.php [ 11196 ]
        Hide
        Colin Darie added a comment -

        I confirm for possible future readers: this patch works perfectly well. (cf github for several forks of doctrine with other bugfixes).

        Show
        Colin Darie added a comment - I confirm for possible future readers: this patch works perfectly well. (cf github for several forks of doctrine with other bugfixes).
        Hide
        steven added a comment -

        Hi all, does somebody knows where can I get a copy of the Doctrine 1.2.4 version but running on php 5.4?
        Thise version you're talking about

        Thanks

        Show
        steven added a comment - Hi all, does somebody knows where can I get a copy of the Doctrine 1.2.4 version but running on php 5.4? Thise version you're talking about Thanks
        Hide
        Marcin Gil added a comment -

        I sent you URL to our private svn repo.

        Show
        Marcin Gil added a comment - I sent you URL to our private svn repo.
        Hide
        steven added a comment -

        Thanks, you've saved mi life

        Show
        steven added a comment - Thanks, you've saved mi life
        Marcin Gil made changes -
        Attachment Record.php.patch [ 11197 ]
        Hide
        Marcin Gil added a comment -

        New, better patch.

        Show
        Marcin Gil added a comment - New, better patch.
        Marcin Gil made changes -
        Attachment Record.php.patch [ 11633 ]
        Hide
        Marcin Gil added a comment -

        Hi, I have uploaded a better patch which resolved one more issue.

        Show
        Marcin Gil added a comment - Hi, I have uploaded a better patch which resolved one more issue.
        Hide
        Christophe Coevoet added a comment -

        Please use a pull request on github to submit a patch

        Show
        Christophe Coevoet added a comment - Please use a pull request on github to submit a patch

        This list may be incomplete, as errors occurred whilst retrieving source from linked applications:

        • Request to http://www.doctrine-project.org/fisheye/ failed: Error in remote call to 'FishEye 0 (http://www.doctrine-project.org/fisheye/)' (http://www.doctrine-project.org/fisheye) [AbstractRestCommand{path='/rest-service-fe/search-v1/crossRepositoryQuery', params={query=DC-1056, expand=changesets[0:20].revisions[0:29],reviews}, methodType=GET}] : Received status code 503 (Service Temporarily Unavailable)

          People

          • Assignee:
            Jonathan H. Wage
            Reporter:
            Marcin Gil
          • Votes:
            2 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated: