Overriding core files in MODX
We all know you shouldn't be doing this, but sometimes practicalities force us to apply a quick fix directly in the core folder.
One common use case is when you find a bug in a package and need to wait until your pull request with the fix is accepted and a new version released.
If you're using Git, then you probably excluded the core folder from your repository in .gitignore. But in the case of overriding a core file, it's actually nice to keep track of these edits with Git. This way you can keep an eye on things when updating (or reinstalling) the package, and it makes the edits portable between MODX installations.
To track your core edits with Git, add the file path to your .gitignore with an !
in front of it:
!core/components/superboxselect/processors/types/users/getlist.class.php
This only works if the file hasn't been excluded before, which is probably not the case in this scenario. So we need to force Git to start tracking this file:
git add -f core/components/superboxselect/processors/types/users/getlist.class.php
That's it! Now the file will be included in both new installations and your existing project.
And if a new version of the package get released with your fixes included, then you can stop tracking the file again by removing the line in .gitignore and running:
git rm --cached core/components/superboxselect/processors/types/users/getlist.class.php