Static WordPress Community

Process_queue Seemed to Delete Some Files It Shouldn't Have

I have a question on how the process_queue command works from the WP CLI interface. I was under the impression that it would only process the items that changed in WordPress that were loaded into the job queue. Something odd happened recently after running that command on one of my sites. Some of the image files attached to content that didn’t change got deleted from the crawled and processed site folders. This made me nervous to rely on process_queue going forward, so I was hoping I might get an explanation of where I might’ve gone wrong.

Hi @knilob,

Thanks for using WP2Static (and via WP-CLI, great way to use it!).

What settings do you have for creating jobs? ie on a post update. And which jobs do you have it set to enqueue each time (detect, crawl, process, deploy)?

The basics of the Jobs/Queue are in this docs: WP2Static | Jobs, which I think you’ve seen.

To be honest, I don’t think many users are aware of/using the Jobs fuctionality, so I haven’t had much feedback about it. There’s a good chance you’re finding a bug.

About the possibly deleted files, I’ll need to look into the code / write some tests to confirm, but there shouldn’t be any selective deletion from those directories happening. Are you able to reproduce the issue and note the steps required to reproduce the isssue here?

In the meantime, the safest command to run would be wp wp2static full_workflow, which will do the whole detect, crawl, post_process and deploy each time (of you can call those individually within your scripts as needed), source code is here: wp2static/CLI.php at 27a682cae245f4337912f4f35fc751d286e64e48 · leonstafford/wp2static · GitHub

Thanks again for trying this out and I hope to work with you to improve the Jobs/Queue functionality!



Thanks for the response, Leon. I’ve been off a few days since I posted that question, so I’m just now getting back to all of this. For our creating jobs options, we have it set to run on Post Save and Post Delete. For Jobs That Will Be Queued, we have Detect, Crawl, and Process. We’re not currently using Deploy since we’re handling that in a custom way.

Thanks for mentioning the full_workflow option. I think I missed that when I was looking through the documentation and source code. I’m planning to use that going forward for my manual builds and cron jobs. I will try to do some more testing to see if the process_queue command still removes items that it shouldn’t.