exclude_tree in wp_list_pages causes heavy CPU usage
|Reported by:||henry.jiang||Owned by:||ryan|
When using exclude_tree in wp_list_pages to exclude pages from the page menu bar, CPU usage jumps to 99.9%. In my example, I have 3000 pages who's parent is 13955 that I'm excluding from the menu bar by using exclude_tree in wp_list_pages.
This caused 99.9% CPU usage, and in a high traffic scenario, web server crashed unexpectedly. The piece of code responsible is in wp-include\post.php: &get_posts()
exclude_tree is being done after get_results() and update_page_cache(). This is the reason for the CPU spike.
A better way to implement exclude_tree should be before the call to get_results()