Debugging error messages in Shopware

On this page you will find some useful information that will help you understand error messages and determine the cause.

How do I find the error message?

Errors can occur in many places for a variety of reasons, but sometimes they can not be found in the log file. So how do you find out where the error is caused?

If a serious error has occurred, first remember when the error occurred! Then see what steps you can take to reproduce the error and consider whether the error could come from Shopware itself or a plugin. Then you search for the message.

Frontend Error Reporter

The Frontend Error Reporter is a possibility to display serious errors directly in the frontend instead of the "An error has occurred" page. Since the template displays the messages directly and thus also displays them to your customers, the use is only recommended if there is little traffic on the shop or you are working in a development environment. How to activate this advanced error debugging is explained under Enhanced Error Debugging.

Log Files

Because the error reporter is disabled by default, the error messages will be written in a logfile on your server which you can find in /var/log/, for example core_production-2016-02-01.log. Depending on the environment you use (production, development) or from where the message comes (core, plugin) the file might be named different. Note that the file will be created for each day on which an error happens. When your error comes from a plugin, the logfile should be named "plugin_production-DATE.log", if it came out of shopware itself, the file should be named "core_production-DATUM.log". Just open the file from the date you search for and take a look for the exact timestamp, when your error happened. Here you should see an error message which describes the problem. How to read error messages we'll explain later in this article.

System-Log im Backend

Since the Shopware version 5.2.13 you can also see the messages of the system log in backend. You will find the new tab called "System log" (1) at Configuration > Logfile. Clicking on the magnifying glass (2) gives detailed information about the individual messages. In the "File" area (3) you can switch between the individual log files and also download log files, if you want to forward them, for example.

Sending errors via email

In the basic settings in System > Log you have the possibility to let shopware send you all the error messages.

How to read error messages?

In this passage we'll show you how to read error messages and how to extract the reason for the error.

AreaNotes for analysis
Stack traceHere you can find informations of the most recently accessed functions. So you can find out at what point a function is called, which led to the error. Also plug-in names are often listed. This plugin should be the first place to start when you go into the error analysis.
TimeThis information provides the option to further localize whether the error happens regulary or occur at regularly scheduled operations to this behavior.
uriHere, the referring URL will be displayed. With a manual call to the URL, you can test, for example, whether "only" the call of a no (longer) existent URL, for example, by a bot, the error has caused. Otherwise, the place of occurrence can be determined in detail.
queryProvides further informations whether the error happened in the frontend / backend , which controller has been addressed, etc.
shopId / shopNameIf language- and / or subshops are used, you can see in which shop the error occurred.

PHP error messages

At PHP errors, you'll not see your shop, instead you see a blank error message in your browser like the default 503 or 500 error message or a blank white site. Debugging PHP errors is a bit more different than the others. To know, whats going wrong, you have 2 possibilities:

  • Take a look into your servers error log folder, where it stores the php errors. The servers error log is not always stored at the same location, so ask your hoster where you can find that. If the error log provides not all messages you can ask your Hoster to increase the log-level, so that more errors will be logged.
  • If you know, what you're doing, you can also jump to the considering function in the code, where the error occurs and insert a "die" with an error output to see, whats happening, But don't forget to reset the file to it's default after debugging!

Template errors

Template errors appear according to the error in the error reporter in the frontend or in the logfile and will look like this:


[2016-02-22 09:43:20] core.ERROR: exception 'SmartyException' with message 'Unable to load template snippet 'frontend/index/headers.tpl' in 'frontend/error/index.tpl|frontend/plugins/seo/index.tpl'' in /home/shopware/www/sw513/engine/Library/Smarty/sysplugins/smarty_internal_templatebase.php:127 
Stack trace: 
#0 /home/shopware/www/sw513/engine/Library/Smarty/sysplugins/smarty_internal_template.php(286): Smarty_Internal_TemplateBase->fetch(NULL, NULL, NULL, NULL, false, false, true) 
#1 /home/shopware/www/sw513/var/cache/production_201602150844/templates/frontend_Responsive_de_DE_1/46/99/47/469947a92e6ed4db0e2e8a7b3c45ebd31eaf531b.snippet.index.tpl.php(170): Smarty_Internal_Template->getSubTemplate('frontend/index/...', NULL, 'frontend_Respon...', NULL, NULL, Array, 0) 
#2 /home/shopware/www/sw513/engine/Library/Smarty/sysplugins/smarty_internal_templatebase.php(180): content_56caca285e1fa9_34792271(Object(Enlight_Template_Default)) 
#3 /home/shopware/www/sw513/engine/Library/Enlight/View/Default.php(274): Smarty_Internal_TemplateBase->fetch() 
#4 /home/shopware/www/sw513/engine/Library/Enlight/Controller/Plugins/ViewRenderer/Bootstrap.php(216): Enlight_View_Default->render(Object(Enlight_Template_Default)) 
#5 /home/shopware/www/sw513/engine/Library/Enlight/Controller/Plugins/ViewRenderer/Bootstrap.php(242): Enlight_Controller_Plugins_ViewRenderer_Bootstrap->renderTemplate(Object(Enlight_Template_Default)) 
#6 /home/shopware/www/sw513/engine/Library/Enlight/Controller/Plugins/ViewRenderer/Bootstrap.php(136): Enlight_Controller_Plugins_ViewRenderer_Bootstrap->render() 
#7 [internal function]: Enlight_Controller_Plugins_ViewRenderer_Bootstrap->onPostDispatch(Object(Enlight_Controller_ActionEventArgs)) 
#8 /home/shopware/www/sw513/engine/Library/Enlight/Event/Handler/Default.php(91): call_user_func(Array, Object(Enlight_Controller_ActionEventArgs)) 
#9 /home/shopware/www/sw513/engine/Library/Enlight/Event/EventManager.php(210): Enlight_Event_Handler_Default->execute(Object(Enlight_Controller_ActionEventArgs)) 
#10 /home/shopware/www/sw513/engine/Library/Enlight/Controller/Action.php(201): Enlight_Event_EventManager->notify('Enlight_Control...', Object(Enlight_Controller_ActionEventArgs)) 
#11 /home/shopware/www/sw513/engine/Library/Enlight/Controller/Dispatcher/Default.php(523): Enlight_Controller_Action->dispatch('genericErrorAct...') 
#12 /home/shopware/www/sw513/engine/Library/Enlight/Controller/Front.php(226): Enlight_Controller_Dispatcher_Default->dispatch(Object(Enlight_Controller_Request_RequestHttp), Object(Enlight_Controller_Response_ResponseHttp)) 
#13 /home/shopware/www/sw513/engine/Shopware/Kernel.php(153): Enlight_Controller_Front->dispatch() 
#14 /home/shopware/www/sw513/vendor/symfony/http-kernel/HttpCache/HttpCache.php(492): Shopware\Kernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) 
#15 /home/shopware/www/sw513/engine/Shopware/Components/HttpCache/AppCache.php(255): Symfony\Component\HttpKernel\HttpCache\HttpCache->forward(Object(Symfony\Component\HttpFoundation\Request), true, NULL) 
#16 /home/shopware/www/sw513/vendor/symfony/http-kernel/HttpCache/HttpCache.php(449): Shopware\Components\HttpCache\AppCache->forward(Object(Symfony\Component\HttpFoundation\Request), true) 
#17 /home/shopware/www/sw513/vendor/symfony/http-kernel/HttpCache/HttpCache.php(349): Symfony\Component\HttpKernel\HttpCache\HttpCache->fetch(Object(Symfony\Component\HttpFoundation\Request), true) 
#18 /home/shopware/www/sw513/engine/Shopware/Components/HttpCache/AppCache.php(178): Symfony\Component\HttpKernel\HttpCache\HttpCache->lookup(Object(Symfony\Component\HttpFoundation\Request), true) 
#19 /home/shopware/www/sw513/vendor/symfony/http-kernel/HttpCache/HttpCache.php(213): Shopware\Components\HttpCache\AppCache->lookup(Object(Symfony\Component\HttpFoundation\Request), true) 
#20 /home/shopware/www/sw513/engine/Shopware/Components/HttpCache/AppCache.php(114): Symfony\Component\HttpKernel\HttpCache\HttpCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) 
#21 /home/shopware/www/sw513/shopware.php(101): Shopware\Components\HttpCache\AppCache->handle(Object(Symfony\Component\HttpFoundation\Request)) 
#22 {main} [] {"uid":"51a7455"}

The message says, that a template snippet could not be loaded. In 'frontend/index' the template tried to call 'frontend/index/headers.tpl' which is not existent or has insufficient permissions. So the first step is to look in the path to make sure, that the file is existent and owns the needed permissions. If the file is not existent, you have 2 possibilities: Is the file missing? or Will the wrong file be called? You can find out that by searching all files under '/frontend/index' for this call (in our example 'frontend/index/index.tpl') and compare this file with the same file from the default responsive theme. If the default theme calls the same file, you have this file missing. If the default theme calls another file, you did a mistake and called a wrong file. In our example we missspelled headers.tpl because it must be named header.tpl. You have to change this and save your file, after saving you should not get this error again.

MySQL errors

MySQL errors can appear at multiple actions and cause multiple reasons. For example: 2 backend users do the exact same action in the backend to the exact same time e.g. saving an item or a setting. This can cause for example the following error:


exception 'PDOException' with message 'SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '185-38' for key 'PRIMARY'' in /var/www/vhosts/domain.de/swverzeichnis/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php:987

Duplicate entry '185-38' in means that you try to save something, which already exists. This can be a setting or a value, according to what you currently do. As a possible solution you can try it another time or take a look in the database and delete the value which occurs the error.

If you make changes on the database, backup your environment first! Changing the database can cause in errors, so do your changes only if you know what you're doing!

Known error messages and their cause

In this section you will find error messages that are known to us from support requests and the community. There are also possible solutions and causes.

Common or "Oops! An error has occured"

"Oops! An error has occured" is the default error page in the frontend, when a so called "503 - Service unavailable" error occurs. This is a script error, which can be caused by many reasons. In many cases, this are plugins or inconsistent data in your database. In this case it's neccessary to turn on the error debugging.

The provided X-CSRF-Token is invalid


exception 'Shopware\Components\CSRFTokenValidationException' with message 'The provided X-CSRF-Token is invalid. Please go back, reload the page and try again.' in /var/www/vhosts/domain.com/httpdocs/shopware/engine/Shopware/Components/CSRFTokenValidator.php:151
Stack trace:
#0 [internal function]: Shopware\Components\CSRFTokenValidator->checkFrontendTokenValidation(Object(Enlight_Controller_ActionEventArgs))
#1 /var/www/vhosts/domain.com/httpdocs/shopware/engine/Library/Enlight/Event/Handler/Default.php(91): call_user_func(Array, Object(Enlight_Controller_ActionEventArgs))
#2 /var/www/vhosts/domain.com/httpdocs/shopware/engine/Library/Enlight/Event/EventManager.php(214): Enlight_Event_Handler_Default->execute(Object(Enlight_Controller_ActionEventArgs))
#3 /var/www/vhosts/domain.com/httpdocs/shopware/engine/Library/Enlight/Controller/Action.php(143): Enlight_Event_EventManager->notify('Enlight_Control...', Object(Enlight_Controller_ActionEventArgs))
#4 /var/www/vhosts/domain.com/httpdocs/shopware/engine/Library/Enlight/Controller/Dispatcher/Default.php(523): Enlight_Controller_Action->dispatch('indexAction')
#5 /var/www/vhosts/domain.com/httpdocs/shopware/engine/Library/Enlight/Controller/Front.php(226): Enlight_Controller_Dispatcher_Default->dispatch(Object(Enlight_Controller_Request_RequestHttp), Object(Enlight_Controller_Response_ResponseHttp))
#6 /var/www/vhosts/domain.com/httpdocs/shopware/engine/Shopware/Kernel.php(176): Enlight_Controller_Front->dispatch()
#7 /var/www/vhosts/domain.com/httpdocs/shopware/vendor/symfony/http-kernel/HttpCache/HttpCache.php(487): Shopware\Kernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#8 /var/www/vhosts/domain.com/httpdocs/shopware/engine/Shopware/Components/HttpCache/AppCache.php(255): Symfony\Component\HttpKernel\HttpCache\HttpCache->forward(Object(Symfony\Component\HttpFoundation\Request), true, NULL)
#9 /var/www/vhosts/domain.com/httpdocs/shopware/vendor/symfony/http-kernel/HttpCache/HttpCache.php(258): Shopware\Components\HttpCache\AppCache->forward(Object(Symfony\Component\HttpFoundation\Request), true)
#10 /var/www/vhosts/domain.com/httpdocs/shopware/vendor/symfony/http-kernel/HttpCache/HttpCache.php(275): Symfony\Component\HttpKernel\HttpCache\HttpCache->pass(Object(Symfony\Component\HttpFoundation\Request), true)
#11 /var/www/vhosts/domain.com/httpdocs/shopware/engine/Shopware/Components/HttpCache/AppCache.php(133): Symfony\Component\HttpKernel\HttpCache\HttpCache->invalidate(Object(Symfony\Component\HttpFoundation\Request), true)
#12 /var/www/vhosts/domain.com/httpdocs/shopware/vendor/symfony/http-kernel/HttpCache/HttpCache.php(206): Shopware\Components\HttpCache\AppCache->invalidate(Object(Symfony\Component\HttpFoundation\Request), true)
#13 /var/www/vhosts/domain.com/httpdocs/shopware/engine/Shopware/Components/HttpCache/AppCache.php(114): Symfony\Component\HttpKernel\HttpCache\HttpCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#14 /var/www/vhosts/domain.com/httpdocs/shopware/shopware.php(101): Shopware\Components\HttpCache\AppCache->handle(Object(Symfony\Component\HttpFoundation\Request))
#15 {main}

What does it mean?

Since Shopware 5.2.0 we use the so called X-CSRF-Token (cross sight request forgery). Using this token, we try to prevent actions, that are not done deliberately by the customer. When processing actions or exchanging data, we compare this token. Was the token not generated correctly or the token doesnt't match, the error message occurs. In many cases it's hard to find the reason for the invalid token, because you need a reproducable workflow, where you can provoke the error, only using a reproducable workflow you can prove, that the error is really gone and not caused by coincidence. It also might happen, that the CSRF token is the cause, but not the error message, so we recommend to check the following things at debugging:

  • Individual theme: Check if you also get the error message in the default responsive theme. Changes at data exchange points may cause invalid tokens.
  • Plugins: Deactivate all Plugins and try to reproduce the error. If it's not reproduceable activate all plugins step by step. If the error appears after activating a plugin, mostly the plugin causes the problem.
  • Updates: It's recommended to use the latest shopware version because we improve this security feature continously.

Deactivating the X-CSRF-Token

When you're not able to find the errors cause, you can deactivate the whole feature temporarilly. In some cases other error messages are hidden by the CSRF error message, so you can debug them after you know them. Deactivating this feature does not mean, that your shop is vulnerable. Shopware has security functions, which are working even then, but for security reasons you should solve the problem to reactivate the csrf protection. To deactivate the csrf protection you find the code snippet here.

Integrity constraint violation

What does it mean?

SQL error messages can be caused by inconsistent or broken database records, caused by broken Foreign Keys or duplicate entries.

What can I do to solve it?

Try to repair the foreign keys in your database. Our foreign key reparation tutorial should help you. This fixes the realtions between the different Shopware core tables - but keep in mind, that plugin tables will not be repaired. You should also check duplicate entries in the mentioned table and delete them.

Order list cannot be opened


Oops! An error occured! The following notes should help you.  in vendor/doctrine/orm/lib/Doctrine/ORM/AbstractQuery.php on line 781 Stack trace: 
#0 engine/Shopware/Controllers/Backend/Order.php(1038): Doctrine\ORM\AbstractQuery->getOneOrNullResult(2) 
#1 var/cache/production_201704210836/proxies/ShopwareControllersBackendOrderProxy.php(6): Shopware_Controllers_Backend_Order->getList(NULL, Array, '0', '20') 
#2 engine/Library/Enlight/Hook/HookManager.php(186): Shopware_Proxies_ShopwareControllersBackendOrderProxy->executeParent('getList', Array) 
#3 var/cache/production_201704210836/proxies/ShopwareControllersBackendOrderProxy.php(38): Enlight_Hook_HookManager->executeHooks(Object(Shopware_Proxies_ShopwareControllersBackendOrderProxy), 'getList', Object(Enlight_Hook_HookArgs)) 
#4 engine/Shopware/Controllers/Backend/Order.php(271): Shopware_Proxies_ShopwareControllersBackendOrderProxy->getList(NULL, NULL, '0', '20') 
#5 engine/Library/Enlight/Controller/Action.php(159): Shopware_Controllers_Backend_Order->getListAction() 
#6 engine/Library/Enlight/Controller/Dispatcher/Default.php(523): Enlight_Controller_Action->dispatch('getListAction') 
#7 engine/Library/Enlight/Controller/Front.php(223): Enlight_Controller_Dispatcher_Default->dispatch(Object(Enlight_Controller_Request_RequestHttp), Object(Enlight_Controller_Response_ResponseHttp)) 
#8 engine/Shopware/Kernel.php(182): Enlight_Controller_Front->dispatch() 
#9 vendor/symfony/http-kernel/HttpCache/HttpCache.php(491): Shopware\Kernel->handle(Object(Enlight_Controller_Request_RequestHttp), 1, true) 
#10 engine/Shopware/Components/HttpCache/AppCache.php(266): Symfony\Component\HttpKernel\HttpCache\HttpCache->forward(Object(Symfony\Component\HttpFoundation\Request), true, NULL) 
#11 vendor/symfony/http-kernel/HttpCache/HttpCache.php(258): Shopware\Components\HttpCache\AppCache->forward(Object(Symfony\Component\HttpFoundation\Request), true) 
#12 engine/Shopware/Components/HttpCache/AppCache.php(103): Symfony\Component\HttpKernel\HttpCache\HttpCache->pass(Object(Symfony\Component\HttpFoundation\Request), true) 
#13 shopware.php(117): Shopware\Components\HttpCache\AppCache->handle(Object(Symfony\Component\HttpFoundation\Request)) #14 {main}  

The error message

In most cases it's caused by duplicate order numbers - Shopware doesn't allow duplicate order numbers and by default and Shopware will never generate duplicate order numbers. Interfaces to your ERP or plugins can leverate this logic, in that case you should contact the vendor of the interface.

The solution

You can use our example script to find orders with duplicate order numbers.

Shopping worlds module cannot be opened

The error message

Open the developer tools in google chrome and open the shopping world module. Under "Network" you should find the XHR Request (Emotion?=XXXX). Go to preview and check, if there is the following code in the last line:


Mac OS X        	2��ATTR��?�?com.apple.quarantineq/0001;58b7f6ba;Cyberduck;AB2E36E7-4E18-42DB-9968-B85541426179

Reason / how to fix it

A not signed ftp client app on your Mac could be the reason. The os added the line to all files that was uploaded, because the app is in quarantine. Try to reupload the files with another signed program.

Error when saving the article: undefined

The meaning

When you get the error message "undefined" when saving an article in backend, there is probably a problem with invalidating the cache over the reverse proxy. You will see the following message in your server error log:


Fatal error:  Call to a member function getId() on null in 
 
/var/www/html/engine/Shopware/Components/DependencyInjection/Bridge/Session.php on line 59

The meaning

First you have to note that this is caused by the server configuration of your hoster. Most of the time it's neccessary to enter the "Alternate proxy URL" in Configuration > Cache/Performance > Settings > HTTP Cache which should be your domain. In some cases you have to enter a different proxy url, so please contact your hoster if you have questions.

Tweaks for the config.php

The config.php is the first configuration to load Shopware during execution. By adding new configuration snippets you can unlock many useful tools that will help you with debugging, among other things. You can view all available configurations in the "Default Config" at Github.

Enhanced error debugging

You activate the Error Reporter in config.php by adding the following lines:


'front' => array(
  'showException' => true,
  'noErrorHandler' => false,
),
 
//Low-Level PHP-Fehler ab Shopware 5.2.0
'phpsettings' => [
    'display_errors' => 1,
]

Your config.php will look something like this:


<?php return array (
  'db' => 
  array (
    'host' => 'HOST',
    'port' => 'PORT',
    'username' => 'USER',
    'password' => 'PASSWORD',
    'dbname' => 'DBNAME',
  ),
  'front' => array(
    'showException' => true,
    'noErrorHandler' => false,
  ),
 
  //Low-Level PHP-Fehler ab Shopware 5.2.0
  'phpsettings' => [
    'display_errors' => 1,
  ]
);

After you have saved the file, the errors are displayed directly in the frontend.

Activating HTTP-Cache Debugging

Sometimes you want to check if the pages you call are really in the cache. Here you can use the following snippet, which activates the Symfony debug cache.


// Http-Cache
'httpCache' => [
    'enabled' => true, // true or false
    'debug' => true,
],

If you now open the developer console of your browser and look at the answer of the initial document request under "Network", you will see the following:


X-Content-Digest:en1dac22cb10b9a66cb6590a7819384d54fcb637e838f65c40b655b07c85cd5f7d
X-Shopware-Allow-Nocache:price-1
X-Shopware-Cache-Id:;c3;
X-Symfony-Cache: GET /: miss, store;
    GET /?action=shopMenu&controller=index&module=widgets: fresh;
    GET /?controller=compare&module=widgets: miss, store;
    GET /?action=menu&controller=index&group=gLeft&module=widgets: miss, store;
    GET /?action=info&controller=checkout&module=widgets: miss, store
  • miss = no Cache files availabe
  • fresh = Controller  / Page liegt iin cache

Deactivate the CSRF-protection

If there are invalid tokens in the frontend, it may be helpful to temporarily disable this function.

Add the following lines of code to config.php:


'csrfProtection' => [
    'frontend' => false,
    'backend' => false
]

Save mails sent from Shopware as a file on the server

If you have problems sending mails, you don't know where to start at first. By activating the Mail-File Config you make sure that all mails are saved as a file.


'mail' => [
    'type' => 'file'
],

Set target path:


'mail' => [
    'type' => 'file',
    'path' => $this->DocPath().'mails'
],

Example configuration for developer

Here we deactivate all caches as well as the template cache. Thus changes are directly visible, without having to configure the theme.

Do not use this configuration in your production system, as it will massively affect performance.


'front' => [
    'showException' => true,
    'throwExceptions' => true,
    'noErrorHandler' => false,
],
 
//Zeige Low-Level PHP-Fehler
'phpsettings' => [
    'display_errors' => 1,
],
 
// Template-Cache
'template' => [
    'forceCompile' => true,
],
 
// Backend-Cache
'cache' => [
    'backend' => 'Black-Hole',
    'backendOptions' => [],
    'frontendOptions' => [
        'write_control' => false
    ],
],
 
// Model-Cache
'model' => [
    'cacheProvider' => 'Array' // supports Apc, Array, Wincache and Xcache
],
 
// Http-Cache
'httpCache' => [
    'enabled' => true, // true or false
    'debug' => true,
],

I need support with finding the reason / solution

Shopware provides many different ways to get help. First of all we offer a qualified support with our commercial version, with an active software subscription we support you in our technical department, where you'll get your answer within your promised reaction time. Our community forum is another way to get help by other users - please keep in mind that there is no gurantee to get an answer. The third way is to consult a Shopware partner which can help you debugging your problem.

Was this article helpful?