Skip to content

DateTime normalization bug with GetSetMethodNormalizer() when using HHVM #10229

@gitnik

Description

@gitnik

I have the following array of entities:

array(2) {
  [0]=>
  object(JustNik\CoreBundle\Entity\Entry)#2955 (4) {
    ["id":protected]=>
    int(1)
    ["title":protected]=>
    string(7) "title 1"
    ["date":protected]=>
    object(DateTime)#2956 (0) {
    }
    ["markdown":protected]=>
    NULL
  }
  [1]=>
  object(JustNik\CoreBundle\Entity\Entry)#2967 (4) {
    ["id":protected]=>
    int(2)
    ["title":protected]=>
    string(7) "title 2"
    ["date":protected]=>
    object(DateTime)#2968 (0) {
    }
    ["markdown":protected]=>
    NULL
  }
}

When I try to normalize one element wth the following code:

$normalizers = array(new GetSetMethodNormalizer());
$serializer = new Serializer($normalizers);
$serializer->normalize($entries[0]);

I get this (obviously shortened)

array(4) {
  ["id"]=>
  int(1)
  ["title"]=>
  string(7) "title 1"
  ["date"]=>
  array(4) {
    ["lastErrors"]=>
    array(4) {
      ["warning_count"]=>
      int(0)
      ["warnings"]=>
      array(0) {
      }
      ["error_count"]=>
      int(0)
      ["errors"]=>
      array(0) {
      }
    }
    ["offset"]=>
    int(3600)
    ["timestamp"]=>
    int(1392058587)
    ["timezone"]=>
    array(3) {
      ["location"]=>
      array(4) {
        ["country_code"]=>
        string(0) ""
        ["latitude"]=>
        float(0)
        ["longitude"]=>
        float(0)
        ["comments"]=>
        NULL
      }
      ["name"]=>
      string(13) "Europe/Berlin"
      ["transitions"]=>
      array(144) {
        [0]=>
        array(5) {
          ["ts"]=>
          int(-1693706400)
          ["time"]=>
          string(24) "1916-05-01T00:00:00+0200"
          ["offset"]=>
          int(7200)
          ["isdst"]=>
          bool(true)
          ["abbr"]=>
          string(4) "CEST"
        }
        [1]=>
        array(5) {
          ["ts"]=>
          int(-1680483600)
          ["time"]=>
          string(24) "1916-10-01T00:00:00+0100"
          ["offset"]=>
          int(3600)
          ["isdst"]=>
          bool(false)
          ["abbr"]=>
          string(3) "CET"
        }
        ..... more entries which times keep increasing with every entry
        [143]=>
        array(5) {
          ["ts"]=>
          int(2140045200)
          ["time"]=>
          string(24) "2037-10-25T02:00:00+0100"
          ["offset"]=>
          int(3600)
          ["isdst"]=>
          bool(false)
          ["abbr"]=>
          string(3) "CET"
        }
      }
    }
  }
  ["markdown"]=>
  NULL
}

I'm not sure whether this is a bug or I just missed a configuration option which causes this behaviour

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions