Local copy of site won't load. Fatal error: Call to a member function setParent() on a non-object in lib/Varien/Simplexml/Element.php on line 444

magento.stackexchange https://magento.stackexchange.com/questions/97705

Question

I have mirrored an EE 1.14 site to my local server to work on. I've followed my normal procedure for doing so - change base urls, modify local.xml, dump caches and session.

However, when I try to navigate to the site, or even to the magicento eval.php (/home/user_name/public_html/site_new/site/html/var/magicento/eval.php), I get this error:

Fatal error: Call to a member function setParent() on a non-object in /home/user_name/public_html/site_new/site/html/lib/Varien/Simplexml/Element.php on line 444

Looking at the code in that area, I can see that Magento is trying to set the parent on a newly created child :

if (is_null($targetChild)) {
        // if child target is not found create new and descend
        $targetChild = $this->addChild($sourceName);
        $targetChild->setParent($this); //Line 444 which throws error.
        foreach ($source->attributes() as $key=>$value) {
            $targetChild->addAttribute($key, $this->xmlentities($value));
        }
    }

In system.log, I am getting this error :

Warning: SimpleXMLElement::addChild() [simplexmlelement.addchild.html]: Element name is required in /home/user_name/public_html/site_new/site/html/lib/Varien/Simplexml/Element.php on line 443

So I looked back in the extendChild function a bit and added some debugging code :

// name of the source node
        $sourceName = $source->getName(); // Standard Magento call
       //Debug code follows :
        if(!$sourceName){ 
            echo "<pre>";
            echo print_r($source);
            echo "</pre>";
        }

The if(!$sourceName) check gets hit once per load. The output I get from the print_r is this, including the '1' at the end:

Mage_Core_Model_Config_Element Object
(
    [192.168.5.112] => Mage_Core_Model_Config_Element Object
        (
            [~user_name] => Mage_Core_Model_Config_Element Object
                (
                    [site_new] => Mage_Core_Model_Config_Element Object
                        (
                            [site] => Mage_Core_Model_Config_Element Object
                                (
                                    [html] => Mage_Core_Model_Config_Element Object
                                        (
                                        )

                                )

                        )

                )

        )

)
1

I'm at a loss as to why this is happening. I've turned off rewrites, js and css compilation, set ownership to webserver:webserver, and a few different permission configurations (settled on 755/644).

Was it helpful?

Solution

I suspect there can be some syntax error in your XML config files.

Assuming you are running on a *nix OS, try to validate your config.xml files launching the following command from your Magento root:

find . -type f -name 'config.xml' -exec xmllint --noout {} \;

To widen your search you can replace config.xml with *.xml; note that in that case some false negatives may occur (e.g.: while checking wsdl files).

Hope it helps.

OTHER TIPS

Other than an error in a config XML file, it can be an error in core_config_data table. Exact same warning and error messages:

Warning in lib/Varien/Simplexml/Element.php on line 443

Fatal error in lib/Varien/Simplexml/Element.php on line 444

are shown on an instance where someone set by mistake an url in the path field instead of value field, when trying to change the base_url's: enter image description here

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top