Wood Chen

WordPress Issues and Workarounds After Upgrading to 8.1

0 comments72 views249 words

This post was translated from Chinese by AI. If anything reads oddly, the Chinese original is authoritative. 中文原文

This workaround only applies if you use the same theme and plugin as I do. It only hides the error messages without affecting the frontend display; it does not fix the underlying issue. We still need to wait for a fix from the developers.
Theme: Neve 3.7.2
Plugin: WP Super Cache 1.10.0

Post editor: Warning: Trying to access array offset on value of type bool in /www/wwwroot/xxx.xxx.net/wp-content/themes/neve/inc/views/template_parts.php on line 432

This PHP error report says that line 432 of template_parts.php tries to access an array offset on a boolean variable, which is not allowed.

In programming, a boolean has only two possible values: true or false. It cannot store multiple values like an array. Trying to access an array offset on a boolean therefore causes an error.

Change from

$markup  = '';
        $markup .= '’;

To

if (is_array($read_more_args) && isset($read_more_args['classes'], $read_more_args['text'])) {
    $markup  = '';
    $markup .= '';
} else {
    // Handle the error case here.
}

Post editor: Warning: Undefined variable $markup in /www/wwwroot/xxx.net/wp-content/themes/neve/inc/views/template_parts.php on line 453

Change from

if ( ! empty( $read_more_args['classes'] ) ) {
            $markup = '
' . $markup . '';
        }

        $new_moretag .= $markup;

        return $new_moretag;

To

$markup = isset($markup) ? $markup : '';

if ( ! empty( $read_more_args['classes'] ) ) {
    $markup = '
' . $markup . '';
}

$new_moretag .= $markup;

return $new_moretag;

Page displays: Deprecated: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in /www/wwwroot/xxx.net/wp-content/plugins/wp-super-cache/wp-cache-phase2.php on line 54

Change from

return do_cacheaction(
        'wp_cache_key',
        // phpcs:ignore WordPress.NamingConventions.ValidVariableName.VariableNotSnakeCase
        wp_cache_check_mobile( $WPSC_HTTP_HOST . $server_port . preg_replace( '/#.*$/', '', str_replace( '/index.php', '/', $url ) ) . $wp_cache_gzip_encoding . wp_cache_get_cookies_values() . '-' . wpsc_get_accept_header() . $accept_tag )
    );

To

$url = $url ?? '';
return do_cacheaction(
    'wp_cache_key',
    wp_cache_check_mobile( $WPSC_HTTP_HOST . $server_port . preg_replace( '/#.*$/', '', str_replace( '/index.php', '/', $url ) ) . $wp_cache_gzip_encoding . wp_cache_get_cookies_values() . '-' . wpsc_get_accept_header() . $accept_tag )
);

Page displays: Deprecated: parse_str(): Passing null to parameter #1 ($string) of type string is deprecated in /www/wwwroot/xxx.net/wp-content/themes/neve/inc/views/pluggable/pagination.php on line 198

Change from

parse_str( wp_parse_url( get_pagenum_link(), PHP_URL_QUERY ), $url_query_args );

To

$query_str = wp_parse_url( get_pagenum_link(), PHP_URL_QUERY );
$query_str = $query_str ?? '';
parse_str($query_str, $url_query_args);

Last updated 2024-01-14

Related posts

Comments 0