php-html-parser icon indicating copy to clipboard operation
php-html-parser copied to clipboard

Object destruction hangs during shutdown

Open Unlink opened this issue 3 years ago • 2 comments

I have some issues with script timeouts using this library.

PHP Version => 7.4.10 paquettg/php-html-parser => 3.1.0

I have basic script:

use PHPHtmlParser\Dom;

$dom = new Dom;
$dom->loadFromUrl('http://www.google.com');
$links = $dom->find("a");
echo "done";

After printing "done" it took around 20 seconds to finish script execution I tried to run it from the console and from the web and the results are the same.

When I load a bigger page, it hangs up. Removing __destruct() from AbstractNode solves this issue, but I'm not sure if it is a good solution.

Unlink avatar Sep 27 '20 17:09 Unlink

Interesting, I guess the destruct of the tree is taking a bit of time for large pages, 20 seconds is a lot. I am thinking of having a configuration option to turn off the destruct functionality, that would help resolve this problem and be backwards compatible.

I wonder why the destruct is so heavy.

paquettg avatar Sep 27 '20 23:09 paquettg

I can confirm this.

steinhaug avatar Nov 02 '20 11:11 steinhaug