Open dusekdan opened 6 years ago
I'm having the same problem with an endless loop of destructors with HtmlDomParser
from WordPress on PHP 7.1.13. The workaround I found was to manually call ->clear()
on the DOM element before returning from a function:
function modify_content($content) {
$dom = HtmlDomParser::str_get_html($content);
// ...
// Add the line below
$dom->clear();
return $content;
}
When I use your library together with Laravel and take advantage of Laravel's possibility to start local development server using command
php artisan serve
I run into an issue where Laravel server gets stuck in an endless loop of calls tosimple_html_dom_node->__destruct()
. After maximum execution time is exceeded, Laravel server calls:I debugged the issue for a while but could not resolve it by any other way than to delete/rename/comment-out your destructors in mentioned class.
Minimum, Complete and Verifiable example/Steps to reproduce:
composer create-project --prefer-dist laravel/laravel blog
cd blog
and update composer.json with required dependency to your library"sunra/php-simple-html-dom-parser": "^1.5"
composer update
to fetch newly added dependency.Open file
routes/web.php
and update its contents to contain following(1) Note that
<!-- YOUR NON-TRIVIAL HTML MARKUP HERE -->
should really be replaced with non-trivial markup, e.g. google.com's source from front-page.php artisan serve
and access used address (it defaults to 127.0.0.1:8000)(2) Note I was not able to reproduce it using on PHPv7.1.14 or PHPv7.1, but PHPv7.1.13, PHPv7.1.18 and even PHPv7.2 do suffer from this behavior.
I worked-around this issue by setting up composer script on
post-autoload-dump
event where I search and destroy (rename) your destructors.