Description
Bug Report
- Yes, I reviewed the contribution guidelines.
- Yes, more specifically, I reviewed the guidelines on how to write clear bug reports.
Describe the current, buggy behavior
The time that the wp site empty
command takes to run increases approximately linearly to the number of posts, comments, terms, and taxonomies on the site, because of all the querying and cache clearance that happens. This means it scales very poorly.
In addition, the query to fetch comments for deletion is unbounded, which means memory exhaustion could be experience on a site with a very large number of comments.
Describe how other contributors can replicate this bug
- Find yourself a site that contains a large number of posts, for example 100,000 or more.
- Run
time wp site empty --yes
and then go and put the kettle on.
Describe what you would expect as the correct outcome
The time that wp site empty
takes to run shouldn't be dictated by the number of objects in the database.
Provide a possible solution
Ideally the cache clearance would happen on a per-group basis to avoid the need to delete every cache entry for every object, but I understand that this is typically not possible.
It may be possible to simply call wp_cache_flush()
after truncating all the tables to flush the entire cache, although this will have side effects on a Multisite installation.