Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-2494

Proxy getId not invoke convertToPHPValue on custom type

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Critical Critical
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.4
    • Component/s: None
    • Security Level: All
    • Labels:
      None

      Description

      I have a custom type tinyint:
      https://gist.github.com/entering/3503d7458e5fbe2f6e02

      I was using it a lot and when I updated to doctrine 2.4 beta it break some stuff. At the time i turn all on smallint and solve the problem, now I had time to look into it.

      Example, entity Currency:

          /**
           * @var integer
           *
           * @ORM\Column(name="id", type="tinyint", nullable=false, options={"unsigned": true})
           * @ORM\Id
           * @ORM\GeneratedValue(strategy="AUTO")
           */
          protected $id;
      
          /**
           * @ORM\Column(name="temp", type="tinyint", nullable=false)
           */
          protected $temp;
      

      Entity Campaign:

          /**
           * @var Currency
           *
           * @ORM\ManyToOne(targetEntity="Currency", inversedBy="campaigns")
           * @ORM\JoinColumns({
           *   @ORM\JoinColumn(name="currency_id", referencedColumnName="id", nullable=false)
           * })
           */
          protected $currency;
      

      When i have this piece of code:

      var_dump($campaign->getCurrency()->getId());
      var_dump($campaign->getCurrency()->getTemp());
      

      I get:
      string(1) "1"
      int(5)

      If I turn id into small int:
      int(1)
      int(5)

      If I switch the order to:

      var_dump($campaign->getCurrency()->getTemp());
      var_dump($campaign->getCurrency()->getId());
      

      As expected:
      int(5)
      int(1)

      If I place a var_dump on convertToPHPValue I can see that is not being called on getId when getId is lazy.

      This looks like a bug introduced when getId started being lazy to save queries.

        Activity

        Eduardo Oliveira created issue -
        Eduardo Oliveira made changes -
        Field Original Value New Value
        Description I have a custom type tinyint:
        https://gist.github.com/entering/3503d7458e5fbe2f6e02

        I was using it a lot and when I updated to doctrine 2.4 beta it break some stuff. At the time i turn all on smallint and solve the problem, know I had time to look into it and a entity Currency:

        {code}
            /**
             * @var integer
             *
             * @ORM\Column(name="id", type="tinyint", nullable=false, options={"unsigned": true})
             * @ORM\Id
             * @ORM\GeneratedValue(strategy="AUTO")
             */
            protected $id;

            /**
             * @ORM\Column(name="temp", type="tinyint", nullable=false)
             */
            protected $temp;
        {code}

        And another entity:

        {code}
            /**
             * @var Currency
             *
             * @ORM\ManyToOne(targetEntity="Currency", inversedBy="campaigns")
             * @ORM\JoinColumns({
             * @ORM\JoinColumn(name="currency_id", referencedColumnName="id", nullable=false)
             * })
             */
            protected $currency;
        {code}

        When i have this piece of code:

        {code}
        var_dump($campaign->getCurrency()->getId());
        var_dump($campaign->getCurrency()->getTemp());
        {code}

        I get:
        string(1) "1"
        int(5)

        If I turn id into small int:
        int(1)
        int(5)

        If I switch the order to:
        {code}
        var_dump($campaign->getCurrency()->getTemp());
        var_dump($campaign->getCurrency()->getId());
        {code}

        As expected:
        int(5)
        int(1)

        If I place a var_dump on convertToPHPValue I can see that is not being called on getId when getId is lazy.
        I have a custom type tinyint:
        https://gist.github.com/entering/3503d7458e5fbe2f6e02

        I was using it a lot and when I updated to doctrine 2.4 beta it break some stuff. At the time i turn all on smallint and solve the problem, know I had time to look into it and a entity Currency:

        {code}
            /**
             * @var integer
             *
             * @ORM\Column(name="id", type="tinyint", nullable=false, options={"unsigned": true})
             * @ORM\Id
             * @ORM\GeneratedValue(strategy="AUTO")
             */
            protected $id;

            /**
             * @ORM\Column(name="temp", type="tinyint", nullable=false)
             */
            protected $temp;
        {code}

        And another entity:

        {code}
            /**
             * @var Currency
             *
             * @ORM\ManyToOne(targetEntity="Currency", inversedBy="campaigns")
             * @ORM\JoinColumns({
             * @ORM\JoinColumn(name="currency_id", referencedColumnName="id", nullable=false)
             * })
             */
            protected $currency;
        {code}

        When i have this piece of code:

        {code}
        var_dump($campaign->getCurrency()->getId());
        var_dump($campaign->getCurrency()->getTemp());
        {code}

        I get:
        string(1) "1"
        int(5)

        If I turn id into small int:
        int(1)
        int(5)

        If I switch the order to:
        {code}
        var_dump($campaign->getCurrency()->getTemp());
        var_dump($campaign->getCurrency()->getId());
        {code}

        As expected:
        int(5)
        int(1)

        If I place a var_dump on convertToPHPValue I can see that is not being called on getId when getId is lazy.

        This looks like a bug introduced when getId started being lazy to save queries.
        Eduardo Oliveira made changes -
        Description I have a custom type tinyint:
        https://gist.github.com/entering/3503d7458e5fbe2f6e02

        I was using it a lot and when I updated to doctrine 2.4 beta it break some stuff. At the time i turn all on smallint and solve the problem, know I had time to look into it and a entity Currency:

        {code}
            /**
             * @var integer
             *
             * @ORM\Column(name="id", type="tinyint", nullable=false, options={"unsigned": true})
             * @ORM\Id
             * @ORM\GeneratedValue(strategy="AUTO")
             */
            protected $id;

            /**
             * @ORM\Column(name="temp", type="tinyint", nullable=false)
             */
            protected $temp;
        {code}

        And another entity:

        {code}
            /**
             * @var Currency
             *
             * @ORM\ManyToOne(targetEntity="Currency", inversedBy="campaigns")
             * @ORM\JoinColumns({
             * @ORM\JoinColumn(name="currency_id", referencedColumnName="id", nullable=false)
             * })
             */
            protected $currency;
        {code}

        When i have this piece of code:

        {code}
        var_dump($campaign->getCurrency()->getId());
        var_dump($campaign->getCurrency()->getTemp());
        {code}

        I get:
        string(1) "1"
        int(5)

        If I turn id into small int:
        int(1)
        int(5)

        If I switch the order to:
        {code}
        var_dump($campaign->getCurrency()->getTemp());
        var_dump($campaign->getCurrency()->getId());
        {code}

        As expected:
        int(5)
        int(1)

        If I place a var_dump on convertToPHPValue I can see that is not being called on getId when getId is lazy.

        This looks like a bug introduced when getId started being lazy to save queries.
        I have a custom type tinyint:
        https://gist.github.com/entering/3503d7458e5fbe2f6e02

        I was using it a lot and when I updated to doctrine 2.4 beta it break some stuff. At the time i turn all on smallint and solve the problem, now I had time to look into it and a entity Currency:

        {code}
            /**
             * @var integer
             *
             * @ORM\Column(name="id", type="tinyint", nullable=false, options={"unsigned": true})
             * @ORM\Id
             * @ORM\GeneratedValue(strategy="AUTO")
             */
            protected $id;

            /**
             * @ORM\Column(name="temp", type="tinyint", nullable=false)
             */
            protected $temp;
        {code}

        And another entity:

        {code}
            /**
             * @var Currency
             *
             * @ORM\ManyToOne(targetEntity="Currency", inversedBy="campaigns")
             * @ORM\JoinColumns({
             * @ORM\JoinColumn(name="currency_id", referencedColumnName="id", nullable=false)
             * })
             */
            protected $currency;
        {code}

        When i have this piece of code:

        {code}
        var_dump($campaign->getCurrency()->getId());
        var_dump($campaign->getCurrency()->getTemp());
        {code}

        I get:
        string(1) "1"
        int(5)

        If I turn id into small int:
        int(1)
        int(5)

        If I switch the order to:
        {code}
        var_dump($campaign->getCurrency()->getTemp());
        var_dump($campaign->getCurrency()->getId());
        {code}

        As expected:
        int(5)
        int(1)

        If I place a var_dump on convertToPHPValue I can see that is not being called on getId when getId is lazy.

        This looks like a bug introduced when getId started being lazy to save queries.
        Eduardo Oliveira made changes -
        Description I have a custom type tinyint:
        https://gist.github.com/entering/3503d7458e5fbe2f6e02

        I was using it a lot and when I updated to doctrine 2.4 beta it break some stuff. At the time i turn all on smallint and solve the problem, now I had time to look into it and a entity Currency:

        {code}
            /**
             * @var integer
             *
             * @ORM\Column(name="id", type="tinyint", nullable=false, options={"unsigned": true})
             * @ORM\Id
             * @ORM\GeneratedValue(strategy="AUTO")
             */
            protected $id;

            /**
             * @ORM\Column(name="temp", type="tinyint", nullable=false)
             */
            protected $temp;
        {code}

        And another entity:

        {code}
            /**
             * @var Currency
             *
             * @ORM\ManyToOne(targetEntity="Currency", inversedBy="campaigns")
             * @ORM\JoinColumns({
             * @ORM\JoinColumn(name="currency_id", referencedColumnName="id", nullable=false)
             * })
             */
            protected $currency;
        {code}

        When i have this piece of code:

        {code}
        var_dump($campaign->getCurrency()->getId());
        var_dump($campaign->getCurrency()->getTemp());
        {code}

        I get:
        string(1) "1"
        int(5)

        If I turn id into small int:
        int(1)
        int(5)

        If I switch the order to:
        {code}
        var_dump($campaign->getCurrency()->getTemp());
        var_dump($campaign->getCurrency()->getId());
        {code}

        As expected:
        int(5)
        int(1)

        If I place a var_dump on convertToPHPValue I can see that is not being called on getId when getId is lazy.

        This looks like a bug introduced when getId started being lazy to save queries.
        I have a custom type tinyint:
        https://gist.github.com/entering/3503d7458e5fbe2f6e02

        I was using it a lot and when I updated to doctrine 2.4 beta it break some stuff. At the time i turn all on smallint and solve the problem, now I had time to look into it.

        Example, entity Currency:

        {code}
            /**
             * @var integer
             *
             * @ORM\Column(name="id", type="tinyint", nullable=false, options={"unsigned": true})
             * @ORM\Id
             * @ORM\GeneratedValue(strategy="AUTO")
             */
            protected $id;

            /**
             * @ORM\Column(name="temp", type="tinyint", nullable=false)
             */
            protected $temp;
        {code}

        And another entity:

        {code}
            /**
             * @var Currency
             *
             * @ORM\ManyToOne(targetEntity="Currency", inversedBy="campaigns")
             * @ORM\JoinColumns({
             * @ORM\JoinColumn(name="currency_id", referencedColumnName="id", nullable=false)
             * })
             */
            protected $currency;
        {code}

        When i have this piece of code:

        {code}
        var_dump($campaign->getCurrency()->getId());
        var_dump($campaign->getCurrency()->getTemp());
        {code}

        I get:
        string(1) "1"
        int(5)

        If I turn id into small int:
        int(1)
        int(5)

        If I switch the order to:
        {code}
        var_dump($campaign->getCurrency()->getTemp());
        var_dump($campaign->getCurrency()->getId());
        {code}

        As expected:
        int(5)
        int(1)

        If I place a var_dump on convertToPHPValue I can see that is not being called on getId when getId is lazy.

        This looks like a bug introduced when getId started being lazy to save queries.
        Eduardo Oliveira made changes -
        Description I have a custom type tinyint:
        https://gist.github.com/entering/3503d7458e5fbe2f6e02

        I was using it a lot and when I updated to doctrine 2.4 beta it break some stuff. At the time i turn all on smallint and solve the problem, now I had time to look into it.

        Example, entity Currency:

        {code}
            /**
             * @var integer
             *
             * @ORM\Column(name="id", type="tinyint", nullable=false, options={"unsigned": true})
             * @ORM\Id
             * @ORM\GeneratedValue(strategy="AUTO")
             */
            protected $id;

            /**
             * @ORM\Column(name="temp", type="tinyint", nullable=false)
             */
            protected $temp;
        {code}

        And another entity:

        {code}
            /**
             * @var Currency
             *
             * @ORM\ManyToOne(targetEntity="Currency", inversedBy="campaigns")
             * @ORM\JoinColumns({
             * @ORM\JoinColumn(name="currency_id", referencedColumnName="id", nullable=false)
             * })
             */
            protected $currency;
        {code}

        When i have this piece of code:

        {code}
        var_dump($campaign->getCurrency()->getId());
        var_dump($campaign->getCurrency()->getTemp());
        {code}

        I get:
        string(1) "1"
        int(5)

        If I turn id into small int:
        int(1)
        int(5)

        If I switch the order to:
        {code}
        var_dump($campaign->getCurrency()->getTemp());
        var_dump($campaign->getCurrency()->getId());
        {code}

        As expected:
        int(5)
        int(1)

        If I place a var_dump on convertToPHPValue I can see that is not being called on getId when getId is lazy.

        This looks like a bug introduced when getId started being lazy to save queries.
        I have a custom type tinyint:
        https://gist.github.com/entering/3503d7458e5fbe2f6e02

        I was using it a lot and when I updated to doctrine 2.4 beta it break some stuff. At the time i turn all on smallint and solve the problem, now I had time to look into it.

        Example, entity Currency:

        {code}
            /**
             * @var integer
             *
             * @ORM\Column(name="id", type="tinyint", nullable=false, options={"unsigned": true})
             * @ORM\Id
             * @ORM\GeneratedValue(strategy="AUTO")
             */
            protected $id;

            /**
             * @ORM\Column(name="temp", type="tinyint", nullable=false)
             */
            protected $temp;
        {code}

        Entity Campaign:
        {code}
            /**
             * @var Currency
             *
             * @ORM\ManyToOne(targetEntity="Currency", inversedBy="campaigns")
             * @ORM\JoinColumns({
             * @ORM\JoinColumn(name="currency_id", referencedColumnName="id", nullable=false)
             * })
             */
            protected $currency;
        {code}

        When i have this piece of code:

        {code}
        var_dump($campaign->getCurrency()->getId());
        var_dump($campaign->getCurrency()->getTemp());
        {code}

        I get:
        string(1) "1"
        int(5)

        If I turn id into small int:
        int(1)
        int(5)

        If I switch the order to:
        {code}
        var_dump($campaign->getCurrency()->getTemp());
        var_dump($campaign->getCurrency()->getId());
        {code}

        As expected:
        int(5)
        int(1)

        If I place a var_dump on convertToPHPValue I can see that is not being called on getId when getId is lazy.

        This looks like a bug introduced when getId started being lazy to save queries.
        Fabio B. Silva made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Assignee Benjamin Eberlei [ beberlei ] Fabio B. Silva [ fabio.bat.silva ]
        Resolution Fixed [ 1 ]
        Benjamin Eberlei made changes -
        Fix Version/s 2.4 [ 10321 ]

          People

          • Assignee:
            Fabio B. Silva
            Reporter:
            Eduardo Oliveira
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: