-
-
Notifications
You must be signed in to change notification settings - Fork 529
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
Removed forced mgr context from findPolicy() #16214
base: 2.x
Are you sure you want to change the base?
Conversation
I'm not sure this is a great idea - don't we only have media source policies assigned to the mgr context? |
I don't know. All I do know is that this function is definitely getting triggered when I try to load a page in the web context and it generates a lot of extraneous error messages in those cases. If it only applies to mgr context, why is it being called at all in web context? Alternatively, if it should only work in mgr context, then shouldn't it return null (or similar) immediately in any other context rather than creating a query, etc.? At the very least, it is causing additional queries to run right now. |
I didn't mean it should only run in the mgr context, but because we only assign media source ACLs to the mgr context this code looks like it should definitely stay in place. We don't give a In your issue #16212 you haven't posted the exact error messages you were getting, so I think we need to really start there and figure out why what happens in a media source is affected by the |
There are the error messages I was seeing: [2022-05-11 20:00:03] (INFO @ /var/www/core/model/modx/modaccessibleobject.class.php : 40) Principal 0 does not have permission to load object of class modContext with primary key: mgr I traced it back to this line of code. |
Based on the code that follows the line I removed, it looks like there are already sufficient controls based on context without forcing to mgr context (which renders the function parameter obsolete). |
What's your thoughts about this @Mark-H ? I didn't look into the code but based on the comments here I think @CarlBohman is right. |
@Mark-H you have more thoughts on this one? @CarlBohman Do you have steps for reproducing the issue? I tried disabling |
I was able to get it to work consistently on my server. Maybe there is another contributing factor somewhere. However, even if there is no error produced (which there is on my system), why is this line even here? The function definition allows for $context to be supplied, but then completely overwrites it on the line I am proposing to remove. The remainder of the code depends on the context but it will be incorrect on any context except for the mgr context. |
It may be worth noting that the error message shows that it is produced when Principal 0 (an anonymous user, importantly with no access to the mgr context) tries to access a page in the web context. |
Would it be fine if (in addition to the removal of the line), this line was added to the top of the function? That seems like it might address the concerns raised by ensuring that it only runs for the mgr context and is always empty otherwise. |
tbh. I do not know why the without a proper steps to reproduce (I didn't manage to trigger the error, even for anonymous user), there's not much I can do about it. |
I just checked a local instance of ModX (2.8.4) and am still seeing the issue. This is what shows up in the error log (many times): I edited that This is the output:
I can add debugging where needed to try to narrow the issue down. If I make the change in this pull request or if I make the other change I suggested (returning an empty array if the context is not mgr), then the log messages go away. |
A bit more context based on my own tracing through the stack trace: The specific plugin that is being initialized is Lingua. It is a static plugin located in a custom media source (not "Filesystem") that is defined on my system (a separate directory). In Because anonymous users do not have "load" (or any other) permissions on I still see this as an issue that needs to be resolved. |
What does it do?
Removes the forced mgr context for the findPolicy() function.
Why is it needed?
See bug #16212
How to test
Related issue(s)/PR(s)
Resolves #16212