Closed claytoncollie closed 9 months ago
Thanks for the suggestion, @claytoncollie
I think I'd avoid a full refactoring and simply add some memory management while it's iterating through attachments.
I got 500k attachments :) guess ill just write a wrapper then
🔨
https://github.com/wp-cli/media-command/blob/830e72a2cbd3eeec95a97df2c1c17d925d86790d/src/Media_Command.php#L910
I used this script a few months ago on an install with somewhere around 12k attachments. I updated the theme and needed to resize all of my images. I initially used Regenerate Thumbnails but that timed out my login session and failed after a while. I then used this script which went a little faster but ultimately timed out and failed. I didn't think much of it then and kept running the script to see if I could make it all the way through my images.
Now that I am building a command for another client and using this script as an example, I am starting to think more about the WP_Query that gets all posts. To make this more scalable, should this query be changed to a paged query inside a foreach loop based on the number of total posts for this post type?
Something like