Bug #32829
Mapping to a subclass by __type property fails if subclass adds fields
| Status: | Resolved | Start date: | 2011-12-24 | |
|---|---|---|---|---|
| Priority: | Should have | Due date: | ||
| Assignee: | Andreas Wolf | % Done: | 100% |
|
| Category: | Property | |||
| Target version: | TYPO3 Flow Base Distribution - 1.1.2 | |||
| PHP Version: | 5.3 | Complexity: | ||
| Has patch: | Yes | FLOW3 version affected: | FLOW3 1.0.0 | |
| Votes: | 1 (View) |
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
[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
[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
[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
[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
[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
Updated by Gerrit Code Review over 1 year 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
Updated by Gerrit Code Review over 1 year ago
Patch set 2 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/7507
Updated by Gerrit Code Review over 1 year ago
Patch set 3 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/7507
Updated by Karsten Dambekalns over 1 year ago
- Category set to Property
- Assignee set to Andreas Wolf
- Target version set to 1.1
Updated by Gerrit Code Review over 1 year ago
Patch set 4 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/7507
Updated by Gerrit Code Review about 1 year ago
Patch set 5 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/7507
Updated by Gerrit Code Review about 1 year ago
Patch set 6 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/7507
Updated by Gerrit Code Review about 1 year ago
Patch set 7 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/7507
Updated by Karsten Dambekalns about 1 year ago
- Target version changed from 1.1 to 1.1 RC1
Updated by Karsten Dambekalns about 1 year ago
- Target version changed from 1.1 RC1 to 1.1
- FLOW3 version affected changed from Git master to Git 1.1
Updated by Karsten Dambekalns about 1 year ago
- FLOW3 version affected changed from Git 1.1 to FLOW3 1.0.0
Updated by Gerrit Code Review 12 months ago
Patch set 8 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/7507
Updated by Gerrit Code Review 12 months ago
Patch set 9 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/7507
Updated by Gerrit Code Review 10 months ago
Patch set 10 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/7507
Updated by Karsten Dambekalns 10 months ago
- Target version changed from 1.1 to 1.1.1
Updated by Gerrit Code Review 10 months ago
Patch set 11 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/7507
Updated by Gerrit Code Review 10 months ago
Patch set 12 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/7507
Updated by Gerrit Code Review 10 months ago
Patch set 13 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/7507
Updated by Gerrit Code Review 10 months ago
Patch set 14 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/7507
Updated by Gerrit Code Review 9 months ago
Patch set 15 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/7507
Updated by Karsten Dambekalns 6 months ago
- Target version changed from 1.1.1 to 1.1.2
Updated by Marco Falkenberg 5 months ago
Are there any news or efforts about solving this bug?
Updated by Gerrit Code Review 4 months ago
Patch set 16 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/7507
Updated by Andreas Wolf 4 months ago
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
Applied in changeset 81997950b7819d9bc7938ee79dcc9aaedab6dcdc.
Updated by Gerrit Code Review 3 months 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
Updated by Gerrit Code Review 3 months 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
Updated by Gerrit Code Review 2 months 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
Updated by Gerrit Code Review 2 months 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
Updated by Gerrit Code Review 2 months 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
Updated by Andreas Wolf 2 months ago
- Status changed from Under Review to Resolved
Applied in changeset eee02f3ba30976da289da0d19fc6a905d703e059.
Updated by Andreas Wolf 2 months 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)