[TYPO3-mvc] spl_object_hash not matching when using in Fluid ajax widget

Marc Bastian Heinrichs typo3 at mbh-web.de
Wed Mar 9 10:56:26 CET 2011


Hey,

> In the Controller of the Widget I call
> $myObject->removeMyStorageProperty($objectToRemove);
> with no result (if I change other properties it works). So I took a 
> closer look and found out that the hash generated by spl_object_hash() 
> which is used as the key for the objectStorage internally did not match 
> the one my $objectToRemove has.
> How can that be?
> Also I looped through the storage and compared the objects to my 
> $objectToRemove like this:
> 
> foreach($myObjectStorage as $object){
> 	if($obj === $objectToRemove)
> 		// do something if they match
> 	else
> 		// do something if they did not match
> }

I suppose $objectToRemove is an rebuilded object by the propertyMapper.
So the $objectToRemove is an other object than the corresponding object
in $myObjectStorage, but they represent the same row.

So you have to implement it like this:

$myObjectStorageClone = $myObjectStorage;
foreach($myObjectStorageClone as $object) {
  if ($objectToRemove->getUid() === $object->getUid()) {
	$myObjectStorage->detach($object);
  }
}
(untested)


Best
Marc Bastian


More information about the TYPO3-project-typo3v4mvc mailing list