Chaman
Chaman

Reputation: 1

Warning: Cannot assign an empty string to a string offset wordPress 4.9.5

Warning: Cannot assign an empty string to a string offset in /home/bofi9rpybgx8/public_html/stagging/hello/wp-includes/class.wp-scripts.php on line 426

Upvotes: 0

Views: 4193

Answers (2)

rakesh vadhel
rakesh vadhel

Reputation: 41

For this solution you need replace your this code at your line number

From :

    foreach ( (array) $l10n as $key => $value ) {
        if ( ! is_scalar( $value ) ) {
            continue;
        }

        $l10n[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' );
    }

To:

foreach ( (array) $l10n as $key => $value ) {
        if ( !is_scalar($value) )
            continue;

        if (!empty($value) && !empty($key) ) {
            $l10n[$key] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8');
        }
    }

Because in my site its showing : Only the first byte will be assigned to the string offset Error that's why i am checking offset $key - is it empty or not. and yes its working for me.

Upvotes: 0

Mohcin Bounouara
Mohcin Bounouara

Reputation: 623

I notice that problem in somewhere in the net try to replace in line 426

        foreach ( (array) $l10n as $key => $value ) {
        if ( !is_scalar($value) )
            continue;

        $l10n[$key] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8');
    }

With

        foreach ( (array) $l10n as $key => $value ) {
        if ( !is_scalar($value) )
            continue;

        if (!empty($value)) {
            $l10n[$key] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8');
        }
    }

Upvotes: 3

Related Questions