-
-
Notifications
You must be signed in to change notification settings - Fork 168
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
No error thrown when accessing private and protected members of Kirby\Cms\App in a plugin #2394
Comments
It's because PHP's Plugins are loaded from the We could fix this by moving the |
I think the question then is - should plugins be able to access private and protected members of App? If I build a plugin that relies on the |
No, they should not rely on that access. It's a bug that you can access protected methods and properties, but the question is whether it matters: Plugin devs shouldn't use the protected methods for their plugins. |
@lukasbestle devs shouldn't use protected members, that's right. But it should be enforced. If VSCode suggests the So yes, I think it does matter. If you have access to something you shouldn't have access to, a fatal error should be thrown. |
That's why this issue is currently "missing: discussion 🗣". Waiting for input from @bastianallgeier and @distantnative. |
I agree that we should protect the App class from access via plugins. F::load does a few things that we don't really need here and I would probably prefer to have this as close to a native include as possible. |
This ensures that the included file can neither access any local variables from the calling methods nor protected methods from the calling classes. See https://www.php.net/manual/en/function.include.php#example-124.
This ensures that the included file can neither access any local variables from the calling methods nor protected methods from the calling classes. See https://www.php.net/manual/en/function.include.php#example-124.
This ensures that the included file can neither access any local variables from the calling methods nor protected methods from the calling classes. See https://www.php.net/manual/en/function.include.php#example-124.
✅ |
Describe the bug
In a plugin, you can access
kirby()->roots
and no error will be thrown. We had a discussion about that with @distantnative here.To Reproduce
Steps to reproduce the behavior:
var_dump(kirby()->roots)
in the plugin index.php fileExpected behavior
An error should be thrown.
Kirby Version
3.3.2
Additional context
If you do
var_dump(kirby()->roots)
in a template, you correctly get the error:However, doing the same thing in a plugin works, and it shouldn't. @distantnative mentioned this might be due to the way hooks are triggered:
kirby/src/Cms/App.php
Line 1292 in c1ff870
The text was updated successfully, but these errors were encountered: