lightweight-term-count-update
lightweight-term-count-update copied to clipboard
Consider edge cases around wp_defer_term_counting()
From #2 (direct link to comment):
I like the idea and it seems to be working fine. I'm just not sure whether we should not check whether the counting is still deferred right before running our SQL queries. While checking whether wp_defer_term_counting() is still returning true might be a quick solution, it does not seem to be bulletproof.
We could perhaps hook the edited_term_taxonomy or edit_term_taxonomy actions and check whether they were called for the term and taxonomy we are currently updating before running our updates.
Looking into this, I have found out that the wp_defer_term_counting is being used in wp_nav_menu_update_menu_items
I'm going to dig into it and figure out what are the consequences of this. In case it least to messed up counts, I'm going to write tests and some mitigating logic.