Bug #32829

Mapping to a subclass by __type property fails if subclass adds fields

Added by Andreas Wolf over 3 years ago. Updated almost 2 years ago.

Status:Resolved Start date:2011-12-24
Priority:Should have Due date:
Assigned To:Andreas Wolf % Done:

100%

Category:Property
Target version:TYPO3 Flow Base Distribution - 1.1.1
PHP Version:5.3 Complexity:
Has patch:Yes Affected Flow version:FLOW3 1.0.0

Description

I have a hierarchy of classes for which an object should be created from a form. For that, I use the feature added with #30300. This all works well until I have a new field in my subclass that is not present in the base class. Then I get the following message on submitting my form:

#1297759968: Exception while property mapping at property path "": Property "text" was not found in target object of type "MyCompany\MyPackage\Domain\Model\BaseClass".

This is caused by the subtype resolving done after the subproperties to map are found. The whole magic is done in PropertyMapper::doMapping(): First the type converter is created, then all subproperties (of the base class, as annotated in my controller action) are fetched in getSourceChildPropertiesToBeConverted(). After this, the object should be created, but the mapping fails first because the property does not exist.

The solution is to do the final type resolution directly after creating the type converter, before the call to getSourceChildPropertiesToBeConverted().


Related issues

related to TYPO3.Flow - Feature #30300: Support mapping to subclass by argument Resolved 2011-09-26

Associated revisions

Revision 81997950
Added by Andreas Wolf over 2 years ago

[BUGFIX] Mapping to subtype with [__type] fails

The type of a target object can be manipulated by setting __type in the
form (or during action initialization when saving the form). This
however fails if the target subclass contains fields that the original
class does not have, because the property mapping is done before the
final class is extracted from the __type request variable.

To get this working, the process of getting the final class name is
moved before the property mapping.

If you wrote your own type converters, you might need to implement the
new getTargetTypeForSource() method if you do not extend the provided
AbstractTypeConverter of Flow.

Change-Id: Ia42e374202845dfe5e95c72512e9fefb4f00e789
Fixes: #32829
Releases: master, 2.0, 1.1

Revision 45ea2277
Added by Christian Müller over 2 years ago

[BUGFIX] Flow should work with PHP versions lower than 5.3.9

The change Ia42e374202845dfe5e95c72512e9fefb4f00e789 introduced
usage of is_a() with 3 arguments which is only implemented from
PHP 5.3.9. This change replaces the call with a manual check for
inheritance.

Change-Id: I05c42b785e3f49e974cd5b381940e96130e5b0dc
Related: #32829
Releases: master

Revision e23dc49c
Added by Andreas Wolf over 2 years ago

[BUGFIX] Mapping to subtype with [__type] fails

The type of a target object can be manipulated by setting __type in the
form (or during action initialization when saving the form). This
however fails if the target subclass contains fields that the original
class does not have, because the property mapping is done before the
final class is extracted from the __type request variable.

To get this working, the process of getting the final class name is
moved before the property mapping.

If you wrote your own type converters, you might need to implement the
new getTargetTypeForSource() method if you do not extend the provided
AbstractTypeConverter of Flow.

Change-Id: Ia42e374202845dfe5e95c72512e9fefb4f00e789
Fixes: #32829
Releases: master, 2.0, 1.1

Revision f64f3cc9
Added by Christian Müller over 2 years ago

[BUGFIX] Flow should work with PHP versions lower than 5.3.9

The change Ia42e374202845dfe5e95c72512e9fefb4f00e789 introduced
usage of is_a() with 3 arguments which is only implemented from
PHP 5.3.9. This change replaces the call with a manual check for
inheritance.

Change-Id: I05c42b785e3f49e974cd5b381940e96130e5b0dc
Related: #32829
Releases: master, 2.0, 1.1

Revision eee02f3b
Added by Andreas Wolf over 2 years ago

[BUGFIX] Mapping to subtype with [__type] fails

The type of a target object can be manipulated by setting __type in the
form (or during action initialization when saving the form). This
however fails if the target subclass contains fields that the original
class does not have, because the property mapping is done before the
final class is extracted from the __type request variable.

To get this working, the process of getting the final class name is
moved before the property mapping.

If you wrote your own type converters, you might need to implement the
new getTargetTypeForSource() method if you do not extend the provided
AbstractTypeConverter of Flow.

Change-Id: Ia42e374202845dfe5e95c72512e9fefb4f00e789
Fixes: #32829
Releases: master, 2.0, 1.1

Revision 006c7eb9
Added by Christian Müller over 2 years ago

[BUGFIX] Flow should work with PHP versions lower than 5.3.9

The change Ia42e374202845dfe5e95c72512e9fefb4f00e789 introduced
usage of is_a() with 3 arguments which is only implemented from
PHP 5.3.9. This change replaces the call with a manual check for
inheritance.

Change-Id: I05c42b785e3f49e974cd5b381940e96130e5b0dc
Related: #32829
Releases: master, 2.0, 1.1

History

#1 Updated by Gerrit Code Review over 3 years ago

  • Status changed from New to Under Review

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

#2 Updated by Gerrit Code Review over 3 years ago

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

#3 Updated by Gerrit Code Review over 3 years ago

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

#4 Updated by Karsten Dambekalns over 3 years ago

  • Category set to Property
  • Assigned To set to Andreas Wolf
  • Target version set to 1.1

#5 Updated by Gerrit Code Review over 3 years ago

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

#6 Updated by Gerrit Code Review over 3 years ago

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

#7 Updated by Gerrit Code Review about 3 years ago

Patch set 6 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/7507

#8 Updated by Gerrit Code Review about 3 years ago

Patch set 7 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/7507

#9 Updated by Karsten Dambekalns about 3 years ago

  • Target version changed from 1.1 to 1.1 RC1

#10 Updated by Karsten Dambekalns about 3 years ago

  • Target version changed from 1.1 RC1 to 1.1
  • Affected Flow version changed from Git master to Git 1.1

#11 Updated by Karsten Dambekalns about 3 years ago

  • Affected Flow version changed from Git 1.1 to FLOW3 1.0.0

#12 Updated by Gerrit Code Review about 3 years ago

Patch set 8 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/7507

#13 Updated by Gerrit Code Review about 3 years ago

Patch set 9 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/7507

#14 Updated by Gerrit Code Review almost 3 years ago

Patch set 10 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/7507

#15 Updated by Karsten Dambekalns almost 3 years ago

  • Target version changed from 1.1 to 1.1.1

#16 Updated by Gerrit Code Review almost 3 years ago

Patch set 11 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/7507

#17 Updated by Gerrit Code Review almost 3 years ago

Patch set 12 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/7507

#18 Updated by Gerrit Code Review almost 3 years ago

Patch set 13 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/7507

#19 Updated by Gerrit Code Review almost 3 years ago

Patch set 14 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/7507

#20 Updated by Gerrit Code Review almost 3 years ago

Patch set 15 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/7507

#21 Updated by Karsten Dambekalns over 2 years ago

  • Target version changed from 1.1.1 to 2052

#22 Updated by Marco Falkenberg over 2 years ago

Are there any news or efforts about solving this bug?

#23 Updated by Gerrit Code Review over 2 years ago

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

#24 Updated by Andreas Wolf over 2 years ago

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

#25 Updated by Gerrit Code Review over 2 years ago

  • Status changed from Resolved to Under Review

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

#26 Updated by Gerrit Code Review over 2 years ago

Patch set 1 for branch FLOW3-1.1 has been pushed to the review server.
It is available at https://review.typo3.org/19096

#27 Updated by Gerrit Code Review over 2 years ago

Patch set 2 for branch FLOW3-1.1 has been pushed to the review server.
It is available at https://review.typo3.org/19096

#28 Updated by Gerrit Code Review over 2 years ago

Patch set 3 for branch FLOW3-1.1 has been pushed to the review server.
It is available at https://review.typo3.org/19096

#29 Updated by Gerrit Code Review over 2 years ago

Patch set 4 for branch FLOW3-1.1 has been pushed to the review server.
It is available at https://review.typo3.org/19096

#30 Updated by Andreas Wolf over 2 years ago

  • Status changed from Under Review to Resolved

#31 Updated by Andreas Wolf over 2 years ago

This still seems to be an issue when changing already persisted objects when the type is not submitted with the form (which may not be desired for several reasons). The reason is that the ObjectConverter does not check if the object has already been persisted (= if $source[__identity] is present) when checking for the target type (in getTargetTypeForSource)

#32 Updated by Karsten Dambekalns almost 2 years ago

  • Target version changed from 2052 to 1.1.1

Also available in: Atom PDF