Handling 404/4xx/5xx errors in Symfony 4 - symfony

I'm using Symfony 4.4.10 and I do have problem with correct error 4xx/5xx handling to get users to my custom html.
On production, when 500 error occurs, I'm getting this kind of screen:
Which is weird, because I followed this tutorial: https://symfony.com/doc/current/controller/error_pages.html
I have my templates overridden (like here), but still above screen occurs. (adding error500.html.twig file isn't changing anything)
When I'm debuging on dev it's ok, I mean, with this custom "_error" route.
What can be the problem here?
404 errors and sometimes work, sometimes not.

Regarding the documentation and your shared code, you are right.
Have you got clear cache dev and production environment ?
php bin/console cache:clear

Related

How to show errors in browser?

I'm getting started with Sylius. Symfony version is 3.2.7. On some pages I have some errors. The pages show text:
Oops! An Error Occurred
The server returned a "500 Internal Server Error".
Something is broken. Please let us know what you were doing when this error occurred. We will fix it as soon as possible. Sorry for any inconvenience caused.
I want the errors to be displayed in browser, with full stacktrace.
I know I can see the error in var/prod.log, but it doesn't show the whole stacktrace, only the last frame. And seeing the error in browser would be more convenient: that's what I'm used to after a lot of working with Yii and Magento.
Is that possible with Symfony/Sylius?
I added /app_dev.php to the url to run the website in development environment, and there I can see the stack trace.
That is, https://[my_domain]/app_dev.php/[page] instead of https://[my_domain]/[page]
By default Symfony show trace in dev environment. In prod environment it show simple error message. For running your project in dev you can use built-in PHP Web Server or Web Server Bundle
Also you can use symfony installer app to serve request
Use symfony serve --no-tls in symfony folder.
It will show you requests and errors in red.

2sxc: 404 Error after adding App module on the page. API is missing?

I have a problem when placing an App module(v 8.4.8) on a page. When I placed an App module on a page I got a pop up saying "Had an error talking to the server (status 404). if you are an advanced user you can learn more about what went wrong - discover how on 2sxc.org/help?tag=debug".
This error happens on whatever action I try to do: trying to add and app, refresh page etc.
I checked a communication to the server using Firebug and seems that one of APIs are missing:
~/desktopmodules/2sxc/api/view/Module/GetSelectableApps
Referer: ~/desktopmodules/tosic_sexycontent/dist/dnn/ui.html?sxcver=8.4.8.19191
Did I missed something? Should I make some configuration after SexyContent module install (v 8.4.8)?
I just checked a video by Daniel Mettler where he showed how to install a module and seems that process is simple. Nothing to worry about.
Does anybody has any idea what might went wrong here?
The same actually happens when I install and Content module: Error about missing APIs:
~/desktopmodules/2sxc/api/view/Module/GetSelectableContentTypes
~/desktopmodules/2sxc/api/view/Module/GetSelectableTemplates
Thanks a lot for your time
My best guess is that it's an issue with the dnn domain/path configuration. So basically my guess is that
you have multiple domains, and if this is configured incorrectly, the paths in the js-calls won't fully match the original one
you have sub-portal (with paths like /products/) or something, and this isn't configured correctly in dnn
languages in portal-paths are causing similar issues.
So please compare EXACTLY the full base path and see if that's the issue.

Issues with Symfony 2.3 Web Debug Toolbar

I'm in the process of upgrading old project from Symfony 2.1.x to 2.3.38, later I might try upgrading to latest LTS version. But first, I'd like to get it working at least on 2.3.
Here's the first hint, that something is wrong:
Code inspector shows that there are <a> blocks above two first buttons on toolbar, linking to _profile.
And clicking on any of toolbar items, to get inside debugger, ends up in routing error:
[3/3] Twig_Error_Runtime: An exception has been thrown during the rendering of a template ("No route found for "GET /my_project/web/_wdt/bdc9db"") in #WebProfiler/Profiler/layout.html.twig at line 5.
[2/3] NotFoundHttpException: No route found for "GET /my_project/web/_wdt/bdc9db"
[1/3] ResourceNotFoundException
Maybe someone has encountered similar issues during upgrades? Any ideas how to debug this?
UPDATE:
Regarding the icons offset, looks like this was an issue with Symfony 2.3.38. I upgraded to 2.3.39 and icons are rendered correctly.
"No route found" issue still persist. _wdt is among the routes listed with app/route:debug.
UPDATE 2:
Finally found, that issue with "No route found" is related to sonata/cache-bundle package. If I remove it from AppKernel.php - everything works correctly. It also fixed issue I had with missing session data.
Have You checked if Your app_dev.php is following changes made in 2.3LTS?
https://github.com/symfony/symfony-standard/blob/2.2/web/app_dev.php https://github.com/symfony/symfony-standard/blob/2.3/web/app_dev.php
You have also documents about upgrading from previous versions (deprecations etc) called UPGRADE-X.X.md

I'm getting fatal error after including SonataMediaBundle's form templates

I've configured SonataMediaBundle, added relation to Media in my Entity. Admin for entity works fine until I add this snippet from docs:
twig:
form:
resources:
# other files
- 'SonataMediaBundle:Form:media_widgets.html.twig'
After that all I get is this error:
FatalErrorException: Compile Error: Cannot inherit previously-inherited or override constant MARKER from interface Doctrine\Common\Persistence\Proxy
What I'm doing wrong? How to make sonata_media_type work with its widget template?
googling for somedays for a similar error I came up with the conclusion that is has nothing to do with your code, but is some kind of strange bug in environment, more likely in APC.
Check this post if you are using amazon server: https://forums.aws.amazon.com/message.jspa?messageID=508800
After I did that upgrade the problem solved. I'm still waiting to see if it comes out again, because it was not a permanet error, and after each apache reload/restart it went away for a while...
Other op-caches may solve the problem without loosing performance.

Drupal - White Screen of Death after updates (and login page returning 403 error)

I have just updated a site that is using Drupal and have now experienced the horrible WSOD.
I have searched through Google looking for any sort of solution/error log to help me find and fix the issue but nothing has worked. I have tried adding in the 'display errors' code in the index.php file and looked at the error_log file in the public directory and nothing.
I can not login to the admin page and check any modules as the login page for this is returning a 403 error.
Any suggestions?
Please go to Apache Error log. You will exact error messages there.
The log file's location is different for different OS and versions.
e.g httpd/log/error.log
Maybe your Drupal registry is broken.
Fix this using the registry_rebuild script (this is no module!)
There are times in Drupal 7 when the registry gets hopelessly hosed and you need to rebuild the registry (a list of PHP classes and the files they go with). Sometimes, though, you can't do this regular cache-clear activity because some class is required when the system is trying to bootstrap.
You might get something like:
PHP Fatal error: Class 'EntityAPIControllerExportable' not found in ...sites/all/modules/rules/includes/rules.core.inc on line 11
If this happens when you're trying to run update.php, and happens when you're trying to clear your cache, well, you have some trouble. That's what Registry Rebuild is for.
It also may happen that you've moved some module that Drupal requires to bootstrap, and you get a horrible error. Registry Rebuild will also rebuild the system table to get the modules in the right place so you can bootstrap.
You will need PHP-CLI or drush to run this.
https://drupal.org/project/registry_rebuild

Resources