Bug #76202
openException when accessing empty ObjectStorage property (frontend form submitting)
0%
Description
hi,
seems bug from 6.2 version https://forge.typo3.org/issues/62553 is still in typo3 7.6 version. i have a form where following select field is:
<f:form.select property="anfragen.0.bundesland." id="bundesland" options="{xxxx}" optionValueField="uid" optionLabelField="bundesland" prependOptionLabel="alle Bundesländer" prependOptionValue=""/>
if i submit form and do not select any "bundesland" following error is shown:
#1297759968: Exception while property mapping at property path "anfragen.0.bundesland": PHP Warning: spl_object_hash() expects parameter 1 to be object, null given in /home/kundenhost/public_html/xxx/typo3/sysext/extbase/Classes/Persistence/ObjectStorage.php line 155
here some info from exeption:
#1297759968: Exception while property mapping at property path "anfragen.0.bundesland": PHP Warning: spl_object_hash() expects parameter 1 to be object, null given in /home/kundenhost/public_html/xxxxxs/typo3/sysext/extbase/Classes/Persistence/ObjectStorage.php line 155 (More information)
TYPO3\CMS\Extbase\Property\Exception thrown in file
/home/kundenhost/public_html/xxxxxs/typo3/sysext/extbase/Classes/Property/PropertyMapper.php in line 128.
21 TYPO3\CMS\Extbase\Property\PropertyMapper::convert(array, "Xxxxxx\Mwxxxxxs\Domain\Model\aaaaaaa", TYPO3\CMS\Extbase\Mvc\Controller\MvcPropertyMappingConfiguration)
/home/kundenhost/public_html/xxxxxs/typo3/sysext/extbase/Classes/Mvc/Controller/Argument.php:
00268: }
00269: try {
00270: $this->value = $this->propertyMapper->convert($rawValue, $this->dataType, $this->propertyMappingConfiguration);
00271: } catch (TargetNotFoundException $e) {
00272: // for optional arguments no exeption is thrown.
20 TYPO3\CMS\Extbase\Mvc\Controller\Argument::setValue(array)
/home/kundenhost/public_html/xxxxxs/typo3/sysext/extbase/Classes/Mvc/Controller/AbstractController.php:
00426: $argumentName = $argument->getName();
00427: if ($this->request->hasArgument($argumentName)) {
00428: $argument->setValue($this->request->getArgument($argumentName));
00429: } elseif ($argument->isRequired()) {
00430: throw new \TYPO3\CMS\Extbase\Mvc\Controller\Exception\RequiredArgumentMissingException('Required argument "' . $argumentName . '" is not set for ' . $this->request->getControllerObjectName() . '->' . $this->request->getControllerActionName() . '.', 1298012500);
19 TYPO3\CMS\Extbase\Mvc\Controller\AbstractController::mapRequestArgumentsToControllerArguments()
/home/kundenhost/public_html/xxxxxs/typo3/sysext/extbase/Classes/Mvc/Controller/ActionController.php:
00168: call_user_func(array($this, $actionInitializationMethodName));
00169: }
00170: $this->mapRequestArgumentsToControllerArguments();
00171: $this->controllerContext = $this->buildControllerContext();
00172: $this->view = $this->resolveView();
Updated by Martin Weymayer about 8 years ago
i solved this for me with following code in typo3/sysext/extbase/Classes/Persistence/ObjectStorage.php line 155 - it seems working:
if(is_object($object)) { $this->isModified = true; $this->storage[spl_object_hash($object)] = array('obj' => $object, 'inf' => $information); $this->positionCounter++; $this->addedObjectsPositions[spl_object_hash($object)] = $this->positionCounter; }
Updated by Martin Weymayer almost 8 years ago
better solution found - so no core hack necessary:
/**
* initialize createanfrage action
*
* @param void
*/
public function initializeCreateanfrageAction() {
$arguments = $this->request->getArguments();
if (intval($arguments['newAnfrage']['bundesland'][0]) === 0) {
unset($arguments['newAnfrage']['bundesland']);
}
if (intval($arguments['newAnfrage']['regionen'][0]) === 0) {
unset($arguments['newAnfrage']['regionen']);
}
$this->request->setArguments($arguments);
}
Updated by Eike Starkmann about 7 years ago
I also experienced this issue.
Also all references attached to the object are lost afterwards.