• Resolved lcvdesigns

    (@lcvdesigns)


    Hi there I am not sure who to contact regarding the following: 
    
    [29-May-2023 02:03:43 UTC] PHP Warning:  Trying to access array offset on value of type bool in /home/zedtdnbp/public_html/wp-content/plugins/woocommerce/includes/wc-template-functions.php on line 1612
    
    Below is the code from that line:
    
    return '<div data-thumb="' . esc_url( $thumbnail_src[0] ) . '" data-thumb-alt="' . esc_attr( $alt_text ) . '" class="woocommerce-product-gallery__image"><a href="' . esc_url( $full_src[0] ) . '">' . $image . '</a></div>';
    
    When I look at the full code it also does look collation related which would be odd since utf8mb4 and is even mentioned in their documentation:
    
                     * Indexes have a maximum size of 767 bytes. Historically, we haven't need to be concerned about that.
    
                     * As of WP 4.2, however, they moved to utf8mb4, which uses 4 bytes per character. This means that an index which
    
                     * used to have room for floor(767/3) = 255 characters, now only has room for floor(767/4) = 191 characters.
    
    Alternatively it could just be some custom CSS or something as simple as a missing thumbnail.
    
    Here’s a snippet from with the full function definition:
    
       1582 function wc_get_gallery_image_html( $attachment_id, $main_image = false ) {
    
       1583         $flexslider        = (bool) apply_filters( 'woocommerce_single_product_flexslider_enabled', get_theme_support( 'wc-product-gallery-slider' ) );
    
       1584         $gallery_thumbnail = wc_get_image_size( 'gallery_thumbnail' );
    
       1585         $thumbnail_size    = apply_filters( 'woocommerce_gallery_thumbnail_size', array( $gallery_thumbnail['width'], $gallery_thumbnail['height'] ) );
    
       1586         $image_size        = apply_filters( 'woocommerce_gallery_image_size', $flexslider || $main_image ? 'woocommerce_single' : $thumbnail_size );
    
       1587         $full_size         = apply_filters( 'woocommerce_gallery_full_size', apply_filters( 'woocommerce_product_thumbnails_large_size', 'full' ) );
    
       1588         $thumbnail_src     = wp_get_attachment_image_src( $attachment_id, $thumbnail_size );
    
       1589         $full_src          = wp_get_attachment_image_src( $attachment_id, $full_size );
    
       1590         $alt_text          = trim( wp_strip_all_tags( get_post_meta( $attachment_id, '_wp_attachment_image_alt', true ) ) );
    
       1591         $image             = wp_get_attachment_image(
    
       1592                 $attachment_id,
    
       1593                 $image_size,
    
       1594                 false,
    
       1595                 apply_filters(
    
       1596                         'woocommerce_gallery_image_html_attachment_image_params',
    
       1597                         array(
    
       1598                                 'title'                   => _wp_specialchars( get_post_field( 'post_title', $attachment_id ), ENT_QUOTES, 'UTF-8', true ),
    
       1599                                 'data-caption'            => _wp_specialchars( get_post_field( 'post_excerpt', $attachment_id ), ENT_QUOTES, 'UTF-8', true ),
    
       1600                                 'data-src'                => esc_url( $full_src[0] ),
    
       1601                                 'data-large_image'        => esc_url( $full_src[0] ),
    
       1602                                 'data-large_image_width'  => esc_attr( $full_src[1] ),
    
       1603                                 'data-large_image_height' => esc_attr( $full_src[2] ),
    
       1604                                 'class'                   => esc_attr( $main_image ? 'wp-post-image' : '' ),
    
       1605                         ),
    
       1606                         $attachment_id,
    
       1607                         $image_size,
    
       1608                         $main_image
    
       1609                 )
    
       1610         );
    
       1611
    
       1612         return '<div data-thumb="' . esc_url( $thumbnail_src[0] ) . '" data-thumb-alt="' . esc_attr( $alt_text ) . '" class="woocommerce-product-gallery__image"><a href="' . esc_url
    
       1612 ( $full_src[0] ) . '">' . $image . '</a></div>';
Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi @lcvdesigns

    Thanks for reaching out!

    I understand you are experiencing an issue with a PHP warning in your WooCommerce installation. It seems that the issue is related to accessing an array offset on a boolean value in the wc-template-functions.php file on line 1612. This could be caused by various reasons, including a missing thumbnail, custom CSS, or a collation-related issue.

    For us to investigate this further, can you please try to switch to the default Storefront theme and only WooCommerce plugin is enabled and see if this resolves the issue?

    If so, then this kind of problem is usually caused by your theme or a third-party plugin present on your site. We can run a conflict test to verify this. I’d recommend cloning your site to a staging environment and performing the tests described on this guide without modifying your live site or impacting customers. Many hosts provide staging facilities, so it’s worth checking in with them. It’s also possible to do it using the free WP Staging plugin.

    If this was caused by a third-party plugin present on your site, it would be best to reach out to the developers for further assistance here.

    If this did not resolve the issue, please share your System Status Report, that will help us further troubleshoot.

    You can find it via WooCommerce > Status. Select Get system report and then Copy for support. Once you’ve done that, you can paste it into your reply here.

    If you could also provide the fatal error logs (if any) under WooCommerce > Status > Logs.

    You could copy and paste your reply here or paste it via https://gist.github.com/ and send the link here.

    Let us know how it goes!

    Thread Starter lcvdesigns

    (@lcvdesigns)

    Hi thank you so much for the response please also see below:

    We just picked this up in wp-config file:

    define( ‘DB_CHARSET’, ‘utf8’ );

    I think it should be updated to utf8mb4

    Do we update this and what impact would updating this have on your tables? This is where collation is specified in wordpress. This is an older installation (Feb/2020 if I recall correctly) that has seen quite a few updates and changes.

    anastas10s

    (@anastas10s)

    Hi there @lcvdesigns 👋

    I think it should be updated to utf8mb4 Do we update this and what impact would updating this have on your tables?

    I’d recommend checking out this post, regarding utf8mb4.

    Feel free to go ahead with any updates, in a controlled environment (as in a development server, not the live site), after making sure a backup is created – for making restores painless.

    This is an older installation (Feb/2020 if I recall correctly) that has seen quite a few updates and changes.

    I am not sure if this refers to WordPress and WooCommerce in that installation being versions from Feb/2020, or otherwise. As a first step, make sure all software is updated to their latest versions.

    Linked here is the official document on how to update WooCommerce.

    I trust that points you in the right direction, but if you have more questions, let us know. We’re happy to help!

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Woocommerce Error Being Generated’ is closed to new replies.