-
Notifications
You must be signed in to change notification settings - Fork 1
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
CDPT-2259 Don't delete non-existent documents. #781
CDPT-2259 Don't delete non-existent documents. #781
Conversation
@EarthlingDavey is it possible to use one of EPs hooks for this instead of rewriting the code through a script? I haven't tested this, but there's |
Hey @EmilyHazlehurst thanks for the suggestion. This might be one of the cases where there is no obvious 'best way'. We only really need to do this
I think if someone clicked the delete button we shouldn't be doing I absolutely do see the benefit of using hooks and not writing custom hacks, so I'm on the fence. What do you think, I could put in a pull request upstream to add a filter in the ideal location - with the intent for us to use that if/when it's merged? |
Thanks for the info @EarthlingDavey. Yeah, I'm really hesitant to add custom code in this way... I understand your points though, especially as we're then relying on a third party to merge. It just introduces a lot of potential headaches with updates/debugging later on. I'm not sure if this is 'the Wordpress way', but is it possible to apply the change as a patch with composer? I usually use Composer Patches: Repo: https://github.com/cweagans/composer-patches You can then just add something like this to the composer file:
|
Hey @EmilyHazlehurst composer patches looks interesting. I've used something similar with node. Today's been very busy, so I'll check it out properly next week. |
Hey @EmilyHazlehurst I'm trying to weigh up the options and arrive at a pragmatic solution. Are these the main concerns that you had in mind:
Can you envisage other downsides to the find/replace script? All extra info will help us make an informed decision. For additional context, we have had some success with creating a find and replace script, creating an upstream PR, and removing the find/replace once the upstream package released an update. Debugging hasn't been much of an issue as the script runs locally, so the local files are an accurate representation of what's run, and what will be run upon deployment. I've researched The pros are:
The cons are:
Do you think that's a fair summary, should I add anything else? I'm wondering if there's a quick fix to improve the robustness of the find/replace script - so that it's on par with that of Then we can postpone a decision to adopt |
@EarthlingDavey exactly that.
I suppose my concern here is how does someone know that the code has been changed with a find and replace. Is there something in the replaced code to indicate that it's been added by a script and where that script is? Also, if something changes in the plugin how would someone know if the script failed to apply properly? Say a new dev was asked to update the ElasticPress version. They run
That's fair. Given there's precedent for this in this project I don't mind approving this PR, but I agree it'd be good discuss the best solution going forward as part of tech. maintenance 🙂 |
Hey @EmilyHazlehurst , thanks for the extra detail 💯 I've made some final changes based on your suggestions.
This is such a good shout, thanks! In this case I've now added a comment
The ![]() ![]()
I've added a comment to to the script file, that should help debugging and identifying when the find/replace is no longer needed. |
This PR uses composer-post-install.sh to modify the ElasticPress plugin.
It adds a check for a document, before deleting it.
This will fix the following logs coming from the proxy service.