Bug #36734

Transient properties cannot be property mapped

Added by Alexander Berl over 3 years ago. Updated 11 months ago.

Status:Resolved Start date:2012-04-30
Priority:Should have Due date:
Assigned To:Karsten Dambekalns % Done:

100%

Category:Property
Target version:-
PHP Version:5.3 Complexity:
Has patch:No Affected Flow version:FLOW3 1.0.0

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

Associated revisions

Revision 296220dc
Added by Alexander Berl 11 months ago

[FEATURE] Transient properties can be property mapped

This change allows properties annotated as transient to be regarded
normally for the classSchema during reflection. Those properties are
marked in the classSchema as being transient and the persistence
implementations can check for that attribute instead of existence in
the classSchema only.

Therefore it is now possible to submit transient properties in web
forms.

Change-Id: I8dcd250e5a19eec80a1e98c2acef4c134f3a5482
Resolves: #36734
Releases: master

History

#1 Updated by Karsten Dambekalns about 3 years ago

  • Status changed from New to Accepted
  • Assigned To set to Karsten Dambekalns
  • Priority changed from -- undefined -- to Should have
  • Affected Flow version changed from Git master to FLOW3 1.0.0

#2 Updated by Alexander Berl over 2 years 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.

#3 Updated by Gerrit Code Review over 2 years 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

#4 Updated by Gerrit Code Review over 2 years ago

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

#5 Updated by Gerrit Code Review over 2 years ago

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

#6 Updated by Gerrit Code Review about 2 years ago

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

#7 Updated by Gerrit Code Review almost 2 years ago

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

#8 Updated by Gerrit Code Review about 1 year ago

Patch set 6 for branch master of project Packages/TYPO3.Flow has been pushed to the review server.
It is available at https://review.typo3.org/19862

#9 Updated by Gerrit Code Review about 1 year ago

Patch set 7 for branch master of project Packages/TYPO3.Flow has been pushed to the review server.
It is available at https://review.typo3.org/19862

#10 Updated by Gerrit Code Review 11 months ago

Patch set 8 for branch master of project Packages/TYPO3.Flow has been pushed to the review server.
It is available at http://review.typo3.org/19862

#11 Updated by Gerrit Code Review 11 months ago

Patch set 9 for branch master of project Packages/TYPO3.Flow has been pushed to the review server.
It is available at http://review.typo3.org/19862

#12 Updated by Gerrit Code Review 11 months ago

Patch set 10 for branch master of project Packages/TYPO3.Flow has been pushed to the review server.
It is available at http://review.typo3.org/19862

#13 Updated by Alexander Berl 11 months ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100

Also available in: Atom PDF