Bug #39413

AOP: Property introduction seems to be broken

Added by Rens Admiraal about 3 years ago. Updated about 1 year ago.

Status:Resolved Start date:2012-07-31
Priority:Must have Due date:
Assigned To:Robert Lemke % Done:

100%

Category:Reflection
Target version:-
PHP Version: Complexity:
Has patch:No Affected Flow version:Git master

Description

Introducing a property does not work at the moment. The functional tests are passing.

Attached is a Test package as example to show the problem.

Test.zip (7.4 kB) Rens Admiraal, 2012-07-31 14:04


Related issues

related to TYPO3.Flow - Bug #27045: Introduced properties are not available in the reflection... New 2011-05-26
related to TYPO3.Flow - Feature #37373: Make annotation overrides / "injection" via Objects.yaml ... Under Review 2012-05-21

Associated revisions

Revision 915b71ce
Added by Alexander Berl about 2 years ago

[BUGFIX] Property introduction is broken

This change fixes property introduction through aspects by adding
missing checks for available property introductions.

Change-Id: I0e89a6f9eca218c2e29956c7416dcede4b7d2b1a
Fixes: #39413
Releases: master, 2.0

Revision 23492025
Added by Alexander Berl about 2 years ago

[BUGFIX] Property introduction is broken

This change fixes property introduction through aspects by adding
missing checks for available property introductions.

Change-Id: I0e89a6f9eca218c2e29956c7416dcede4b7d2b1a
Fixes: #39413
Releases: master, 2.0

History

#1 Updated by Rens Admiraal about 3 years ago

Extra info: property introduction does work if you also introduce an interface in the aspect. But as there could be usecases where you don't want to introduce methods it should be possible to do without that.

#2 Updated by Rens Admiraal about 3 years ago

debugged a bit further, seems like getProperties() in the reflectionService does not have the introduced properties during the compile run, so doctrine:migrationgenerate does not pick up the new properties. Might be a good thing if someone more into the reflection / proxy building stuff has a look at this issue.

#3 Updated by Karsten Dambekalns almost 3 years ago

  • Project changed from TYPO3 Flow Base Distribution to TYPO3.Flow

#4 Updated by Karsten Dambekalns almost 3 years ago

  • Category set to Reflection
  • Has patch set to No

#5 Updated by Robert Lemke almost 3 years ago

  • Assigned To set to Robert Lemke

#6 Updated by Karsten Dambekalns over 2 years ago

  • Affected Flow version changed from Git 1.2 (master) to Git master

#7 Updated by Christoph Gross over 2 years ago

Bug still present in current master. Introduced properties are not added by doctrine.

Uncaught Exception
    The class "CGROSS\Drinkaccounting\Aop\MultiCommunitySupport" is tagged
  to
    be an aspect but doesn't contain advices nor pointcut or introduction
    declarations.

<?php
namespace CGROSS\Drinkaccounting\Aop;

use TYPO3\Flow\Annotations as Flow;

/**
 * Inject community-attribute to every class
 *
 * @Flow\Aspect
 */
class MultiCommunitySupport {

    /**
     * @var string
     * @Flow\Introduce("class(CGROSS\Drinkaccounting\Domain\Model\User)")
     */
    protected $community;

}

Adding a pointcut (even if not used) and the error message is gone BUT the property is still not created by doctrine:update.

<?php
namespace CGROSS\Drinkaccounting\Aop;

use TYPO3\Flow\Annotations as Flow;

/**
 * Inject community-attribute to every class
 *
 * @Flow\Aspect
 */
class MultiCommunitySupport {

    /**
     * A pointcut which matches all guestbook submission method invocations
     *
     * @Flow\Pointcut("method(CGROSS\Drinkaccounting\Domain\Model\User->create())")
     */
    public function guestbookSubmissionPointcut() {}

    /**
     * @var string
     * @Flow\Introduce("class(CGROSS\Drinkaccounting\Domain\Model\User)")
     */
    protected $community;

}

#8 Updated by Alexander Berl over 2 years ago

There are actually two points where propertyIntroduction is not taken into consideration:

1. At the end of ProxyClassBuilder->buildAspectContainer, the count of propertyIntroductions isn't taken into account before throwing the "doesn't contain advices nor pointcut or introductions" exception.

2. In AspectContainer->reduceTargetClassNames, the targetClassName cache isn't reduced over propertyIntroductions, leading to all classes that are not also subject to another advice or interface introduction to not be considered at all, hence no property is introduced in the proxy class.

I'll provide a change set for that tomorrow. From there on it's maybe easier to find the spot where to put a proper update of the reflectionData.
My current assumption is, that the ReflectionData is collected before the proxy exists and afterwards the reflectionData isn't updated anymore.

#9 Updated by Gerrit Code Review over 2 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 https://review.typo3.org/20000

#10 Updated by Gerrit Code Review about 2 years ago

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

#11 Updated by Gerrit Code Review about 2 years ago

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

#12 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/20000

#13 Updated by Gerrit Code Review about 2 years ago

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

#14 Updated by Alexander Berl about 1 year ago

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

Also available in: Atom PDF