{"id":1678,"date":"2019-04-08T22:43:09","date_gmt":"2019-04-08T16:43:09","guid":{"rendered":"http:\/\/promincproductions.com\/blog\/?p=1678"},"modified":"2019-04-09T22:10:32","modified_gmt":"2019-04-09T16:10:32","slug":"magento-1-x-supee-11086-bug-magelog-stops-writing-data","status":"publish","type":"post","link":"https:\/\/promincproductions.com\/blog\/magento-1-x-supee-11086-bug-magelog-stops-writing-data\/","title":{"rendered":"Magento 1.x SUPEE-11086 Bug \u2013 Mage::log stops writing data"},"content":{"rendered":"<p>It&#8217;s good to keep your Magento installation up to date with security patches.  But like usual, be ready to catch a bug or two from them&#8230;<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" width=\"944\" height=\"944\" src=\"https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2019\/04\/Magento-SUPEE-11086-Bug.jpg\" alt=\"Mage::log broken with patch SUPEE-11086\" class=\"wp-image-1680\" srcset=\"https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2019\/04\/Magento-SUPEE-11086-Bug.jpg 944w, https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2019\/04\/Magento-SUPEE-11086-Bug-150x150.jpg 150w, https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2019\/04\/Magento-SUPEE-11086-Bug-500x500.jpg 500w, https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2019\/04\/Magento-SUPEE-11086-Bug-768x768.jpg 768w, https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2019\/04\/Magento-SUPEE-11086-Bug-600x600.jpg 600w\" sizes=\"(max-width: 944px) 100vw, 944px\" \/><\/figure>\n\n\n\n<p>With SUPEE-11086 I&#8217;ve so far found that calls to <strong>Mage::log<\/strong> no longer write data to the log files.  They seem to have crippled this function by accident for my installation&#8230;<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Source of the Bug<\/h2>\n\n\n\n<p>In&nbsp;<code>app\/Mage.php<\/code>&nbsp;they made this change:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ Validate file extension before save. Allowed file extensions: log, txt, html, csv\n-        if (!self::helper('log')-&gt;isLogFileExtensionValid($file)) {\n+        $_allowedFileExtensions = explode(\n+            ',',\n+            (string) self::getConfig()-&gt;getNode('dev\/log\/allowedFileExtensions', Mage_Core_Model_Store::DEFAULT_CODE)\n+        );\n+        $logValidator = new Zend_Validate_File_Extension($_allowedFileExtensions);\n+        $logDir = self::getBaseDir('var') . DS . 'log';\n+        if (!$logValidator-&gt;isValid($logDir . DS . $file)) {\n         return;\n    }<\/code><\/pre>\n\n\n\n<p>This change looks to your stores configuration for a list of what file extensions are approved for logging (comma separated).  However this configuration doesn&#8217;t exist&#8230;  It should be in the database (or I believe could be defined in XML).<\/p>\n\n\n\n<p>Magento could\/should have added an option to configure this is the Mage Admin in my mind with this patch.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Solution (let&#8217;s start writing data again!)<\/h2>\n\n\n\n<p>The solve is actually quite simple.  We need to add the configuration to the database and clear the cache.<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Add entry to the database (<code>core_config_data<\/code> table)<ul><li><code>INSERT INTO core_config_data VALUES ( NULL, 'default', 0, 'dev\/log\/allowedFileExtensions', 'log,txt,html,csv' );<\/code><\/li><\/ul><\/li><li>Clear the object cache<ul><li>via the Magento admin or command line<\/li><\/ul><\/li><li>Verify log files are writing again (look at timestamps)<ul><li><code>ls -lrt var\/log\/ | tail <\/code><\/li><\/ul><\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Tested Version<\/h2>\n\n\n\n<p>Magento Enterprise Edition 1.14.2.0 with all security patches applied.<\/p>\n\n\n\n<p>I applied <code>PATCH_SUPEE-11086_EE_1.14.2.4_v1-2019-03-26-03-11-57.sh<\/code> when applying the SUPEE-11086 patch.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Magento&#8217;s Support \/ Response to this Bug<\/h2>\n\n\n\n<p>I have an open ticket with Magento Support.  I&#8217;ll update if\/when I hear a response.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Magento Ignored Existing Code?<\/h2>\n\n\n\n<p>Odd\/sad that Magento didn&#8217;t reuse existing code for validating log file extensions that they added via SUPEE-10415 in late 2017.<\/p>\n\n\n\n<p><code>app\/code\/core\/Mage\/Log\/Helper\/Data.php<\/code><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/**\n * Checking if file extensions is allowed. If passed then return true.\n *\n * @param $file\n * @return bool\n *\/\npublic function isLogFileExtensionValid($file)\n{\n    $result = false;\n    $validatedFileExtension = pathinfo($file, PATHINFO_EXTENSION);\n    if ($validatedFileExtension &amp;&amp; in_array($validatedFileExtension, $this-&gt;_allowedFileExtensions)) {\n        $result = true;\n    }\n\n    return $result;\n}<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Resolution \/ Update<\/h2>\n\n\n\n<p>It turns out this was a case of <strong>user error<\/strong>&#8230;.  (not sure how I could have done that!!!  ha!)  But others may run into this as well and thus I&#8217;m leaving this post active.<\/p>\n\n\n\n<p>I have the main codebase in one git repo.  I have a second git repo for configuration which includes the file <code>app\/etc\/config.xml<\/code> which was part of the patch.  But when I deployed the change this configuration did not get pushed live.  Once I updated the XML file and I removed my added config from the database all still worked as expected (and flushed cache of course).<\/p>","protected":false},"excerpt":{"rendered":"<p>It&#8217;s good to keep your Magento installation up to date with security patches. But like usual, be ready [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":1680,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"wprm-recipe-roundup-name":"","wprm-recipe-roundup-description":"","_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_post_was_ever_published":false},"categories":[46,5],"tags":[],"class_list":["post-1678","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-magento","category-website-development"],"jetpack_featured_media_url":"https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2019\/04\/Magento-SUPEE-11086-Bug.jpg","jetpack_shortlink":"https:\/\/wp.me\/p4BbcR-r4","jetpack_sharing_enabled":true,"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/promincproductions.com\/blog\/wp-json\/wp\/v2\/posts\/1678","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/promincproductions.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/promincproductions.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/promincproductions.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/promincproductions.com\/blog\/wp-json\/wp\/v2\/comments?post=1678"}],"version-history":[{"count":3,"href":"https:\/\/promincproductions.com\/blog\/wp-json\/wp\/v2\/posts\/1678\/revisions"}],"predecessor-version":[{"id":1683,"href":"https:\/\/promincproductions.com\/blog\/wp-json\/wp\/v2\/posts\/1678\/revisions\/1683"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/promincproductions.com\/blog\/wp-json\/wp\/v2\/media\/1680"}],"wp:attachment":[{"href":"https:\/\/promincproductions.com\/blog\/wp-json\/wp\/v2\/media?parent=1678"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/promincproductions.com\/blog\/wp-json\/wp\/v2\/categories?post=1678"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/promincproductions.com\/blog\/wp-json\/wp\/v2\/tags?post=1678"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}