-
- 75 Posts
I need to speed up the getCollection script in a certain circumstance. I don't need to check permissions at all, but MODX checks all the permissions on all objects unless the user is a sudo user. I need to emulate this faster mode without making users sudo users.
-
- 24,544 Posts
This is about writing to the DB, but changing the SQL should let you read without involving permissions:
https://bobsguides.com/blog.html/2014/12/01/bypassing-modx-to-write-directly-to-the-database/
-
- 75 Posts
I appreciate the response, Bob, though it sounds like you're basically saying I can run my own queries and not use getCollection, which is of course true. We took a closer look at the MODX code itself and there is a flag for sudo users at one point in the code, but there's no way to take advantage of that flag through the API or to tell the script to bypass the permission checks.
Our plan now is to copy the relevant parts of the MODX code into our own code base and add an override feature. If anyone knows of a better way that's already built into the MODX core, I'd love to hear it.
-
- 24,544 Posts
If you can run your code from the command line, MODX skips the permission checks in CLI mode. If your data doesn't change that often, you might be able to use a cron job to call a PHP script that writes everything to a file and use that for your display.
Personally, I would write my own snippet to do the queries rather than modifying the core code, which may be undone when you upgrade MODX, though maybe I'm misunderstanding what you intend to do.
-
- 75 Posts
Interesting about the command line difference.
We're not going to modify the MODX code in MODX itself. We're just going to copy code from MODX into our own code and make it our own, outside of MODX.