Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-2064

[GH-469] ProxyFactory: Catch exception if type hint of entity method parameter is invalid

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Invalid
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: ORM
    • Security Level: All
    • Labels:
      None
    • Environment:
      Doctrine 2.2.2, Symfony 2.0.17

      Description

      In Symfony I got this exception when I access the page after cleaning the cache:

      PHP Fatal error:  Uncaught exception 'ReflectionException' with message 'Class integer does not exist' in C:\projects\osl\trunk\vendor\doctrine\lib\Doctrine\ORM\Proxy\ProxyFactory.php:226
      Stack trace:
      #0 C:\projects\osl\trunk\vendor\doctrine\lib\Doctrine\ORM\Proxy\ProxyFactory.php(226): ReflectionParameter->getClass()
      #1 C:\projects\osl\trunk\vendor\doctrine\lib\Doctrine\ORM\Proxy\ProxyFactory.php(160): Doctrine\ORM\Proxy\ProxyFactory->_generateMethods(Object(Doctrine\ORM\Mapping\ClassMetadata))
      #2 C:\projects\osl\trunk\vendor\doctrine\lib\Doctrine\ORM\Proxy\ProxyFactory.php(144): Doctrine\ORM\Proxy\ProxyFactory->_generateProxyClass(Object(Doctrine\ORM\Mapping\ClassMetadata), 'C:/projects/osl...', '<?php??namespac...')
      #3 C:\projects\osl\trunk\vendor\symfony\src\Symfony\Bridge\Doctrine\CacheWarmer\ProxyCacheWarmer.php(68): Doctrine\ORM\Proxy\ProxyFactory->generateProxyClasses(Array)
      #4 C:\projects\osl\trunk\vendor\symfony\src\Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerAggregate.php(47): Symfony\Bridge\Doctrine\CacheWa in C:\projects\osl\trunk\vendor\doctrine\lib\Doctrine\ORM\Proxy\ProxyFactory.php on line 226
      

      The reason was a wrong type hint in the setter method of a property:

          public function setAdrid(\integer $adrid)
          {
              $this->adrid = $adrid;
              return $this;
          }
      

      Is it possible to merge this fix also into 2.2 branch? Or should I do that myself?

      I made a pull request on github
      https://github.com/doctrine/doctrine2/pull/469

      Message:

      ProxyFactory: Catch exception if a type hint of an entity's method parameter is invalid and forward the exception with a better readable and more helpful message.

        Activity

        Benjamin Eberlei created issue -
        Christian S. made changes -
        Field Original Value New Value
        Environment Doctrine 2.2.2, Symfony 2.0.17
        Description This issue is created automatically through a Github pull request on behalf of naitsirch:

          Url: https://github.com/doctrine/doctrine2/pull/469

        Message:

        ProxyFactory: Catch exception if a type hint of an entity's method parameter is invalid and forward the exception with a better readable and more helpful message.
        In Symfony I got this exception when I access the page after cleaning the cache:

        {code}
        PHP Fatal error: Uncaught exception 'ReflectionException' with message 'Class integer does not exist' in C:\projects\osl\trunk\vendor\doctrine\lib\Doctrine\ORM\Proxy\ProxyFactory.php:226
        Stack trace:
        #0 C:\projects\osl\trunk\vendor\doctrine\lib\Doctrine\ORM\Proxy\ProxyFactory.php(226): ReflectionParameter->getClass()
        #1 C:\projects\osl\trunk\vendor\doctrine\lib\Doctrine\ORM\Proxy\ProxyFactory.php(160): Doctrine\ORM\Proxy\ProxyFactory->_generateMethods(Object(Doctrine\ORM\Mapping\ClassMetadata))
        #2 C:\projects\osl\trunk\vendor\doctrine\lib\Doctrine\ORM\Proxy\ProxyFactory.php(144): Doctrine\ORM\Proxy\ProxyFactory->_generateProxyClass(Object(Doctrine\ORM\Mapping\ClassMetadata), 'C:/projects/osl...', '<?php??namespac...')
        #3 C:\projects\osl\trunk\vendor\symfony\src\Symfony\Bridge\Doctrine\CacheWarmer\ProxyCacheWarmer.php(68): Doctrine\ORM\Proxy\ProxyFactory->generateProxyClasses(Array)
        #4 C:\projects\osl\trunk\vendor\symfony\src\Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerAggregate.php(47): Symfony\Bridge\Doctrine\CacheWa in C:\projects\osl\trunk\vendor\doctrine\lib\Doctrine\ORM\Proxy\ProxyFactory.php on line 226
        {code}

        The reason was a wrong type hint in the setter method of a property:
        {code}
            public function setAdrid(\integer $adrid)
            {
                $this->adrid = $adrid;
                return $this;
            }
        {code}

        Is it possible to merge this fix also into 2.2 branch? Or should I do that myself?


        I made a pull request on github
         https://github.com/doctrine/doctrine2/pull/469

        Message:

        ProxyFactory: Catch exception if a type hint of an entity's method parameter is invalid and forward the exception with a better readable and more helpful message.
        Component/s ORM [ 10012 ]
        Christian S. made changes -
        Comment [ In Symfony I got this exception when I access the page after cleaning the cache:

        {code}
        PHP Fatal error: Uncaught exception 'ReflectionException' with message 'Class integer does not exist' in C:\projects\osl\trunk\vendor\doctrine\lib\Doctrine\ORM\Proxy\ProxyFactory.php:226
        Stack trace:
        #0 C:\projects\osl\trunk\vendor\doctrine\lib\Doctrine\ORM\Proxy\ProxyFactory.php(226): ReflectionParameter->getClass()
        #1 C:\projects\osl\trunk\vendor\doctrine\lib\Doctrine\ORM\Proxy\ProxyFactory.php(160): Doctrine\ORM\Proxy\ProxyFactory->_generateMethods(Object(Doctrine\ORM\Mapping\ClassMetadata))
        #2 C:\projects\osl\trunk\vendor\doctrine\lib\Doctrine\ORM\Proxy\ProxyFactory.php(144): Doctrine\ORM\Proxy\ProxyFactory->_generateProxyClass(Object(Doctrine\ORM\Mapping\ClassMetadata), 'C:/projects/osl...', '<?php??namespac...')
        #3 C:\projects\osl\trunk\vendor\symfony\src\Symfony\Bridge\Doctrine\CacheWarmer\ProxyCacheWarmer.php(68): Doctrine\ORM\Proxy\ProxyFactory->generateProxyClasses(Array)
        #4 C:\projects\osl\trunk\vendor\symfony\src\Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerAggregate.php(47): Symfony\Bridge\Doctrine\CacheWa in C:\projects\osl\trunk\vendor\doctrine\lib\Doctrine\ORM\Proxy\ProxyFactory.php on line 226
        {code}

        The reason was a wrong type hint in the setter method of a property:
        {code}
            public function setAdrid(\integer $adrid)
            {
                $this->adrid = $adrid;
                return $this;
            }
        {code}

        Is it possible to merge this fix also into 2.2 branch? Or should I do that myself? ]
        Benjamin Eberlei made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Invalid [ 6 ]

          People

          • Assignee:
            Benjamin Eberlei
            Reporter:
            Benjamin Eberlei
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: