Notice: Undefined property: DOMDocument::$documentElement
Asked Answered
R

9

5

I recently re-opened an old (1 year) Symfony project and I am having an error on every page (I don't remember having this issue a year ago) :

[exception] 500 | Internal Server Error | Symfony\Component\Config\Exception\FileLoaderLoadException
/var/www/[...]/wdt.xml

ContextErrorException: Notice: Undefined property: DOMDocument::$documentElement

If I clear the cache, the error disappear but as soon as I edit and save a file, the error is showing up again. The project was using Symfony 2.8 and I updated to Symfony 3.2 but it didn't solve the issue.

I don't think the problem is related to the wdt.xml file and I think it might be related to my laptop config.

I don't really know where to start to investigate so any suggestion is welcome!

Edit 1 :
I am actually having the same problem with another project I created few days ago. The project don't use any additional bundles and I just created 5 entities and generated the MySQL database.

Edit 2 :
After some more researched, I decided to create a new Ubuntu VM and test a new Symfony project and it just work perfectly so it must be something to do with the configuration on my laptop.

Edit 3 :
After some more tests, here is what I get when I add a print_r($dom); in the file XmlUtils.php (vendor/symfony/symfony/src/Symfony/Component/Config/Util/XmlUtils.php) line 59 :

Ubuntu VM (no error) :

DOMDocument Object ( [doctype] => [implementation] => (object value omitted) [documentElement] => (object value omitted) [actualEncoding] => [encoding] => [xmlEncoding] => [standalone] => 1 [xmlStandalone] => 1 [version] => 1.0 [xmlVersion] => 1.0 [strictErrorChecking] => 1 [documentURI] => /var/www/my_project/web/ [config] => [formatOutput] => [validateOnParse] => 1 [resolveExternals] => [preserveWhiteSpace] => 1 [recover] => [substituteEntities] => [nodeName] => #document [nodeValue] => [nodeType] => 9 [parentNode] => [childNodes] => (object value omitted) [firstChild] => (object value omitted) [lastChild] => (object value omitted) [previousSibling] => [attributes] => [ownerDocument] => [namespaceURI] => [prefix] => [localName] => [baseURI] => /var/www/my_project/web/ [textContent] => %kernel.charset% %kernel.default_locale% )

Ubuntu laptop (error) :

DOMDocument Object ( [validateOnParse] => 1 [nodeName] => #document [nodeValue] => [nodeType] => 9 [parentNode] => [childNodes] => (object value omitted) [firstChild] => (object value omitted) [lastChild] => (object value omitted) [previousSibling] => [attributes] => [ownerDocument] => [namespaceURI] => [prefix] => [localName] => [baseURI] => /var/www/lab/symfony/booklib/web/ [textContent] => %kernel.charset% %kernel.default_locale% )

It looks like there is some missing information on my laptop...

So basically, the function $dom->loadXML doesn't return the same value on my laptop environment and inside the VM... any idea why?

Recurve answered 14/3, 2017 at 11:42 Comment(0)
K
7

I have Ubuntu 16.04 installation with php7.0.15, and i fixed the error by just removing php-xdebug extension.

sudo apt-get purge php-xdebug

Krug answered 18/4, 2017 at 11:53 Comment(2)
phpdismod xdebug && service php7.1-fpm restart and error gone for me. wery strange...Dowery
purging xdebug fixed it for me, tooVidal
S
4

In my case the error was triggered by the dom.so extension being loaded in two places. Removing one fixed the problem.

Steady answered 5/6, 2018 at 9:45 Comment(2)
Thanks, this solution was for me the bestDiscouragement
where to find dom.so in host cpanel????Spahi
R
2

I finally resolved the problem by uninstalling / reinstalling php7. I have no idea why I had this issue though...

Recurve answered 15/3, 2017 at 19:50 Comment(0)
D
2

In my case the dom extension was enabled twice. Once in the dom.ini and also in the php.ini. I removed the extension=dom.so entry from the php.ini and reloaded the apache2 webserver.

Douville answered 21/8, 2019 at 11:7 Comment(0)
P
2

This might be relevant: https://getcomposer.org/doc/articles/troubleshooting.md#xdebug-impact-on-composer

TLDR: Use COMPOSER_ALLOW_XDEBUG=1 if you are using xdebug with composer.

Pretty answered 26/3, 2020 at 11:5 Comment(0)
D
1

This is very strange BUT try to change php extensions load order in php config. This solve my problem... move dom extension above or below in list

Dowery answered 2/5, 2017 at 12:2 Comment(1)
For me similar solution has worked - I had dom extension in 2 places. I removed it from one and then it started working. 2nd one was probably ignored so extension order was most probably the problem.Anson
S
0

Hi I also meet this problem. The way I resolve it is:

composer update

Hope that help some one.

Selfdevotion answered 15/3, 2017 at 15:33 Comment(3)
Hi, It didn't solve my problem because it's not related to Symfony (I've done another test outside Symfony and I have the exact same error).Recurve
Yes, It does. I already debug. At the beginning I thought because XML binary lib but It is not. When I update and it fixed my issue.Selfdevotion
I had the same problem outside Symfony but maybe your issue was actually a different one. I tried the composer update solution but didn't work for me.Recurve
V
0

Thank @pjehan. I had the same problem and I've lost a day. Finally, I did like you and it was successful. Just specify one thing: unistall PHP 7.0.x and PHP 7.1.3 intaller (stable version for PHP 7). The link of the version PHP 7 stable: http://php.net/downloads.php Thank you so much, @pjehan, you saved my life :D

Villalobos answered 16/3, 2017 at 18:14 Comment(1)
You're welcome, I wish I could have found the exact problem and another way than just uninstall and reinstall but after spending 6 hours trying to find a solution, I just gave up and choose the easiest way to solve this problem. I am glad it helped you thought 😉Recurve
R
0

I solved the problem by disabling xdebug for the cli

Routh answered 17/11, 2017 at 13:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.