Keeping Magento shops up to date is important to reduce their vulnerability. Sometimes, security updates introduce breaking changes. The recent Magento update, version 18.104.22.168, includes such a breaking change that can cause blank pages on the front-end and back-end. This is caused by the way in which Magento handles symlinks.
When blank pages occur, take a look at Magento’s system.log file. You might find entries like the following:
2017-07-20T20:53:05+00:00 CRIT (2): Not valid template file:frontend/theme/default/template/page/2columns-right.phtml
2017-07-20T20:55:48+00:00 CRIT (2): Not valid template file:adminhtml/default/default/template/mstcore/toolbar.phtml
2017-07-20T20:55:48+00:00 CRIT (2): Not valid template file:adminhtml/default/default/template/magmodules/beslist/notifications.phtml
Some days ago the Magento security update SUPEE-8788 was released. This update fixes a number of critical vulnerabilities. To fix an existing shop one could either apply the SUPEE-patch or upgrade the shop to Magento 1.9.3. However, after updating I experienced a little issue when trying to reach the shop again.
A PHP Exception popped up:
Notice:Undefined index:session_expire_timestamp in/data/web/public/app/code/core/Mage/Core/Model/Session/Abstract/Varien.php on line461
Even after flushing the cache this problem appears. The undefined index and path of the file that raises the exception gives away that this problem might have to with Magento’s session handling. I started with deleting any existing session cookies in my browser. This made the error message disappear. Be aware that this is not an appropriate solution to this error!
Magento now includes CSRF (Cross-Site Request Forgery) protection on publicly available forms such as the new user registration form. The goal of this is to make it impossible for anyone to POST to an URL without first visiting the corresponding form page. A token is supplied on this page that is sent along with the rest of the form to the server. The server validates the correctness of the token and responds in a sensible way if the token is correct. If the token is not however, the server ignores the POST request.
This problem arose after upgrading to Magento 22.214.171.124. which is a patch release that patches a number of security flaws in Magento. After installation of the patch some parts of the front-end template stayed blank. Review of the exception.log file shows a number of exceptions that seem to occur from the template filter classes of Magento.
The error is:
exception'Exception'with message'Notice: Undefined variable: block in /data/web/public/app/code/core/Mage/Core/Model/Email/Template/Filter.php on line 187'in/data/web/public/app/code/core/Mage/Core/functions.php:245
The layout of Magento’s information, warning and error messages cannot be easily changed using layout and template files. The HTML generation is done from a Block PHP class (Mage_Core_Block_Messages). It is a very bad idea to overwrite any core element of Magento. Instead we are going to extend this core-block by creating a separate module.
My goal was to make the messages compliant with Twitter Bootstrap alerts but the following technique can be used for about anything.