Publisher does not support the Fluid field type. Please do not contact asking when support will be available.
If you purchased an add-on from expressionengine.com, be sure to visit boldminded.com/claim to add the license to your account here on boldminded.com.
Ticket: 500 error when trying to access cached page on front-end
Status | Resolved |
Add-on / Version | Speedy 1.9.1 |
Severity | |
EE Version | 7.4.5 |
DSite
Mar 27, 2024Hi Brian,
I am back with another puzzling 1.9.0/1.9.1 issue… I’m getting a 500 error on the front end when trying to access cached versions of a page. I know those are the worst, but maybe you can see what I’m missing.
I have a site that is working properly with 1.8.1. To generate the error, I do the following: 1. Replace the 1.8.1 add-on files with 1.9.0/1.9.1 (I’ve tried both) 2. Update the add-on in the add-ons section 3. Delete the /html/static directory 4. Regenerate it from the Speedy control panel page
The first time I visit a page, it appears properly. When I refresh the page, I get the 500 error.
Speedy does generate the static version of the page. I can see it in the CP and in the static directory. As far as I can tell, those cached versions seem to be as expected. But something is not connecting to the static version on the second page load.
I’ve turned on debugging, but that obviously doesn’t help much with a 500 error.
When I revert to 1.8.1, everything works as expected.
Again, I know that this is likely not enough information. Aside from turning off other add-ons to look for conflicts, is there a troubleshooting step that I’m missing? I’ve seen one or two 500-error-related tickets in the last couple of months, but I can’t tell if you’ve made suggestions in the private messages that might help.
BoldMinded (Brian)
Check your php error log on the server, or try this https://gist.github.com/litzinger/5598641
DSite
Thanks, Brian.
Here is what I see in the PHP logs:
I’m not super fluent in stack trace, but it looks like Speedy is trying to connect to the database sever and failing because EE can’t load my environment variables in .env.php?
If that is roughly correct, it’s puzzling to me in that EE has no issues connecting to the database for the initial page load or for the admin.
Do you have a clearer idea of what might be happening here and how I might go about fixing or troubleshooting this further?
BoldMinded (Brian)
When using static caching, and making it support the CSRF token it needs to connect to the database directly and not to through EE, but it looks like I didn’t account for loading config values from env vars…. something EE does when it boots up. I’ll have to take a look at this and find a fix. For now though you’ll need to get your db connection info into the config directly for it to work :(
DSite
Thanks. I just verified that adding the database connection info to config.php resolves the issue.
For what it’s worth, I’ve used Speedy successfully with env vars for a while now. 1.8.1 seems to handle them successfully. It’s only the newer builds that trigger the error for me.
If there’s anything I can do to help you troubleshoot or test further, I’m happy to help.
BoldMinded (Brian)
Right, the newer build is what fixes the CRSF issue by making the DB connection. Try this. Open the SpeedyDatabase.php file in the speedy/Service/Csrf folder (this is what gets copied to the utilities folder). On line 55 after the include $configPath line add this:
I haven’t tested this so I’m just speculating, but it might fix it. You’ll need to regenerate your utilities folder.
BoldMinded (Brian)
Disregard this comment
DSite
I’m still getting the same error after adding the code and regenerating the utilities. I’m assuming I applied it correctly, but just in case:
BoldMinded (Brian)
Comment has been marked private.
DSite
Comment has been marked private.
BoldMinded (Brian)
Comment has been marked private.
DSite
Comment has been marked private.
BoldMinded (Brian)
Cool! I’ll get that fix into the next release.