neos / flow-development-collection

The unified repository containing the Flow core packages, used for Flow development.
https://flow.neos.io/
MIT License
137 stars 188 forks source link

PointcutSettingFilter should allow unequal conditions #1907

Open lsascha opened 4 years ago

lsascha commented 4 years ago

Description

PointcutSettingFilter should allow unequal conditions too.

Steps to Reproduce

  1. Create an Aspect
  2. Add * @Flow\Before("method(Foo\Bar\Domain\Model\SomeModel->setSomeProperty()) && setting(Foo.Bar.some.setting != '')" as annotation to a method

Expected behavior

The aspect method should be called if configuration Foo.Bar.some.setting, has some value.

Actual behavior

it gives the following error message:

Exception #1355480641 in line 379 of /var/www/html/Packages/Framework/Neos.Flow/Classes/Core/Booting/Scripts.php: The given condition has a syntax error (Make sure to set quotes correctly).
Got: "''"
  Type: Neos\Flow\Aop\Exception\InvalidPointcutExpressionException
  Code: 1230047529
  File: Packages/Framework/Neos.Flow/Classes/Aop/Pointcut/PointcutSettingFilter.php
  Line: 138
Open Data/Logs/Exceptions/20200205113108422248.txt for a full stack trace.
18 Neos\Flow\Core\Booting\Scripts::executeCommand("neos.flow:core:compile", array|16|)
17 Neos\Flow\Core\Booting\Scripts::initializeProxyClasses(Neos\Flow\Core\Bootstrap)
16 Neos\Flow\Core\Booting\Scripts::recompileClasses(Neos\Flow\Core\Bootstrap)
15 call_user_func(array|2|, Neos\Flow\Core\Bootstrap)
14 Neos\Flow\Core\Booting\Step::__invoke(Neos\Flow\Core\Bootstrap)
13 Neos\Flow\Core\Booting\Sequence::invokeStep(Neos\Flow\Core\Booting\Step, Neos\Flow\Core\Bootstrap)
12 Neos\Flow\Core\Booting\Sequence::invokeStep(Neos\Flow\Core\Booting\Step, Neos\Flow\Core\Bootstrap)
11 Neos\Flow\Core\Booting\Sequence::invokeStep(Neos\Flow\Core\Booting\Step, Neos\Flow\Core\Bootstrap)
10 Neos\Flow\Core\Booting\Sequence::invokeStep(Neos\Flow\Core\Booting\Step, 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("/var/www/html/Packages/Framework/Neos.Flow/Scripts/flow.php")

Affected Versions

Flow: 6.1.1 and probably everything lower.

albe commented 4 years ago

Should not be too hard to implement, as all logic for parsing and evaluating is inside the class. Currently it only splits on PATTERN_SPLITBYEQUALSIGN, which is equal to /\s*( *= *)\s*/ (which in turn looks strange with the explicit whitespace before and after the equal)