Question about adding and removing filters

9 views
Skip to first unread message

David A

unread,
Nov 22, 2022, 8:05:37 PM11/22/22
to Minneapolis St. Paul WordPress User Group
Hi All,

We had a weird situation where some of our RSS feeds were taking up to 30 seconds.  I think that we had this problem for a while in our environment but it was being "masked/hidden" by our Caching Server, once the caching server had the copy of the RSS feed it was fine, and of course, nobody goes to the RSS feeds.  At least no human, so nobody complained.

But we were doing some maintenance on the test server and shut down the caching server, and I noticed that from time to time test site response times were spiking.  It took me a while to figure out that it was the RSS feeds.  But not all of them.

After looking at the traffic reports and logs, the guilty party seems to be a custom plugin that in theory should not have even been causing those spikes.  Following the code, I figure out that we have some filters been removed and added to modify the RSS feed to include some custom fields.  Do no ask me why, but the add and remove filters were under the do_action "init" in the function.php file.  And the callbacks on this plugin.

I was going to split the code and move action to add and remove filters to the custom plugin so I could activate and deactivate the plugin and be able to troubleshoot the plugin.  To my surprise, the feeds that before were taking 30 seconds were taking 3-4 seconds once I moved the actions to the plugin.

I tried to figure out what is the reason for this improvement but I did not find an answer, so I am looking to see if somebody has experienced something similar, or if they know why moving the add and remove filter actions out of the function.php would improve performance so much. 

Also, I noticed that function that was wrapping the add and remove filters was called several times during one RSS feed refresh when the action to was in the function.php

Thanks, David
Reply all
Reply to author
Forward
0 new messages