Flying Scripts bundles simple_html_dom – conflicts with WebP Express
-
Hello,
I’m running Flying Scripts on a WordPress site (shared hosting, PHP 8.x)
together with the WebP Express plugin. Since installing both, the site’s
php-errors.log is flooded with warnings on every single page load:PHP Warning: Constant HDOM_TYPE_ELEMENT already defined in .../webp-express/vendor/kub-at/php-simple-html-dom-parser/src/KubAT/PhpSimple/lib/simple_html_dom.php on line 26The same warning repeats for every HDOM_* constant (HDOM_TYPE_, HDOM_QUOTE_,
HDOM_INFO_*, etc.), so each request writes roughly 30+ lines. Over the past year
the log grew to ~86 GB (about 218 million warning lines) and is filling the disk
on our shared hosting.Root cause: Flying Scripts bundles its own copy of the simple_html_dom parser
(v1.9.1) in:.../public_html/wp-content/plugins/flying-scripts/lib/dom-parser.phpIt’s wrapped in if(!class_exists(‘simple_html_dom’)), which protects the class,
but the global HDOM_* constants at the top of that block are declared with
unguarded define() calls. WebP Express bundles a second copy of the same parser,
so whichever plugin loads second re-declares the constants and PHP logs the
“already defined” warning. In our case the warnings point to WebP Express’s copy,
but the fix can be done on either side — guarding your defines would resolve it
too, since your copy is loaded first.Suggested fix: guard the define() calls in lib/dom-parser.php, e.g.:
if (!defined('HDOM_TYPE_ELEMENT')) { define('HDOM_TYPE_ELEMENT', 1); // ... }or move the constants into a namespace/class. For comparison, WP Optimize bundles
a namespaced (modern) copy of simplehtmldom and never touches global names, so it
causes no conflicts.Any chance the bundled parser could be updated/patched? This would help a lot of
users on shared hosting with limited disk space.Environment:
- WordPress 6.x, Flying Scripts (latest), WebP Express (latest)
- Shared hosting (CloudWays), PHP 8.x
- php-errors.log written via error_log ini setting in wp-config.php
You must be logged in to reply to this topic.