Project

General

Profile

Bug #67144

Updated by Markus Klein about 9 years ago

I encountered that if you are doing something like: 

 <pre> 
 $storage @$storage = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage(); 
 $storage->attach(\DateTime("2015-05-21 11:38:00")); 
 $storage->attach(\DateTime("2015-05-22 11:38:00")); 
 $storage->attach(\DateTime("2015-05-26 11:38:00")); 
 $now = \DateTime("2015-05-25 11:38:00"); 

 foreach($storage as $storedObject){ 
     if($storedObject <= $now){ 
         $storage->detach($storedObject); 
     } 
 } 
 </pre> }@ 

 the positionCounter in ObjectStorage is not touched. 
 This is cousing the loop to jump over the next object and leaves us with an unprocessed item in the ObjectStorage, that should have been processed by the condition inside the loop, too. 
 The result of the code above would be: 

 <pre> 
 ObjectStorage ->  
     ( 
         \DateTime("2015-05-22 11:38:00"), 
         \DateTime("2015-05-26 11:38:00") 
     ) 
 </pre> 

 but it should be: 

 <pre> 
 ObjectStorage ->  
     ( 
         \DateTime("2015-05-26 11:38:00") 
     ) 
 </pre> 

 Tested on TYPO3 6.2.13 with PHP 5.5.9

Back