Automattic / lightweight-term-count-update

Makes term count updates less painful
GNU General Public License v2.0
27 stars 8 forks source link

Account for term relationship changes #2

Closed mboynes closed 7 years ago

mboynes commented 7 years ago
mboynes commented 7 years ago

Looks like it's decrementing by 2 when terms are removed from a post. I'll add a test for this and get that bug resolved.

mboynes commented 7 years ago

@david-binda @mattoperry I had some momentum so I ran with this. Give it a review and if it looks good to you, I have a site I can test it on.

One important point, I bumped the minimum WP version to 4.7 due to a change to the added_term_relationship and deleted_term_relationships actions that went in in 4.7 (the $taxonomy param was added). Working around this is a moderate amount of work to support down to 4.3, and it would be very difficult to support < 4.3 (due to changes in get_term_by() introduced in 4.3 that we'd need to account for not having the taxonomy). My opinion is to keep it 4.7+ to keep the code as simple as possible, but if either of you feel strongly otherwise, please let me know.

mboynes commented 7 years ago

Plugin updated with numerous improvements. We have a failing test that I think I might change -- in short, if an unattached attachment (an attachment with post_parent == 0), the plugin counts it because the attachment is technically considered public. However, core doesn't correctly calculate this right now. Counting it, therefore, sidesteps a core bug (See #23530, #22558).

david-binda commented 7 years ago

Gah, I'm fixing the PHPCS issues.