3

I am getting these errors in system.log.

2017-06-20T11:59:55+00:00 ERR (3): Warning: simplexml_load_string(): Entity: line 1: parser error : Start tag expected, '<' not found  in home/www/lib/Varien/Simplexml/Config.php on line 512
2017-06-20T11:59:55+00:00 ERR (3): Warning: simplexml_load_string():   in /home/www/lib/Varien/Simplexml/Config.php on line 512
2017-06-20T11:59:55+00:00 ERR (3): Warning: simplexml_load_string(): ^  in /home/www/lib/Varien/Simplexml/Config.php on line 512

I tried debugging them by adjusting the loadstring function in the config.php file:

public function loadString($string)
{
if (is_string($string)) {
    $xml = simplexml_load_string($string, $this->_elementClass);
    if(!$xml){
        Mage::log('XML_ERROR: ' . $string);
    }
    if ($xml instanceof Varien_Simplexml_Element) {
        $this->_xml = $xml;
        return true;
    }
} else {
    Mage::logException(new Exception('"$string" parameter for simplexml_load_string is not a string'));
}
return false;
}

The response in the system.log is not pointing to any logic location or file. How to debug this:

2017-06-20T11:59:56+00:00 DEBUG (7): XML_ERROR: ’°#  .   ½; ô..                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          
2017-06-20T11:59:57+00:00 DEBUG (7): XML_ERROR: <config/>

Changed the error login as sugested in the comments. This is what the response is now:

2017-06-20T12:43:51+00:00 ERR (3): Notice: Undefined variable: classblock  in /home/www/app/code/local/Cmsmart/Megamenu/Block/Navigation.php on line 186
2017-06-20T12:43:51+00:00 ERR (3): Notice: Undefined variable: nothumbnail  in /home/www/app/code/local/Cmsmart/Megamenu/Block/Navigation.php on line 84
2017-06-20T12:43:51+00:00 ERR (3): Notice: Undefined variable: classblock  in /home/www/app/code/local/Cmsmart/Megamenu/Block/Navigation.php on line 186
2017-06-20T12:43:51+00:00 DEBUG (7): LibXMLError Object
(
[level] => 3
[code] => 4
[column] => 1
[message] => Start tag expected, '<' not found

[file] => 
[line] => 1
)

2017-06-20T12:43:53+00:00 DEBUG (7): LibXMLError Object
(
[level] => 3
[code] => 4
[column] => 1
[message] => Start tag expected, '<' not found

[file] => 
[line] => 1
)

Got this error:

2017-06-20T14:19:51+00:00 DEBUG (7): LibXMLError Object
(
[level] => 3
[code] => 4
[column] => 1
[message] => Start tag expected, '<' not found

[file] => ./app/design/frontend/default/theme313k/layout/cmsmart
[line] => 1
)

This is the corresponding file contents. I don't see anything wrong with that file. Also tried to remove whitespaces etc.

<?xml version="1.0"?>
<layout version="0.1.0">
<default>
    <reference name="top.menu" >
          <action  method="unsetChild" ><name>catalog.topnav</name>     </action>
          <block type="page/html_topmenu" name="catalog.topnav2" template="page/html/topmenu_2.phtml"/>
           <block type="megamenu/navigation"  name="catalog.topnav.megamenu">
              <action method="unsetData"><key>cache_lifetime</key></action>
              <action method="unsetData"><key>cache_tags</key></action>
           </block>
    </reference>

</default>
</layout>
  • If you try opening each XML file your extension requests (and it's configuration) in notepad, or less, do you have any weird characters at the beginning of the file? Might be an encoding issue? – Douglas Radburn Jun 20 '17 at 13:11
5

Please check your config.xml, system.xml and all the layout.xml files.

For debugging you can try this ... create file in magento root

<?php
require_once('./app/Mage.php');
umask(0);
Mage::app();

// enable user error handling
libxml_use_internal_errors(true);

// adjust template path
$dir = "./app/design/frontend/base/default/layout/*";

foreach(glob($dir) as $file) {
    $xml = simplexml_load_file($file);
    foreach (libxml_get_errors() as $error) {
        Mage::log($error);
    }
    libxml_clear_errors();
}

Output looks like

2017-06-20T13:28:21+00:00 DEBUG (7): Array
(
    [0] => ./app/design/frontend/base/default/layout/catalog.xml
    [1] => LibXMLError Object
        (
            [level] => 3
            [code] => 76
            [column] => 28
            [message] => Opening and ending tag mismatch: reference line 191 and catalog_product_view

            [file] => ./app/design/frontend/base/default/layout/catalog.xml
            [line] => 262
        )

)

Source: http://www.php.net/manual/en/function.libxml-use-internal-errors.php


Edit: check all XML files ...

<?php
require_once('./app/Mage.php');
umask(0);
Mage::app();

// enable user error handling
libxml_use_internal_errors(true);

$root = './app';
$iterator  = new RecursiveIteratorIterator(
    new RecursiveDirectoryIterator($root, RecursiveDirectoryIterator::SKIP_DOTS),
    RecursiveIteratorIterator::SELF_FIRST,
    RecursiveIteratorIterator::CATCH_GET_CHILD
);

foreach ($iterator as $path => $item) {
    if ($item->isFile() && $item->getExtension() == 'xml') {
        $xml = simplexml_load_file($path);
        foreach (libxml_get_errors() as $error) {
            Mage::log($error);
        }
        libxml_clear_errors();
    }
}
  • I added the output from system.log to the question. Shouldn't this be pointing to an XML files? – matthijshofstede Jun 20 '17 at 12:50
  • Updated answer. – sv3n Jun 20 '17 at 13:46
  • Let me check this: 1.) Create a file with the code above and upload it to Magento root, change template path? 2.) Run file in browser 3.) Check errors in system.log? – matthijshofstede Jun 20 '17 at 14:09
  • Yep ... set $dir to the template you use. – sv3n Jun 20 '17 at 14:11
  • 1
    Statusupdate: We noticed a heavy brute force atack when these problems started. Causing problems on the server (to many connections, also apache was not able to close all of the processes). I am not sure but somehow this generated the xml error. Blocking all traffic from external IP's actually made the error go away so I think it should be related to loads off traffic. We will be monitoring for a couple off days to see if this is the case. – matthijshofstede Jun 22 '17 at 10:59
2

Solved, we traced down the XML error back to some issues with the server. The server was being hit by a large scale brute force atack. Somehow XML errors with some strange special characters are generated when the server can not handle the load (seems like Apache had problems closing all child processes).

Steps to diagnose and solve the problem

  • Stopped all external traffic by blocking every IP address except our own with .htaccess. After a couple off minutes the site worked as expected, no more error where generated.
  • Installed Free Watchlog extension and register all login attempts. We noticed 120K attempts the last couple off days.
  • Blocked all IP adresses that attempted to log in. We used an third party extension.
  • Don't forget to allow external traffic via the .htaccess file again.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.