Bug #39413

AOP: Property introduction seems to be broken

Added by Rens Admiraal 10 months ago. Updated about 1 month ago.

Status:Under Review Start date:2012-07-31
Priority:Must have Due date:
Assignee:Robert Lemke % Done:

0%

Category:Reflection
Target version:-
PHP Version: Complexity:
Has patch:No FLOW3 version affected:Git master
Votes: 2 (View)

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

History

Updated by Rens Admiraal 10 months 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.

Updated by Rens Admiraal 10 months 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.

Updated by Karsten Dambekalns 10 months ago

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

Updated by Karsten Dambekalns 10 months ago

  • Category set to Reflection
  • Has patch set to No

Updated by Robert Lemke 7 months ago

  • Assignee set to Robert Lemke

Updated by Karsten Dambekalns 5 months ago

  • FLOW3 version affected changed from Git 1.2 (master) to Git master

Updated by Christoph Gross 3 months 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;

}

Updated by Alexander Berl about 1 month 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.

Updated by Gerrit Code Review about 1 month 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

Also available in: Atom PDF