Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-456

Wrong implementation of loading metadata from cache

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.0-BETA1
    • Fix Version/s: 2.0-BETA1
    • Component/s: None
    • Security Level: All
    • Labels:
      None

      Description

      Dear developers,
      There's a bug on line starting with 146 of ClassMetadataFactory.php, which loaded only one element in _loadedMetadata if cache is enable and it cause problem when you use inheritance.

       if ($this->_cacheDriver {
                      if (($cached = $this->_cacheDriver->fetch("$realClassName\$CLASSMETADATA")) !== false) {
                          
                          $this->_loadedMetadata[$realClassName] = $cached;                // if it's found in cache it load only one element
                      } else {
                          foreach ($this->_loadMetadata($realClassName) as $loadedClassName) {
                              $this->_cacheDriver->save(
                                  "$loadedClassName\$CLASSMETADATA", $this->_loadedMetadata[$loadedClassName], null
                              );
                          }
                      }
                  } else {
                      $this->_loadMetadata($realClassName);                                         // if cache is not enable same block load more element to _loadMetadata
                  }
      

      hope you undestand

        Issue Links

          Activity

          Hide
          Ondrej Sibrina added a comment -

          You know ... another time in here... 4am

          Show
          Ondrej Sibrina added a comment - You know ... another time in here... 4am
          Hide
          Ondrej Sibrina added a comment -

          I little more sober

           Message:
          Property id does not exist
          
          Request Parameters:
          array ( 'language' => 'cs', 'module' => 'default', 'controller' => 'index', 'action' => 'index', )
          
          Exception trace vardump:
          
          array
            'file' => string '/home/else/workspace/Shop/www/library/Doctrine/ORM/Mapping/ClassMetadata.php' (length=76)
            'line' => int 344
            'function' => string 'getProperty' (length=11)
            'class' => string 'ReflectionClass' (length=15)
            'type' => string '->' (length=2)
            'args' => 
              array
                0 => string 'id' (length=2)
          
          
          array
            'function' => string '__wakeup' (length=8)
            'class' => string 'Doctrine\ORM\Mapping\ClassMetadata' (length=34)
            'type' => string '->' (length=2)
            'args' => 
              array
                empty
          
          
          array
            'file' => string '/home/else/workspace/Shop/www/library/Doctrine/Common/Cache/ApcCache.php' (length=72)
            'line' => int 58
            'function' => string 'apc_fetch' (length=9)
            'args' => 
              array
                0 => string 'Shop_Data_Entity_Guest$CLASSMETADATA' (length=36)
          
          
          array
            'file' => string '/home/else/workspace/Shop/www/library/Doctrine/Common/Cache/AbstractCache.php' (length=77)
            'line' => int 59
            'function' => string '_doFetch' (length=8)
            'class' => string 'Doctrine\Common\Cache\ApcCache' (length=30)
            'type' => string '->' (length=2)
            'args' => 
              array
                0 => string 'Shop_Data_Entity_Guest$CLASSMETADATA' (length=36)
          
          
          array
            'file' => string '/home/else/workspace/Shop/www/library/Doctrine/ORM/Mapping/ClassMetadataFactory.php' (length=83)
            'line' => int 147
            'function' => string 'fetch' (length=5)
            'class' => string 'Doctrine\Common\Cache\AbstractCache' (length=35)
            'type' => string '->' (length=2)
            'args' => 
              array
                0 => string 'Shop_Data_Entity_Guest$CLASSMETADATA' (length=36)
          
          
          array
            'file' => string '/home/else/workspace/Shop/www/library/Doctrine/ORM/EntityManager.php' (length=68)
            'line' => int 206
            'function' => string 'getMetadataFor' (length=14)
            'class' => string 'Doctrine\ORM\Mapping\ClassMetadataFactory' (length=41)
            'type' => string '->' (length=2)
            'args' => 
              array
                0 => string 'Shop_Data_Entity_Guest' (length=22)
          
          
          array
            'file' => string '/home/else/workspace/Shop/www/library/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php' (length=88)
            'line' => int 66
            'function' => string 'getClassMetadata' (length=16)
            'class' => string 'Doctrine\ORM\EntityManager' (length=26)
            'type' => string '->' (length=2)
            'args' => 
              array
                0 => string 'Shop_Data_Entity_Guest' (length=22)
          
          
          array
            'file' => string '/home/else/workspace/Shop/www/library/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php' (length=90)
            'line' => int 101
            'function' => string '_prepare' (length=8)
            'class' => string 'Doctrine\ORM\Internal\Hydration\ObjectHydrator' (length=46)
            'type' => string '->' (length=2)
            'args' => 
              array
                empty
          
          
          array
            'file' => string '/home/else/workspace/Shop/www/library/Doctrine/ORM/AbstractQuery.php' (length=68)
            'line' => int 522
            'function' => string 'hydrateAll' (length=10)
            'class' => string 'Doctrine\ORM\Internal\Hydration\AbstractHydrator' (length=48)
            'type' => string '->' (length=2)
            'args' => 
              array
                0 => 
                  object(Doctrine\DBAL\Driver\PDOStatement)[142]
                    ...
                1 => 
                  object(Doctrine\ORM\Query\ResultSetMapping)[140]
                    ...
                2 => 
                  array
                    ...
          
          
          array
            'file' => string '/home/else/workspace/Shop/www/library/Doctrine/ORM/AbstractQuery.php' (length=68)
            'line' => int 349
            'function' => string 'execute' (length=7)
            'class' => string 'Doctrine\ORM\AbstractQuery' (length=26)
            'type' => string '->' (length=2)
            'args' => 
              array
                0 => 
                  array
                    ...
                1 => int 1
          
          
          array
            'file' => string '/home/else/workspace/Shop/www/library/Shop/Auth.php' (length=51)
            'line' => int 75
            'function' => string 'getResult' (length=9)
            'class' => string 'Doctrine\ORM\AbstractQuery' (length=26)
            'type' => string '->' (length=2)
            'args' => 
              array
                empty
          
          
          array
            'file' => string '/home/else/workspace/Shop/www/application/controllers/IndexController.php' (length=73)
            'line' => int 30
            'function' => string 'getUser' (length=7)
            'class' => string 'Shop_Auth' (length=9)
            'type' => string '->' (length=2)
            'args' => 
              array
                empty
          
          
          array
            'file' => string '/home/else/workspace/Shop/www/library/Zend/Controller/Action.php' (length=64)
            'line' => int 513
            'function' => string 'indexAction' (length=11)
            'class' => string 'IndexController' (length=15)
            'type' => string '->' (length=2)
            'args' => 
              array
                empty
          
          
          array
            'file' => string '/home/else/workspace/Shop/www/library/Zend/Controller/Dispatcher/Standard.php' (length=77)
            'line' => int 289
            'function' => string 'dispatch' (length=8)
            'class' => string 'Zend_Controller_Action' (length=22)
            'type' => string '->' (length=2)
            'args' => 
              array
                0 => string 'indexAction' (length=11)
          
          
          array
            'file' => string '/home/else/workspace/Shop/www/library/Zend/Controller/Front.php' (length=63)
            'line' => int 954
            'function' => string 'dispatch' (length=8)
            'class' => string 'Zend_Controller_Dispatcher_Standard' (length=35)
            'type' => string '->' (length=2)
            'args' => 
              array
                0 => 
                  object(Zend_Controller_Request_Http)[86]
                    ...
                1 => 
                  object(Zend_Controller_Response_Http)[87]
                    ...
          
          
          array
            'file' => string '/home/else/workspace/Shop/www/library/Zend/Application/Bootstrap/Bootstrap.php' (length=78)
            'line' => int 97
            'function' => string 'dispatch' (length=8)
            'class' => string 'Zend_Controller_Front' (length=21)
            'type' => string '->' (length=2)
            'args' => 
              array
                empty
          
          
          array
            'file' => string '/home/else/workspace/Shop/www/library/Zend/Application.php' (length=58)
            'line' => int 366
            'function' => string 'run' (length=3)
            'class' => string 'Zend_Application_Bootstrap_Bootstrap' (length=36)
            'type' => string '->' (length=2)
            'args' => 
              array
                empty
          
          
          array
            'file' => string '/home/else/workspace/Shop/www/public/index.php' (length=46)
            'line' => int 14
            'function' => string 'run' (length=3)
            'class' => string 'Zend_Application' (length=16)
            'type' => string '->' (length=2)
            'args' => 
              array
                empty
          
          
          Show
          Ondrej Sibrina added a comment - I little more sober Message: Property id does not exist Request Parameters: array ( 'language' => 'cs', 'module' => ' default ', 'controller' => 'index', 'action' => 'index', ) Exception trace vardump: array 'file' => string '/home/ else /workspace/Shop/www/library/Doctrine/ORM/Mapping/ClassMetadata.php' (length=76) 'line' => int 344 'function' => string 'getProperty' (length=11) 'class' => string 'ReflectionClass' (length=15) 'type' => string '->' (length=2) 'args' => array 0 => string 'id' (length=2) array 'function' => string '__wakeup' (length=8) 'class' => string 'Doctrine\ORM\Mapping\ClassMetadata' (length=34) 'type' => string '->' (length=2) 'args' => array empty array 'file' => string '/home/ else /workspace/Shop/www/library/Doctrine/Common/Cache/ApcCache.php' (length=72) 'line' => int 58 'function' => string 'apc_fetch' (length=9) 'args' => array 0 => string 'Shop_Data_Entity_Guest$CLASSMETADATA' (length=36) array 'file' => string '/home/ else /workspace/Shop/www/library/Doctrine/Common/Cache/AbstractCache.php' (length=77) 'line' => int 59 'function' => string '_doFetch' (length=8) 'class' => string 'Doctrine\Common\Cache\ApcCache' (length=30) 'type' => string '->' (length=2) 'args' => array 0 => string 'Shop_Data_Entity_Guest$CLASSMETADATA' (length=36) array 'file' => string '/home/ else /workspace/Shop/www/library/Doctrine/ORM/Mapping/ClassMetadataFactory.php' (length=83) 'line' => int 147 'function' => string 'fetch' (length=5) 'class' => string 'Doctrine\Common\Cache\AbstractCache' (length=35) 'type' => string '->' (length=2) 'args' => array 0 => string 'Shop_Data_Entity_Guest$CLASSMETADATA' (length=36) array 'file' => string '/home/ else /workspace/Shop/www/library/Doctrine/ORM/EntityManager.php' (length=68) 'line' => int 206 'function' => string 'getMetadataFor' (length=14) 'class' => string 'Doctrine\ORM\Mapping\ClassMetadataFactory' (length=41) 'type' => string '->' (length=2) 'args' => array 0 => string 'Shop_Data_Entity_Guest' (length=22) array 'file' => string '/home/ else /workspace/Shop/www/library/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php' (length=88) 'line' => int 66 'function' => string 'getClassMetadata' (length=16) 'class' => string 'Doctrine\ORM\EntityManager' (length=26) 'type' => string '->' (length=2) 'args' => array 0 => string 'Shop_Data_Entity_Guest' (length=22) array 'file' => string '/home/ else /workspace/Shop/www/library/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php' (length=90) 'line' => int 101 'function' => string '_prepare' (length=8) 'class' => string 'Doctrine\ORM\Internal\Hydration\ObjectHydrator' (length=46) 'type' => string '->' (length=2) 'args' => array empty array 'file' => string '/home/ else /workspace/Shop/www/library/Doctrine/ORM/AbstractQuery.php' (length=68) 'line' => int 522 'function' => string 'hydrateAll' (length=10) 'class' => string 'Doctrine\ORM\Internal\Hydration\AbstractHydrator' (length=48) 'type' => string '->' (length=2) 'args' => array 0 => object(Doctrine\DBAL\Driver\PDOStatement)[142] ... 1 => object(Doctrine\ORM\Query\ResultSetMapping)[140] ... 2 => array ... array 'file' => string '/home/ else /workspace/Shop/www/library/Doctrine/ORM/AbstractQuery.php' (length=68) 'line' => int 349 'function' => string 'execute' (length=7) 'class' => string 'Doctrine\ORM\AbstractQuery' (length=26) 'type' => string '->' (length=2) 'args' => array 0 => array ... 1 => int 1 array 'file' => string '/home/ else /workspace/Shop/www/library/Shop/Auth.php' (length=51) 'line' => int 75 'function' => string 'getResult' (length=9) 'class' => string 'Doctrine\ORM\AbstractQuery' (length=26) 'type' => string '->' (length=2) 'args' => array empty array 'file' => string '/home/ else /workspace/Shop/www/application/controllers/IndexController.php' (length=73) 'line' => int 30 'function' => string 'getUser' (length=7) 'class' => string 'Shop_Auth' (length=9) 'type' => string '->' (length=2) 'args' => array empty array 'file' => string '/home/ else /workspace/Shop/www/library/Zend/Controller/Action.php' (length=64) 'line' => int 513 'function' => string 'indexAction' (length=11) 'class' => string 'IndexController' (length=15) 'type' => string '->' (length=2) 'args' => array empty array 'file' => string '/home/ else /workspace/Shop/www/library/Zend/Controller/Dispatcher/Standard.php' (length=77) 'line' => int 289 'function' => string 'dispatch' (length=8) 'class' => string 'Zend_Controller_Action' (length=22) 'type' => string '->' (length=2) 'args' => array 0 => string 'indexAction' (length=11) array 'file' => string '/home/ else /workspace/Shop/www/library/Zend/Controller/Front.php' (length=63) 'line' => int 954 'function' => string 'dispatch' (length=8) 'class' => string 'Zend_Controller_Dispatcher_Standard' (length=35) 'type' => string '->' (length=2) 'args' => array 0 => object(Zend_Controller_Request_Http)[86] ... 1 => object(Zend_Controller_Response_Http)[87] ... array 'file' => string '/home/ else /workspace/Shop/www/library/Zend/Application/Bootstrap/Bootstrap.php' (length=78) 'line' => int 97 'function' => string 'dispatch' (length=8) 'class' => string 'Zend_Controller_Front' (length=21) 'type' => string '->' (length=2) 'args' => array empty array 'file' => string '/home/ else /workspace/Shop/www/library/Zend/Application.php' (length=58) 'line' => int 366 'function' => string 'run' (length=3) 'class' => string 'Zend_Application_Bootstrap_Bootstrap' (length=36) 'type' => string '->' (length=2) 'args' => array empty array 'file' => string '/home/ else /workspace/Shop/www/ public /index.php' (length=46) 'line' => int 14 'function' => string 'run' (length=3) 'class' => string 'Zend_Application' (length=16) 'type' => string '->' (length=2) 'args' => array empty
          Hide
          Roman S. Borschel added a comment -

          Looks like the same as DDC-388.

          Show
          Roman S. Borschel added a comment - Looks like the same as DDC-388 .
          Hide
          Ondrej Sibrina added a comment - - edited

          Dear roman,

          I don't understand explanation from DDC-388 very well. It's obvious that you get another results on first (without cache) and second (with cache) case. So where is the problem?

          Andy

          Show
          Ondrej Sibrina added a comment - - edited Dear roman, I don't understand explanation from DDC-388 very well. It's obvious that you get another results on first (without cache) and second (with cache) case. So where is the problem? Andy
          Hide
          Roman S. Borschel added a comment -

          Fixed in http://github.com/doctrine/doctrine2/commit/d4232d906e433b1fe4dd8aa85aa7a4aca3a2cf4c .
          Make sure to clear the metadata cache if necessary.

          Show
          Roman S. Borschel added a comment - Fixed in http://github.com/doctrine/doctrine2/commit/d4232d906e433b1fe4dd8aa85aa7a4aca3a2cf4c . Make sure to clear the metadata cache if necessary.

            People

            • Assignee:
              Roman S. Borschel
              Reporter:
              Ondrej Sibrina
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: