the-events-calendar / the-events-calendar-category-colors

Plugin add-on for The Events Calendar to colorize categories
https://wordpress.org/plugins/the-events-calendar-category-colors
45 stars 19 forks source link

Plugin should not update options when viewing frontend #153

Open kadamwhite opened 1 year ago

kadamwhite commented 1 year ago

I've observed that the recent changes to this plugin are causing an update_option call on every page view. This causes performance issues on high-traffic sites, because frontend site views cause a database write in addition to reading all of their normal content out of the database.

I'm looking at this line: https://github.com/the-events-calendar/the-events-calendar-category-colors/blob/develop/src/Category_Colors/Main.php#L247 get_category_terms is called by load_categories, which is hooked to init, which runs every time WP spins up to serve a request.

It feels like we shouldn't have to update any content on a normal frontend page view. I'd only expect an option to get written if the user has taken some action which could change the contents of the option, or possibly if a cache has expired.

afragen commented 1 year ago

Interesting that the blame shows this line has been present for 9 years.

I do agree that this shouldn't happen.

FYI, I've given the plugin the The Events Calendar folks for maintenance and support. I'll still be helping where I can.