Posted: March 15, 2020 at 1:26 pm
|
For half a year we are struggling with 404 errors on EE event pages. The previous (now closed) top is: https://eventespresso.com/topic/irregular-404-errors-continued/ We observed the site for some time now and checked the real-time PHP memory usage many times, during daily operations. Some typical values we’ve seen are as follows: So, our conclusion would be that the PHP memory limit is not a factor in relation to our problem after all. But we still have the problem that after about a day and a half all event pages start throwing that 404 again. This seems unrelated to the number of visitors on our site (ranging from a daily 125 to 400). We made it now our daily routine to deactivate and reactivate the EE core plugin every morning as a work-around to the problem. But of course this is not a sustainable solution. Do you have any further suggestions how we could proceed to solve the problem? |
Hi Joost, In short, we can’t reproduce this so it’s rather difficult to troubleshoot. We’ve tried multiple times with various setups and permalinks remain working just as they should whenever we run tests on this.
To be honest, I’m not sure how you’ve come to that conclusion just from the above. In your previous thread I posted this:
Did you investigate why the memory usage was spiking/climbing? De-activating EE and re-activating EE (and its add-ons) is all well and good, but if memory is spiking and the request to rebuild/flush permalinks can’t process it would cause issues like this with said permalinks. From the above, you’ve checked the memory usage after the issue has occurred, de-activated and noted the usage, then re-activated and noted usage, but none of that seems to be when the issue is actually occurring, correct? Do the permalinks stop functioning at a specific time in the day? If so do you have any daily scheduled tasks running on the server which would run roughly around the same time the issue occurs? —- What may help is to add a snippet to the site that writes a log entry saving the date & time, all of the rewrite rules and a call stack to a file. It isn’t going to fix anything but should give an idea of what is calling to flush the rewrite_rules and when/if they are missing from the site. There are a few steps you’ll need to take to set that up if you’d like to try it? You’d basically need a function to write to a log file that you leave active on the site until the permalink issue happens again (hopefully within 24hours from the sounds of it) then send that over to me to have a look over. Note that file may end up huge pretty quickly depending on the notices/warnings and other errors are thrown. (Again we are guessing as to what the cause is as we can’t reproduce on multiple different setups, so just to be clear, this may well end up being a wild goose chase but I think its worth a shot) |
|
|
This reply has been marked as private. |
This reply has been marked as private. | |
Hi Paul/Joost, Just checking in to confirm you received the above? |
|
|
Hi Tony, I just installed the plugin and updated the wp-config.php. Regards, |
Ok, before we even get into EE’s lost permalinks you have a bigger issue to fix first as it’s very likely connected. Every request on your site is flushing permalinks, even some front end requests which is crazy as flushing permalinks is expensive and should only be done when needed (new rules need adding, plugins activate/de-activate etc). Also, each of those requests is saving different rewrite_rules, which is likely a hint towards the problem you have with EE’s permalinks. I’m assuming you have a local copy of the site? If so, open up the entire Find out what is calling that function on every request, if it’s a plugin check for updates and if there are none, find another plugin. If it’s a theme… check for updates, if it’s your own theme, remove that code and use it correctly: https://codex.wordpress.org/Function_Reference/flush_rewrite_rules Your site should not be flushing permalinks anywhere near as often as it is and the fact that you are getting different rewrite_rules on those requests means something is running the above incorrectly. |
|
|
Thanks, Tony. I’ll do as you suggested and let you know the results. Regards, Paul |
|
Hi Tony, I did as you told me. I see the flush_rewrite_rules function in several plugin PHP files. But it’s not clear to me from the code if it’s actually being called during PHP execution, as the conditions in the program flow are not clear to me. I could try to disable those plugins one by one and look for any change in the logfile. Could you tell me what change to look for exactly in the logfile? Or I could send you the PHP files that contain the flush_rewrite_rules function. Would that be sufficient for you to see what’s going on? Please advice. Best regards, Paul |
Sure, I’ll reply in a private thread with specifics for your site after this one but you would disable the plugin then view the log file and note the ‘last’ entry containing the rewrite_rules wait a few seconds without visiting the WP Settings page in the admin (load a front end page of the site a couple of times) and just refresh the log file, if new rewrite_rule entries were made in that time, it’s not that plugin. Repeat until it stops adding rewrite_rule logs on each request and you’ve found the plugin. (See next reply for specifics relating to your site)
Whilst we can do that, code review isn’t covered under support so it would require support tokens to cover the time spent doing so. |
|
This reply has been marked as private. | |
|
This reply has been marked as private. |
Hi Paul, That’s a really interesting find. I downloaded a copy of Really Simple SSL and checked its code. The code that triggers a rewrite rules flush would normally prevent anything like this. It’s supposed to only flush rewrite rules once about 1 minute after plugin activation, and once after activating SSL. So unless the plugin or SSL setting is getting deactivated/reactivated a lot, the rewrite rule flushes shouldn’t be happening. One thing you could do is add the following to your site’s wp-config.php file:
What that will do is tell Really Simple SSL to not update the option Do you happen to also have any of the 3 following plugins activated on the site? |
|
|
This reply has been marked as private. |
Hi Paul, I can advise to contact WooCommerce support, they should have some troubleshooting steps for this because normally WooCommerce only flushes rewrite rules when needed. |
|
|
Thanks. I’ll do that and let you know the result. |
|
This reply has been marked as private. |
When you say it’s blank, do you mean it’s a whitescreen or no products? (meaning you can see some/all of the theme output but not the products themselves) If it’s a whitescreen it likely means the function is running over and over again then running out of memory. Load shop, then check your servers error logs, any errors? |
|
|
The page is there, only the WooCommerce generated output is completely missing. If I enable the rewrite_rules log plugin, it’s still there, but as soon as I also enable the logging, the products list in the shop page is gone. The product pages are still there. With enable logging I mean:
in the wp-config.php. |
Hmm, strange. The
Or
Correct? I have the latest version of Woo and my plugin enabled on a test site, loading the shop works fine for me with it enabled…. but, I also know that my site isn’t constantly flushing permalinks so that function should basically be doing nothing there anyway. So, a couple of things to try on your site. Comment out/Delete THIS LINE and THIS LINE. Its possible something is catching the exception (shouldn’t be but not much else I can think of). Rename ‘write_log’ to something else throughout that plugin, for example I would use |
|
|
Renaming write_log() to tw_ee_write_log() solved the problem of the missing WooCommerce shop page output. I will now report back to WooCommerce that enabling the plugin still causes a lot of permalink flushes with their updated plugin. |
Seems strange that Woo would be causing this, I don’t get the same issue on the site mentioned above. Are you sure it is not a template loading within your theme within Woo? Or another plugin hooking into Woo? |
|
|
I don’t know if there is a side-effect or an incompatibility with another plugin or such. I tried it with a lot of plugins disabled (including the Woo-related plugins) and then the difference (permalink flushes or not) is just between the Woo plugin active or not. Let’s wait and see what Woo has to say about it. |
|
The problem seems to have been solved by the recent WordPress update to 5.4. Both the permalink flushes and the 404 errors have gone since that update. I still don’t understand why this happened only in specific cases related to EE and Woo and presumably only on our website, but something in WP 5.4 has solved it. Thanks again for all the support time you have spent. |
I’m not sure why WP 5.4 would have changed this either, but for now, it’s working 🙂 If it happens again please do let us know, note we would need the log with the exception stack trace to be able to know what ran to cause the problem. Whilst I’m not recommending you leave that enabled (you could but you’ll need to monitor it to make sure the log doesn’t end up huge) if it happens again and you don’t have that trace, you’ll need to enable the log plugin again and wait for it to happen once again so it logs and we have something to work with. |
|
The support post ‘Irregular 404 errors – still a problem’ is closed to new replies.
Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.