Bug #36734

Transient properties cannot be property mapped

Added by Alexander Berl about 1 year ago. Updated 2 months ago.

Status:Under Review Start date:2012-04-30
Priority:Should have Due date:
Assignee:Karsten Dambekalns % Done:

0%

Category:Property
Target version:-
PHP Version:5.3 Complexity:
Has patch:No FLOW3 version affected:FLOW3 1.0.0
Votes: 1 (View)

Description

When creating an object containing transient properties through a webform an exception is thrown that the property is not found within the object.

Example

Model

/**
 * A Baz
 *
 * @FLOW3\Entity
 */
class Baz {

    /**
     * The password
     * @var string
     * @FLOW3\Transient
     */
    protected $password;
...
}

Form

    <f:form action="create" name="baz" object="{baz}">
        Password: <f:form.textfield property="password" /><br />
        <f:form.submit value="submit" />
    </f:form>

After submitting the form the following exception is thrown:

TYPO3\FLOW3\Property\Exception\InvalidTargetException thrown in file TYPO3_FLOW3_Property_TypeConverter_PersistentObjectConverter_Original.php

Property "password" was not found in target object of type "Foo\Bar\Domain\Model\Baz".
20 TYPO3\FLOW3\Property\TypeConverter\PersistentObjectConverter_Original::getTypeOfChildProperty("Foo\Bar\Domain\Model\Baz", "password", TYPO3\FLOW3\Mvc\Controller\MvcPropertyMappingConfiguration)

19 TYPO3\FLOW3\Property\PropertyMapper_Original::doMapping(array, "Foo\Bar\Domain\Model\Baz", TYPO3\FLOW3\Mvc\Controller\MvcPropertyMappingConfiguration, array)

18 TYPO3\FLOW3\Property\PropertyMapper_Original::convert(array, "Foo\Bar\Domain\Model\Baz", TYPO3\FLOW3\Mvc\Controller\MvcPropertyMappingConfiguration)

17 TYPO3\FLOW3\Mvc\Controller\Argument_Original::setValue(array)

16 TYPO3\FLOW3\Mvc\Controller\AbstractController::mapRequestArgumentsToControllerArguments()

15 TYPO3\FLOW3\Mvc\Controller\ActionController_Original::processRequest(TYPO3\FLOW3\Mvc\ActionRequest, TYPO3\FLOW3\Http\Response)

14 TYPO3\FLOW3\Mvc\Dispatcher_Original::dispatch(TYPO3\FLOW3\Mvc\ActionRequest, TYPO3\FLOW3\Http\Response)

13 TYPO3\FLOW3\Mvc\Dispatcher::dispatch(TYPO3\FLOW3\Mvc\ActionRequest, TYPO3\FLOW3\Http\Response)

12 call_user_func_array(array, array)

11 TYPO3\FLOW3\Mvc\Dispatcher::FLOW3_Aop_Proxy_invokeJoinPoint(TYPO3\FLOW3\Aop\JoinPoint)

10 TYPO3\FLOW3\Aop\Advice\AdviceChain::proceed(TYPO3\FLOW3\Aop\JoinPoint)

9 TYPO3\FLOW3\Security\Aspect\RequestDispatchingAspect_Original::setAccessDeniedResponseHeader(TYPO3\FLOW3\Aop\JoinPoint)

8 TYPO3\FLOW3\Aop\Advice\AroundAdvice::invoke(TYPO3\FLOW3\Aop\JoinPoint)

7 TYPO3\FLOW3\Aop\Advice\AdviceChain::proceed(TYPO3\FLOW3\Aop\JoinPoint)

6 TYPO3\FLOW3\Security\Aspect\RequestDispatchingAspect_Original::blockIllegalRequestsAndForwardToAuthenticationEntryPoints(TYPO3\FLOW3\Aop\JoinPoint)

5 TYPO3\FLOW3\Aop\Advice\AroundAdvice::invoke(TYPO3\FLOW3\Aop\JoinPoint)

4 TYPO3\FLOW3\Aop\Advice\AdviceChain::proceed(TYPO3\FLOW3\Aop\JoinPoint)

3 TYPO3\FLOW3\Mvc\Dispatcher::dispatch(TYPO3\FLOW3\Mvc\ActionRequest, TYPO3\FLOW3\Http\Response)

2 TYPO3\FLOW3\Http\RequestHandler::handleRequest()

1 TYPO3\FLOW3\Core\Bootstrap::run()

The problem here is, that the property is skipped in reflection due to the Transient annotation (see ReflectionService->addPropertiesToClassSchema) and therefore also cannot be property mapped.

see http://lists.typo3.org/pipermail/flow3-general/2012-April/002285.html

History

Updated by Karsten Dambekalns 12 months ago

  • Status changed from New to Accepted
  • Assignee set to Karsten Dambekalns
  • Priority changed from -- undefined -- to Should have
  • FLOW3 version affected changed from Git master to FLOW3 1.0.0

Updated by Alexander Berl 2 months ago

Just some research on the matter:
@Transient is currently only really used in the ReflectionService/classSchema, i.e. all Transient properties are not regarded for the classSchema.
The classSchemas properties in turn are only relevant for:
- the generic persistence in the DataMapper (only schema properties are used for reconstitution)
- for finding property annotations in the doctrine persistence, to quickly skip properties not part of classSchema
- in the property mapping PersistentObjectConverter where only classSchema properties are data mapped
- in the validation UniqueEntityValidator when (custom) identity properties are not part of the classSchema

I think a good solution would be to add @Transient properties to the classSchema, but tag them as transient there, so the checks in generic persistence/doctrine(/validation?) can still skip those properties.

I'm gonna try and provide a changeset when I find time.

Updated by Gerrit Code Review 2 months ago

  • Status changed from Accepted to Under Review

Patch set 1 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/19862

Updated by Gerrit Code Review 2 months ago

Patch set 2 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/19862

Updated by Gerrit Code Review 2 months ago

Patch set 3 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/19862

Also available in: Atom PDF