Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cannot build interceptor code for private method BrowserState::initializeData() #2190

Closed
kdambekalns opened this issue Oct 29, 2020 · 16 comments
Assignees
Labels

Comments

@kdambekalns
Copy link
Member

Description

Updated a new Neos instance (Neos 5.3.0 and Flow 6.3.1 => 6.3.2) and ran ./flow package: rescan. Get the following error.

The Neos\Flow\Aop\Builder\AdvicedMethodInterceptorBuilder cannot build interceptor code for private method Neos\Media\Browser\Domain\Session\BrowserState::initializeData().
Please change the scope to at least protected or adjust the pointcut
expression in the corresponding aspect.
  Type: Neos\Flow\Aop\Exception
  Code: 1593070574
  File:
Packages/Framework/Neos.Flow/Classes/Aop/Builder/AdvicedMethodInterceptorBu
        ilder.php
  Line: 42
Open Data/Logs/Exceptions/20201029091519918cd4.txt for a full stack
trace.
  Type: Neos\Flow\Core\Booting\Exception\SubProcessException
  Code: 1355480641
  File: Packages/Framework/Neos.Flow/Classes/Core/Booting/Scripts.php
  Line: 699
Open Data/Logs/Exceptions/20201029091518caed70.txt for a full stack trace.

Affected Versions

Neos: 5.3.0

Flow: 6.3.2

@kdambekalns kdambekalns self-assigned this Oct 29, 2020
@kdambekalns
Copy link
Member Author

Related to #2131 (BUGFIX: Disallow advising of private methods)

@kdambekalns
Copy link
Member Author

Put this in Neos, as it is exposed by a Flow change, but seems to originate in Neos.Media…

@patriceckhart
Copy link

Exception #1355480641 in line 384 of /data/neos/Packages/Framework/Neos.Flow/Classes/Core/Booting/Scripts.php: The Neos\Flow\Aop\Builder\AdvicedMethodInterceptorBuilder cannot build interceptor code for private method Neos\Media\Browser\Domain\Session\BrowserState::initializeData().
Please change the scope to at least protected or adjust the pointcut
expression in the corresponding aspect.

  Type: Neos\Flow\Aop\Exception
  Code: 1593070574
  File: Packages/Framework/Neos.Flow/Classes/Aop/Builder/AdvicedMethodInterceptorBu
        ilder.php
  Line: 42

Open Data/Logs/Exceptions/20201029091519918cd4.txt for a full stack trace.

13 Neos\Flow\Core\Booting\Scripts::executeCommand("neos.flow:core:compile", array|16|)
12 Neos\Flow\Core\Booting\Scripts::initializeProxyClasses(Neos\Flow\Core\Bootstrap)
11 call_user_func(array|2|, Neos\Flow\Core\Bootstrap)
10 Neos\Flow\Core\Booting\Step::__invoke(Neos\Flow\Core\Bootstrap)
9 Neos\Flow\Core\Booting\Sequence::invokeStep(Neos\Flow\Core\Booting\Step, Neos\Flow\Core\Bootstrap)
8 Neos\Flow\Core\Booting\Sequence::invokeStep(Neos\Flow\Core\Booting\Step, Neos\Flow\Core\Bootstrap)
7 Neos\Flow\Core\Booting\Sequence::invokeStep(Neos\Flow\Core\Booting\Step, Neos\Flow\Core\Bootstrap)
6 Neos\Flow\Core\Booting\Sequence::invokeStep(Neos\Flow\Core\Booting\Step, Neos\Flow\Core\Bootstrap)
5 Neos\Flow\Core\Booting\Sequence::invoke(Neos\Flow\Core\Bootstrap)
4 Neos\Flow\Cli\CommandRequestHandler::boot("Runtime")
3 Neos\Flow\Cli\CommandRequestHandler::handleRequest()
2 Neos\Flow\Core\Bootstrap::run()
1 require("/data/neos/Packages/Framework/Neos.Flow/Scripts/flow.php")

@kdambekalns
Copy link
Member Author

Thanks for the trace! But as I feared, not helpful. 😞

@albe
Copy link
Member

albe commented Oct 29, 2020

Yeah, we need to find the aspect that targets this class. The expression is probably too loose and accidentially targets the initializeData method. If targeting this method is intended, then this is a bug uncovered.

Edit: Can't find anything in Neos.Media and Neos.Media.Browser - so another package that AOPs the Media Browser?

@bwaidelich
Copy link
Member

The stack trace helped me a little :)
I think it's the SessionObjectMethodsPointcutFilter of Flow that targets the method. Investigating why that is...

@bwaidelich
Copy link
Member

OK, it's because we include private methods in

public function matches($className, $methodName, $methodDeclaringClassName, $pointcutQueryIdentifier)
{
if ($methodName === null) {
return false;
}
$objectName = $this->objectManager->getObjectNameByClassName($className);
if (empty($objectName)) {
return false;
}
if ($this->objectManager->getScope($objectName) !== ObjectConfiguration::SCOPE_SESSION) {
return false;
}
if (preg_match('/^__wakeup|__construct|__destruct|__sleep|__serialize|__unserialize|__clone|shutdownObject|initializeObject|inject.*$/', $methodName) !== 0) {
return false;
}
return true;
}

@bwaidelich
Copy link
Member

Adding some

        if (!is_callable([$className, $methodName])) {
            return false;
        }

there seems to do the trick but I'm not sure if that's the best way to go

@kdambekalns
Copy link
Member Author

That being said, in

if (preg_match('/^__wakeup|__construct|__destruct|__sleep|__serialize|__unserialize|__clone|shutdownObject|initializeObject|inject.*$/', $methodName) !== 0) {
the expression should be ^(?:__wakeup|__construct|__destruct|__sleep|__serialize|__unserialize|__clone|shutdownObject|initializeObject|inject.*)$ (added grouping), to make ^ and $ work with all alternatives!

Screenshot 2020-10-29 at 10 20 08

@kdambekalns kdambekalns transferred this issue from neos/neos-development-collection Oct 29, 2020
@kdambekalns
Copy link
Member Author

It's in Flow, after all, so I moved the issue.

@bwaidelich
Copy link
Member

..good call (both)

@albe
Copy link
Member

albe commented Oct 29, 2020

Adding some

        if (!is_callable([$className, $methodName])) {
            return false;
        }

there seems to do the trick but I'm not sure if that's the best way to go

is_callable checks callability from current scope, right? But what about protected methods?

@bwaidelich
Copy link
Member

is_callable checks callability from current scope, right? But what about protected methods?

good point.. maybe check for private scope explicitly

@bwaidelich
Copy link
Member

@kdambekalns @albe This issue is assigned to the three of us for some reason.
Is one of you working on a fix? Because I'm currently not, but I could have a look tomorrow if nobody takes care of it before that

@kdambekalns
Copy link
Member Author

I assigned it to us, since we discussed it this morning. Didn't @kitsunet mention he might be able to look into it?

@kdambekalns
Copy link
Member Author

I'll work on this now.

kdambekalns added a commit that referenced this issue Oct 29, 2020
The matches() method did not skip private methods, so Flow tried to
build interceptors for them. That breaks as of the bugfix in
#2131, leading
to #2190

Fixes #2190
neos-bot pushed a commit to neos/flow that referenced this issue Oct 29, 2020
The matches() method did not skip private methods, so Flow tried to
build interceptors for them. That breaks as of the bugfix in
neos/flow-development-collection#2131, leading
to neos/flow-development-collection#2190

Fixes #2190
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants