• Resolved fredcy

    (@fredcy)


    My PHP error log has many warnings of this form:

    [php:warn] [pid 10891] [client xxx.xxx.2.170:62673] PHP Warning:  Constant HDOM_INFO_OUTER already defined in /srv/www/www/www1/wp-content/plugins/gallery-custom-links/vendor/kub-at/php-simple-html-dom-parser/src/KubAT/PhpSimple/lib/simple_html_dom.php on line 41

    The same kind of warning message appears in a burst for various other constants defined in simple_html_dom.php.

    My site uses another plugin that also vendors in the simple_html_dom.php file. The version in that other plugin is careful to define the constants only if they have not already been defined. But it seems to be loaded first, and so when gallery-custom-links loads those constants are already defined and the warning messages result.

    Perhaps whatever you use that ultimately vendors in that simple_html_dom.php file could be updated to a newer version that won’t redefine those constants if already set? I’ve patched my local copy to do that.

    Gallery Custom Links 2.1.8

    WordPress 6.4.3

    PHP 8.2.16

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support Val Meow

    (@valwa)

    Hey @fredcy! ??

    Thank you for reporting this issue. Indeed, it could occur if another plugin is utilizing the same vendor. We will look into what actions we can take on our end to address it.

    Thread Starter fredcy

    (@fredcy)

    This is still happening in version 2.2.0 of the plugin, causing many spurious output lines in the Apache error log.

    A workable solution, as used by other plugins, is to conditionally define the constants like this:

    defined('HDOM_TYPE_ELEMENT') || define('HDOM_TYPE_ELEMENT', 1);

    Thread Starter fredcy

    (@fredcy)

    diff -r 41f4483514f9 -r a6190364678e wp-content/plugins/gallery-custom-links/vendor/kub-at/php-simple-html-dom-parser/src/KubAT/PhpSimple/lib/simple_html_dom.php
    --- a/wp-content/plugins/gallery-custom-links/vendor/kub-at/php-simple-html-dom-parser/src/KubAT/PhpSimple/lib/simple_html_dom.php Thu Aug 29 14:13:38 2024 -0500
    +++ b/wp-content/plugins/gallery-custom-links/vendor/kub-at/php-simple-html-dom-parser/src/KubAT/PhpSimple/lib/simple_html_dom.php Thu Aug 29 14:45:08 2024 -0500
    @@ -23,29 +23,29 @@
    * Version Rev. 1.9.1 (291)
    */

    -define('HDOM_TYPE_ELEMENT', 1);
    -define('HDOM_TYPE_COMMENT', 2);
    -define('HDOM_TYPE_TEXT', 3);
    -define('HDOM_TYPE_ENDTAG', 4);
    -define('HDOM_TYPE_ROOT', 5);
    -define('HDOM_TYPE_UNKNOWN', 6);
    -define('HDOM_QUOTE_DOUBLE', 0);
    -define('HDOM_QUOTE_SINGLE', 1);
    -define('HDOM_QUOTE_NO', 3);
    -define('HDOM_INFO_BEGIN', 0);
    -define('HDOM_INFO_END', 1);
    -define('HDOM_INFO_QUOTE', 2);
    -define('HDOM_INFO_SPACE', 3);
    -define('HDOM_INFO_TEXT', 4);
    -define('HDOM_INFO_INNER', 5);
    -define('HDOM_INFO_OUTER', 6);
    -define('HDOM_INFO_ENDSPACE', 7);
    +defined('HDOM_TYPE_ELEMENT') || define('HDOM_TYPE_ELEMENT', 1);
    +defined('HDOM_TYPE_COMMENT') || define('HDOM_TYPE_COMMENT', 2);
    +defined('HDOM_TYPE_TEXT') || define('HDOM_TYPE_TEXT', 3);
    +defined('HDOM_TYPE_ENDTAG') || define('HDOM_TYPE_ENDTAG', 4);
    +defined('HDOM_TYPE_ROOT') || define('HDOM_TYPE_ROOT', 5);
    +defined('HDOM_TYPE_UNKNOWN') || define('HDOM_TYPE_UNKNOWN', 6);
    +defined('HDOM_QUOTE_DOUBLE') || define('HDOM_QUOTE_DOUBLE', 0);
    +defined('HDOM_QUOTE_SINGLE') || define('HDOM_QUOTE_SINGLE', 1);
    +defined('HDOM_QUOTE_NO') || define('HDOM_QUOTE_NO', 3);
    +defined('HDOM_INFO_BEGIN') || define('HDOM_INFO_BEGIN', 0);
    +defined('HDOM_INFO_END') || define('HDOM_INFO_END', 1);
    +defined('HDOM_INFO_QUOTE') || define('HDOM_INFO_QUOTE', 2);
    +defined('HDOM_INFO_SPACE') || define('HDOM_INFO_SPACE', 3);
    +defined('HDOM_INFO_TEXT') || define('HDOM_INFO_TEXT', 4);
    +defined('HDOM_INFO_INNER') || define('HDOM_INFO_INNER', 5);
    +defined('HDOM_INFO_OUTER') || define('HDOM_INFO_OUTER', 6);
    +defined('HDOM_INFO_ENDSPACE') || define('HDOM_INFO_ENDSPACE', 7);

    defined('DEFAULT_TARGET_CHARSET') || define('DEFAULT_TARGET_CHARSET', 'UTF-8');
    defined('DEFAULT_BR_TEXT') || define('DEFAULT_BR_TEXT', "\r\n");
    defined('DEFAULT_SPAN_TEXT') || define('DEFAULT_SPAN_TEXT', ' ');
    defined('MAX_FILE_SIZE') || define('MAX_FILE_SIZE', 600000);
    -define('HDOM_SMARTY_AS_TEXT', 1);
    +defined('HDOM_SMARTY_AS_TEXT') || define('HDOM_SMARTY_AS_TEXT', 1);

    function file_get_html(
    $url,
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘PHP warnings about constants already defined in simple_html_dom.php’ is closed to new replies.