• Upgraded a site from 5.3.9 to 5.8.1. Plug-ins in use have all been updated and are allegedly compatible. Re-checking those details. Meanwhile…

    I got a couple PHP errors (below) from functions.php. I pulled up functions.php to try to figure out which plug-in was the issue. I ran into two issues doing that.

    First, the lines that are referenced by the error message are the PHP lines that throw the error messages (the error routines), NOT the lines that actually generated the error. So referencing line numbers is relatively useless. (?). Code shown below.

    Second, the specific code element that’s referenced in the error messages doesn’t seem to actually be in functions.php.
    —————————————————————————–
    Details:
    First error:

    This message appeared at the top of the WordPress dashboard:

    Notice: WP_Scripts::localize was called incorrectly. The $l10n parameter must be an array. To pass arbitrary data to scripts, use the wp_add_inline_script() function instead. Please see Debugging in WordPress for more information. (This message was added in version 5.7.0.) in /home/masked/public_html/wp-includes/functions.php on line 5663

    Here’s a slice from functions.php around 5663. Clearly it’s the line # of the error handler:

    trigger_error(
    sprintf(
    /* translators: Developer debugging message. 1: PHP function name, 2: Explanatory message, 3: WordPress version number. */
    __( '%1$s was called <strong>incorrectly</strong>. %2$s %3$s' ),
    					$function,
    					$message,
    					$version
    ),
    E_USER_NOTICE <em>(note: this is line 5663)</em>
    );


    Second Error:
    This message appeared embedded in pages at the site:

    Deprecated: wp_make_content_images_responsive is deprecated since version 5.5.0! Use wp_filter_content_tags() instead. in /home/masked/public_html/wp-includes/functions.php on line 5211

    Here’s a slice from functions.php around 5221. Clearly it’s also the line # of the error handler:

    trigger_error(
    sprintf(
    /* translators: 1: PHP function name, 2: Version number. */
    __( '%1$s is <strong>deprecated</strong> since version %2$s with no alternative available.' ),
    		$function,
    		$version
    		),
    	E_USER_DEPRECATED
    );
Viewing 4 replies - 1 through 4 (of 4 total)
  • Moderator t-p

    (@t-p)

    Please review 5.8 Master List and attempt troubleshooting outlined therein.

    Thread Starter Benny

    (@wordbob)

    Thanks, I will give some of that a shot.

    But, is there an answer/solution to getting a hand on what code is actually throwing the error, per my post above? That would send me direct to a theme or plugin without the somewhat backdoor hunt-n-peck method of “turn things on or off until you find it”.

    As a former software developer, hunt-n-peck was always a last resort alternative.

    Dion

    (@diondesigns)

    You can add the following code just before the trigger_error() calls:

    ob_start();
    debug_print_backtrace();
    echo '<pre>' . ob_get_clean() . '</pre>';

    A complete backtrace will then be generated and displayed, and it should provide you with the information you need to debug the issues. (I’m somewhat surprised this isn’t done within WordPress.)

    Alternately, turning off WP_DEBUG and setting the PHP error level to its default will block both messages from appearing.

    Thread Starter Benny

    (@wordbob)

    Thanks. I’ll give that a shot.

    I was thinking that they could be suppressed y shutting that off, but it seems like a bad strategy overall ??

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Finding PHP errors in Plugins?’ is closed to new replies.