-
-
Notifications
You must be signed in to change notification settings - Fork 164
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
Invalid logic of matching joinpoints for complex pointcuts with logical operators #217
Comments
I figured that this problem was because method called was inherited from the superclass. In details it's actually more tricky than that:
Is there a way to make this setup work somehow? |
Hello! |
Ok, so my test case: BaseController.php class BaseController
{
public function handle_GetDefault()
{
echo __CLASS__.':'.__FUNCTION__, PHP_EOL;
$this->handle_Default();
}
public function handle_Default()
{
echo __CLASS__.':'.__FUNCTION__, PHP_EOL;
}
} JscssController.php: class JscssController extends BaseController
{
public function handle_Default()
{
echo __CLASS__.':'.__FUNCTION__, PHP_EOL;
}
} Pointcut is modified a bit: And then test case: $ctrl = new \Demo\Example\BaseController();
$ctrl->handle_GetDefault();
echo PHP_EOL;
$ctrl = new \Demo\Example\JscssController();
$ctrl->handle_GetDefault();
die; Output is following:
First part is perfect, because it's what we want when declare First thing that we see is two lines "Before". This wasn't expected, but there is a reason, method Then we see, that original method Now I'm thinking is there a bug or not. According to the class inheritance and definied pointcut this is and expected behaviour for now. But it's impossible to ignore this methods in children classes. So, maybe new syntax should be developed or keyword, like |
Alternatively, you could use a workaround for this and add a check into the advice body. if ($invocation->getThis() instanceof JscssController) {
return; // just do nothing for this case
} |
Hi, First of all, terribly sorry for late reply! The suggestion of using code to filter out controller - I'm already doing that. It just would be nice to use expressions only. :) Now to the test case.... To me it looks like a bug, because although However, the fact that a child |
Hi! Don't worry about late reply ) I'm also busy and can spend only limited time on my project, so I should excuse instead. But yesterday I revised the whole logic of matching joinpoints for complex pointcuts and surprisingly discovered that it can be absolutely incorrect 😃 So, yes, I can confirm that for complex pointcut expressions matching can be incorrect due to two cases:
|
I see, but I cant say that it's absolutely incorrect. Let's say it would cover most of the cases that ppl usually encounter :) I'm ashamed to say that I cannot suggest anyone worthy to help with the grammar (including myself). Of course you most probably have looked at existing solutions like rvanvelzen/lime? Could they be of any help? |
This part is fixed by #220
This still present, I will look into it soon. |
There is a progress on this: see #274, this feature allows to control matching of inherited methods. And now I'm trying to fix logic for "OR" pointcuts. |
* origin/1.x: Fix logic of complex pointcuts, combined with OR, resolves #217
Hi,
I've stumbled upon a behavior which I cant seem to figure out. Consider the following pointcut expression which applies to any controller in
**\common\**
namespace except forLoginController
:Then when I change it to:
!within
stops working in the sense that theJscssController
is never excluded - i.e.beforeMethodExecution
always fires. What am I doing wrong here?The text was updated successfully, but these errors were encountered: