Wordpress save_post hook will be unnecessarily fired - wordpress

Having a WP multisite as a backend for my blog encountered a really weird issue. The multisite splits the blog into english and german. They have exactly the same setup, plugins, wp-theme etc.
The frontend is a gatsby site (static site generated with react) so have made an action on the save_post WP Hook to deploy the site. It worked well until recently it fires really frequently and unreliably but only of the english blog. The german blog as I said has everything the same yet it works as it supposed to work.
The hook makes a request with php curl to the deployHQ endpoint which triggers the deployment. The problem is that the save_post hook fires sometimes more than 3 times a minute then stops for maybe one minute then stops for a few minutes then again. Seemingly it does that without any sequence and feels like completely random. The time between 2 such request is never more than 10 minutes.
Do you have any idea what it may causes this or any way of debug?
Thank you for your support in advance!

Sorry guys it was due to a plugin. Whenever a request was made it fired somehow the post_save hook too. So if you're working with this hook I would recommend not to use this plugin: https://wordpress.org/plugins/wp-rest-api-log/

Related

What is a good action to use to update the WP database from my plugin?

I need a good trigger to use in my plugin to kick off changes to the website.
I've got a custom plugin that goes on all WordPress sites that I build. I've got it set up to auto-update the plugin.
Occasionally, I need to push out an update across all websites. For instance, there was a plugin that started causing issues across all sites so I wrote code in my function to deactivate it across all sites.
Now I'm writing code to remove some old users that should no longer have access to the site. To deactivate the plugin, I used the action 'plugins_loaded'. Of course the problem there is that it runs EVERY time the plugins are loaded so it runs on EVERY page load. It's pretty fast but still not the right way to do it.
I tried to find some sort of way to kick that one off only when the plugin is updated. Really, I just need these functions to run once ever.
Is there a good action I could use to make sure that happens?

Wordpress Api not up to date

I'm working on a project using WP's API along with VueJs + Nuxt for the front-end. Everything seemed to be working just fine, but since yesterday not all of my changes are fetched by the API.
It's really weird because, in the WP admin my changes are displayed as normal, but when looking at the response using postman, I can only see what was on my site prior to my changes, or only a few recent changes that don't even appear on the final render.
I am not using any type of extensions for cache as of now, but I've tried several extensions to empty it anyway, even if all of them signaled me that nothing is in the cache.
Could it be that the API got somehow "stuck" at some point and now no update is ever taken into account? Then is there anyway to "reset" this and force it to update?
Problem solved! I am using Gandi to host my site and I had no idea thye used Varnish as a caching solution. Disabled it and everything went back to normal. Thanks for your answers!

Wordpress unknow request slowing down my website

I am optimizing a wordpress site using woocommerce plugin.
All seems fine except one unknown request reported by gtmetrix.
It seems that this variable is being appended on every url on my site:
?resource=cart
This specific request takes 2 to 3 seconds to load
and here is the response:
{"cart":{"token":"","item_count":0,"total_price":0,"items":[]}}
Any ideas how to disable this?
Perfect! I advise you to disable all the plugins and reactivate one by one to figure out which to be the error on your site.
30 Plugins are many, and therefore they can try various contrasts between them, between the version of Wordpress and the version of Woocommerce.
After finding the wrong plugin, you can contact the developer to report the bug and have it updated.
Otherwise you will have to delete it and implement the PHP code yourself.

WordPress cache on the backend side

I have the same problem on different WordPress based websites.
I developed some of them, while others are made by someone else.
They don't have that much in common: completely different websites, different themes/plugins and so on.
Recently in these websites, I've been experiencing this problem: WordPress is caching the backend in a really tough way and, after saving any edits, I have to force a refresh with ctrl+f5 to actually see the edits I made before.
After some digging I can assure that:
it doesn't seem to depend on the webserver (same problem on nginx and on apache)
it doesn't depend on varnish or wp caching plugins (it happens also on website without any cache solutions)
it happens just in some new wp releases, I'm not experiencing this problem on older websites
it doesn't depend on my pc/browser configuration because my colleagues are experiencing the exact same problem on their pc
Anyone who had the same problem and was able to find a solution?
EDIT: It actually happened also on a fresh WordPress installation. Once I created a page, I went back to the page list by clicking on the menu item and I couldn't see the page in the list. After forcing a page refresh the newly created page was there as it was supposed to be before.

Long wait time before first byte is received

I have a website (currently running at www.subspace.cz), which I spent some time on optimizing. There's still some tasks to be done, like image optimization, but that's not the problem I'm solving now.
The problem is, that it almost constantly takes 1.6 seconds before the page starts loading, ie. before the webserver starts responding to the request.
I am certain this is not due to the hosting, since another website is also running at www.subspace.cz/trekken and is running fast. I also tried running this website on localhost on my i5 PC and the delay here is constantly 1.2 seconds.
I also ran WP-Optimizer on the database
I also tried switching the theme to Twenty Twelve and deactivated all plugins. The difference in the waiting time is insignificant, about 150ms.
It seems to me like the WP core has to be doing something that needs to be completed before the server starts responding... but over 1 second? Does any of you have a hint on what could be causing this?
Note: The admin section of the website is also affected by this waiting time.
Test the performance of installed plugins with P3 (Plugin Performance Profiler) that measures their impact on your site's load time. Badly written plugins can vastly increase the server response time ( for example, i was unpleasantly surprised when I discovered that only one plugin, which is only used for galleries, consumed 500ms of server time on each request,
regardless of whether it was even necessary for that request ).
The delay is usually because of the time spent by server on executing the code and once the code is executed, it then responds with the relavant html/css. Wordpress uses hooks, which means that everytime wordpress starts executing the code, it also has to execute all the code hooked into it, mostly by plugins. As Danijel mentioned, P3 Profiler can be used to check the performance of plugins.
Some plugins like woocommerce and acf are really heavy but you cant live without them, what you can do for this kind of situation is to use a plugin called "Plugin Organizer". By using this plugin you can organize your plugins for special pages. This way woocommerce will only be activated on product, cart and checkout pages and wont effect the performance of rest of the website.

Resources