-
-
Notifications
You must be signed in to change notification settings - Fork 14
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
Fix access of undefined array index file when internally analyzing stack frames #50
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs test additions
Yeah would love to add a test but it is quite difficult because there are no existing tests for the class and mocking the native buildin functions is quite hard. Any suggestions how to start this? |
I think a backtrace is not available when the code is either internal, or A test could do something like: $provider = new EventContextProvider();
$file = eval(<<<'PHP'
return (function (): void {
return $provider->getEventTriggerFile();
})();
PHP
);
self::assertSame('', $file); Alternatively using |
I added a crazy testcase for this specific case 🙈 |
Test case makes sense, now we need to make CI green :D Also: 100% sure this makes PHPUnit fail when your patch is not applied? |
Target branch need to be changed to 2.7.x or 2.8.x and rebase. |
A bugfix goes to the current release branch (2.7.x):
|
Happens if I remove my patch.
Will try to solve this as best as possible :-D |
If I try to fix psalm and add I think I'll just close this cause creating a test case for it is quite annoying 🙈 |
Okay I think I'll not be able to solve the psalm errors without breaking the test case again. I'll get some sleep and may be next week I have a solution for the testcase 👼 |
Hmm, something went wrong with the rebase here - I can take over, if it's not clear :) |
was too late yesterday 🙈 Would be happy if you help cause I got somewhere stuck with the rebase, tought it was right but it seems not. |
a011f3f
to
9ec53cb
Compare
Currently checking this locally: interestingly, if |
Rewriting some of the test to use |
`call_user_func()` is automatically optimized away by PHP-SRC starting from early PHP 7 releases, and therefore cannot be used to generate artificial stack frames that are detected in PHP-SRC itself. With this change, we use `array_map()` instead, which (for now) is not optimized away (yet).
9ec53cb
to
229ca7a
Compare
229ca7a
to
7c1f50d
Compare
I rewrote most of the patch, and GIT somehow lostsome ownership of the patch here, sorry :-( Still, final result is much cleaner, I'd say. |
Thanks @reinfi! |
@reinfi |
thank you guys <3 |
Description
When triggering events from within a controller plugin in laminas mvc the index is not a file because it is an invokable function.
4 = {array} [5] function = "__invoke" class = "Application\Controller\Plugin\ForwardToPlugin" object = {Application\Controller\Plugin\ForwardToPlugin} [3] type = "->" args = {array} [2]
I just checked if the index exists and return an empty string.