• Resolved linux4me2

    (@linux4me2)


    This one really has me scratching my head.

    I have a site whose error log is filling up with PHP warnings like this:

    PHP Warning:  json_encode(): Invalid UTF-8 sequence in argument in /home/theusername/public_html/wp-includes/class.wp-scripts.php on line 170

    It has been particularly hard to troubleshoot because I can’t reproduce the error by browsing to a particular post or page, though the warning keeps showing up in the error logs.

    I’ve searched for this error message but haven’t found an issue involving class.wp-scripts.php. It looks like class.wp-scripts.php handles the enqueueing of scripts, and I don’t see a script name for the site that includes an invalid UTF-8 character.

    Does anyone have any idea how I might identify the cause of this warning and fix it?

Viewing 4 replies - 1 through 4 (of 4 total)
  • I’m getting the same error on a production server… I cannot recreate or find the culprit. Any ideas would be greatly appreciated!

    Moderator Jose Castaneda

    (@jcastaneda)

    THEME COFFEE MONKEY

    Does this happen with all plugins deactivated and a bundled theme like Twenty Fourteen or Twenty Thirteen?

    Thread Starter linux4me2

    (@linux4me2)

    I’m so glad it’s not just me!

    I’m running the Twenty Ten theme on the problem site. I am not in a position to deactivate all plugins because this is a production site, but it isn’t running any plugins that I’m not running in the same combination on another site that isn’t throwing the warning.

    If I get a chance today, I’m going to try adding some code to class.wp-scripts.php to record the values of $l10n in the problem line:

    $script = "var $object_name = " . json_encode($l10n) . ';';

    to see if I can figure out which one contains an invalid UTF-8 sequence and trace it back that way.

    Thread Starter linux4me2

    (@linux4me2)

    I put the code in to catch the invalid UTF-8 sequences and discovered a couple of things. First, the reason I wasn’t able to reproduce the error appears to be that someone is apparently submitting an array of arrays to the WP_Scripts function, and some of the values for the secondary arrays are invalid UTF-8 strings including a variety of strings that aren’t script names, spammy stuff with URLs to spammer sites, etc.

    I reviewed the site’s traffic logs and noticed a huge upswing in traffic from a particular country well-known for spam/hacking that corresponds to the time this site has been throwing the warning.

    It doesn’t look like it has to do with WordPress after all, or at least not in the sense that the warning represents something wrong with the site.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘PHP Warning: json_encode(): Invalid UTF-8 sequence in argument’ is closed to new replies.