• Resolved glazergallery

    (@glazergallery)


    I have a navigation bar on my WooCommerce site that I’ve used for years with no problem. It works fine with PHP 7.4 but if I try switching to PHP 8.0, it displays correctly on every page except Product Pages. I have attached screenshots of what happens. The one with the list of links instead of the navigation bar is PHP 8.0. I have tried looking for conflicts with other plugins by eliminating them and adding back one at a time — it doesn’t matter. I ran a debug routine both with PHP 8.0 and with PHP 7.4 and it turned up this (I’ve deleted the full paths or account names for security reasons and substituted brackets). Does anyone know what’s going wrong and how I could fix it? Note that I am a designer not a coder so I have no idea what the code here actually does, but I do know how to edit a child theme and can copy and paste code into it if you tell me exactly what to do.

    PHP 8.0 DEBUG LOG:

    Fatal error: Uncaught TypeError: call_user_func_array(): Argument #1 ($callback) must be a valid callback, function “add_text” not found or invalid function name in /includes/class-wp-hook.php:324 Stack trace: #0 /includes/class-wp-hook.php(348): WP_Hook->apply_filters(NULL, Array) #1 /includes/[/plugin.php(517): WP_Hook->do_action(Array) #2 /wp-content/plugins/woocommerce/templates/content-single-product.php(72): do_action(‘woocommerce_aft…’) #3 /wp-includes/template.php(792): require(‘/home/georgegl/…’) #4 /wp-content/plugins/woocommerce/includes/wc-core-functions.php(284): load_template(‘/home/[account name]/…’, false) #5 /wp-content/plugins/woocommerce/templates/single-product.php(37): wc_get_template_part(‘content’, ‘single-product’) #6 /wp-includes/template-loader.php(106): include(‘/home/[account name]/…’) #7 /wp-blog-header.php(19): require_once(‘/home/georgegl/…’) #8 /index.php(17): require(‘/home/[account name]/…’) #9 {main} thrown in /wp-includes/class-wp-hook.php on line 324

    PHP 7.4 DEBUG LOG:

    Warning: call_user_func_array() expects parameter 1 to be a valid callback, function ‘add_text’ not found or invalid function name in /wp-includes/class-wp-hook.php on line 324

    HERE IS THE CLASS-WP-HOOK.PHP CODE. I’VE BOLDED LINES 324 AND 328:

    EXCERPT OF LINES 289-354 OF CLASS-WP-HOOK.PHP, WITH LINES 324 AND 348 IN RED

    /**

    * Calls the callback functions that have been added to a filter hook.

    *

    * @since 4.7.0

    *

    * @param mixed $value The value to filter.

    * @param array $args  Additional parameters to pass to the callback functions.

    *                     This array is expected to include $value at index 0.

    * @return mixed The filtered value after all hooked functions are applied to it.

    */

    public function apply_filters( $value, $args ) {

    if ( ! $this->callbacks ) {

    return $value;

    }

    $nesting_level = $this->nesting_level++;

    $this->iterations[ $nesting_level ] = $this->priorities;

    $num_args = count( $args );

    do {

    $this->current_priority[ $nesting_level ] = current( $this->iterations[ $nesting_level ] );

    $priority = $this->current_priority[ $nesting_level ];

    foreach ( $this->callbacks[ $priority ] as $the_ ) {

    if ( ! $this->doing_action ) {

    $args[0] = $value;

    }

    // Avoid the array_slice() if possible.

    if ( 0 === $the_['accepted_args'] ) {

    $value = call_user_func( $the_['function'] );

    } elseif ( $the_['accepted_args'] >= $num_args ) {

    $value = call_user_func_array( $the_['function'], $args );

    } else {

    $value = call_user_func_array( $the_['function'], array_slice( $args, 0, $the_['accepted_args'] ) );

    }

    }

    } while ( false !== next( $this->iterations[ $nesting_level ] ) );

    unset( $this->iterations[ $nesting_level ] );

    unset( $this->current_priority[ $nesting_level ] );

    --$this->nesting_level;

    return $value;

    }

    /**

    * Calls the callback functions that have been added to an action hook.

    *

    * @since 4.7.0

    *

    * @param array $args Parameters to pass to the callback functions.

    */

    public function do_action( $args ) {

    $this->doing_action = true;

    $this->apply_filters( '', $args );

    // If there are recursive calls to the current action, we haven't finished it until we get to the last one.

    if ( ! $this->nesting_level ) {

    $this->doing_action = false;

    }

    }

    The page I need help with: [log in to see the link]

Viewing 9 replies - 1 through 9 (of 9 total)
  • Stef

    (@serafinnyc)

    Hello @glazergallery chances are your site’s software is outdated somewhere.

    Can you please submit a systems report?

    Go to?WooCommerce?>?Status?>?Get Systems Report?and pasting that here inside using a Code Block. Please ensure it’s free of <br> tags before pasting or use Github to show casing it redacting any information other than plugins that you don’t want others seeing.

    Plugin Support ckadenge (woo-hc)

    (@ckadenge)

    Hi @glazergallery,

    Thank you for reaching out.

    Looking at the shared error logs, it appears that the issue arises from a function named “add_text” that is being called but cannot be found. This function is likely part of your theme or one of your plugins.

    PHP 8.0 is stricter than PHP 7.4 when it comes to errors. In PHP 7.4, the absence of the “add_text” function is considered a warning, while in PHP 8.0, it’s considered a fatal error, which is why your navigation bar isn’t displaying correctly on Product Pages.

    Here’s are a few steps to try and troubleshoot this issue:

    1. Make sure that all your plugins and theme are up-to-date.
    2. If all your plugins and theme are up-to-date, it is possible there is a conflict between one of the plugins and/or theme. I recommend running a conflict test as suggested here.

    Remember, before making any changes, always back up your site first. This will allow you to restore your site to its current state if anything goes wrong. Also, you can run the conflict test from a staging site to avoid messing the live site.

    I hope this helps!

    Thread Starter glazergallery

    (@glazergallery)

    Here is the System Status Report:

    System Status Report

    ### WordPress Environment ###
    
    WordPress address (URL): [Redacted]
    Site address (URL): [Redacted]
    WC Version: 9.3.1
    Legacy REST API Package Version: ? 1.0.4
    Action Scheduler Version: ? 3.8.1
    Log Directory Writable: ?
    WP Version: 6.6.2
    WP Multisite: –
    WP Memory Limit: 768 MB
    WP Debug Mode: –
    WP Cron: –
    Language: en_US
    External object cache: –
    
    ### Server Environment ###
    
    Server Info: Apache
    PHP Version: 7.4.33
    PHP Post Max Size: 128 MB
    PHP Time Limit: 300
    PHP Max Input Vars: 10000
    cURL Version: 7.87.0
    OpenSSL/1.1.1w
    
    SUHOSIN Installed: –
    MySQL Version: 10.5.25-MariaDB-cll-lve
    Max Upload Size: 128 MB
    Default Timezone is UTC: ?
    fsockopen/cURL: ?
    SoapClient: ?
    DOMDocument: ?
    GZip: ?
    Multibyte String: ?
    Remote Post: ?
    Remote Get: ?
    
    ### Database ###
    
    [REDACTED]
    
    ### Post Type Counts ###
    
    amn_mi-lite: 3
    attachment: 16954
    custom_css: 1
    jetpack_migration: 2
    metagallery: 1
    ml-slide: 25
    ml-slider: 2
    nav_menu_item: 12
    oembed_cache: 2
    page: 98
    post: 2
    product: 2840
    revision: 9678
    so_wc_template: 3
    wccaf: 1
    wp_global_styles: 1
    wp_navigation: 1
    wp_template: 2
    
    ### Security ###
    
    Secure connection (HTTPS): ?
    Hide errors from visitors: ?
    
    ### Active Plugins (19) ###
    
    Duplicate Page: by mndpsingh287 – 4.5.4
    Duplicate Taxonomy Term: by Sebastian Pisula – 1.0.2
    MetaSlider: by MetaSlider – 3.91.0
    Plugin Compatibility Checker: by Dinesh Pilani – 3.0.1
    Products Admin Notes Simple: by Jamie Hall – 1.1
    Regenerate Thumbnails: by Alex Mills (Viper007Bond) – 3.1.6
    Simple Image Sizes: by Rahe – 3.2.1
    Page Builder by SiteOrigin: by SiteOrigin – 2.29.20
    SiteOrigin Premium: by SiteOrigin – 1.66.0
    SiteOrigin CSS: by SiteOrigin – 1.5.11
    SiteOrigin Widgets Bundle: by SiteOrigin – 1.63.1
    Accessibility by UserWay: by UserWay.org – 2.5.3
    WooCommerce Legacy REST API: by WooCommerce – 1.0.4
    WooCommerce Visibility: by codemine – 4.1
    WooCommerce: by Automattic – 9.3.1
    WooSidebars: by WooCommerce – 1.4.6
    YITH Essential Kit for WooCommerce #1: by YITH – 2.37.0
    YITH WooCommerce Catalog Mode: by YITH – 2.38.0
    YITH WooCommerce Wishlist: by YITH – 3.38.0
    
    ### Inactive Plugins (2) ###
    
    WP All Import - WooCommerce Add-On Pro: by Soflyy – 3.2.6
    WP All Import Pro: by Soflyy – 4.6.9
    
    ### Dropin Plugins () ###
    
    install.php: install.php
    maintenance.php: maintenance.php
    
    ### Must Use Plugins (1) ###
    
    WP Staging Optimizer: by René Hermenau – 1.1
    
    ### Settings ###
    
    Legacy API Enabled: ?
    Force SSL: –
    Currency: USD ($)
    Currency Position: left
    Thousand Separator: ,
    Decimal Separator: .
    Number of Decimals: 0
    Taxonomies: Product Types: external (external)
    grouped (grouped)
    simple (simple)
    variable (variable)
    
    Taxonomies: Product Visibility: exclude-from-catalog (exclude-from-catalog)
    exclude-from-search (exclude-from-search)
    featured (featured)
    outofstock (outofstock)
    rated-1 (rated-1)
    rated-2 (rated-2)
    rated-3 (rated-3)
    rated-4 (rated-4)
    rated-5 (rated-5)
    
    Connected to WooCommerce.com: –
    Enforce Approved Product Download Directories: –
    HPOS feature enabled: –
    Order datastore: WC_Order_Data_Store_CPT
    HPOS data sync enabled: –
    
    ### Logging ###
    
    Enabled: ?
    Handler: Automattic\WooCommerce\Internal\Admin\Logging\LogHandlerFileV2
    Retention period: 30 days
    Level threshold: –
    Log directory size: 18 KB
    
    ### WC Pages ###
    
    Shop base: #5 - /shop/
    Cart: ? Page visibility should be public
    Checkout: #7 - /checkout/ -  Contains the [woocommerce_checkout] shortcode
    My account: #8 - /my-account/
    Terms and conditions: #20359 - /privacy-policy/
    
    ### Theme ###
    
    Name: Vantage Child
    Version: 1.0.0
    Author URL: https://siteorigin.com/
    Child Theme: ?
    Parent Theme Name: Vantage
    Parent Theme Version: 1.20.22 – 1.20.25 is available
    Parent Theme Author URL: https://siteorigin.com/
    WooCommerce Support: ?
    
    ### Templates ###
    
    Overrides: –
    
    ### Admin ###
    
    Enabled Features: activity-panels
    analytics
    product-block-editor
    coupons
    core-profiler
    customize-store
    customer-effort-score-tracks
    import-products-task
    experimental-fashion-sample-products
    shipping-smart-defaults
    shipping-setting-tour
    homescreen
    marketing
    mobile-app-banner
    navigation
    onboarding
    onboarding-tasks
    pattern-toolkit-full-composability
    product-custom-fields
    remote-inbox-notifications
    remote-free-extensions
    payment-gateway-suggestions
    printful
    shipping-label-banner
    subscriptions
    store-alerts
    transient-notices
    woo-mobile-welcome
    wc-pay-promotion
    wc-pay-welcome-page
    launch-your-store
    
    Disabled Features: experimental-blocks
    minified-js
    product-pre-publish-modal
    settings
    async-product-editor-category-field
    product-editor-template-system
    blueprint
    reactify-classic-payments-settings
    
    Daily Cron: ? Next scheduled: 2024-09-18 14:21:12 -04:00
    Options: ?
    Notes: 189
    Onboarding: completed
    
    ### Action Scheduler ###
    
    Complete: 198
    Oldest: 2024-08-17 21:00:03 -0400
    Newest: 2024-09-17 12:00:03 -0400
    
    Failed: 3
    Oldest: 2023-03-06 11:41:33 -0500
    Newest: 2024-01-10 17:36:20 -0500
    
    Pending: 1
    Oldest: 2024-09-18 12:00:03 -0400
    Newest: 2024-09-18 12:00:03 -0400
    
    
    ### Status report information ###
    
    Generated at: 2024-09-17 17:03:57 -04:00
    Thread Starter glazergallery

    (@glazergallery)

    @ckadenge — Thanks for the tip. I did try testing for plug in conflicts before and turned up nothing useful, but I can try again. Today I created a staging site so I can do that methodically. I will report back to this thread what I find.

    The standard advice for resolving theme conflicts probably doesn’t help because if I change the theme to Storefront or one of the basic themes, the masthead won’t display correctly anyway, because the masthead formatting is stored in the Child Theme.

    As for “add_text” — that’s very interesting that you are able to see that is the command causing problems. I am able to see that it does not appear in any of the .php files for my Child Theme so we can rule it out there at least, if I understand you correctly.

    Plugin Support Shameem R. a11n

    (@shameemreza)

    Hi @glazergallery

    As @ckadenge mentioned, PHP 8.0 is stricter than PHP 7.4 when it comes to errors. In PHP 7.4, the absence of the add_text function is considered a warning, but in PHP 8.0, it’s considered a fatal error, so your navigation bar isn’t showing as expected on Product Pages.

    Here are some steps to troubleshoot this issue:

    1. Ensure that all your custom code, plugins and your theme are up-to-date and compatible with PHP 8+.
    2. If all your custom code, plugins and theme are up-to-date and compatible with PHP 8+, there might be a conflict between one of the custom code, plugins and theme. I recommend running a conflict test as shared here.

    Rest assured, WooCommerce is compatible with PHP 7.4 to 8.3, even though I use PHP 8.2 on my testing environment and couldn’t reproduce that error. More info: https://woocommerce.com/document/server-requirements/

    I hope this helps and please let us know if you have any further questions!

    Thread Starter glazergallery

    (@glazergallery)

    Hi @shameemreza,

    I followed your suggestions and checked my plugins and none say they are incompatible with PHP 8. I also created a staging site and deactivated all the plugins except WooCommerce. It made no difference. The problem with getting rid of my custom code is that the custom code is what styles the navigation bar. So if I run the site without the portions of the Child Theme that style the navigation bar, which are in header.php and style.css, I can’t tell why the navigation bar displays on every page except Product pages, because the navigation bar won’t display on any pages at all without that styling. I hate to give up an attractive navigation bar that has served us well in the past. The theme is one recommended for use with WooCommerce (Site Origin Vantage). I have contacted Site Origin and they see no reason the theme should cause an issue. And surely if it works with everything else in WooCommerce except this one type of page, it means the fault is not my custom code but something that is different about Product Pages than every other page on a WooCommerce site.

    So am still stuck! Any ideas?

    Plugin Support Shameem R. a11n

    (@shameemreza)

    Hi @glazergallery

    It seems like you’ve done a thorough job of troubleshooting already. However, the issue you’re experiencing might be due to a specific function or code snippet within your custom code that’s incompatible with PHP 8.0 and only triggered on the Product Pages.

    Here’s what I suggest:

    1. Double-check your custom code, especially the parts that are specific to the Product Pages. Look for deprecated functions or syntaxes that were acceptable in PHP 7.4 but not in PHP 8.0.
    2. You can also enable WP_DEBUG mode. This will allow WordPress to log any errors that occur, which might give you a clue about what’s going wrong.
    3. If you’re uncomfortable checking the code yourself, you might need to consider hiring a developer experienced with PHP and WooCommerce.

    I hope this helps! Please let us know how it goes or if you need further assistance.

    Thread Starter glazergallery

    (@glazergallery)

    @shameemreza I finally found the problematic code and it was where you and others suspected, in the custom code in the child theme. As I said in the first post I made describing this issue, the debug log said that the problematic command was add_text. However, I had no idea what function was calling on add_text. I had looked for it in all the child theme PHP files by doing a Find command with my browser on each page, while it was loaded in the Dashboard. I tested the Find function by searching for code I knew was in the PHP file and it worked. But for some reason, it did NOT find add_text, even though it was there in my child theme’s functions.php file. I even tried that search on different days and it never turned up. It seems weird, but that’s what kept happening.

    The way I finally found where add_text was hiding was through the Find function in Bluefish, which is an open source editor for webpage code that I use sometimes to edit HTML files on non-WordPress sites. I searched the files I had stored on my local machine and it found it in the child theme functions.php and Bluefish’s Find also told me which line it was on. Now that I knew where it was, I deleted that code and PHP 8 is not causing the problem on product pages — nor, apparently anywhere else. I know what the purpose of that code was, it was indeed specific to product pages, but I can accomplish the same thing another way so I don’t need it anymore.

    Therefore, my advice to anyone else who is looking for a specific phrase in your Child Theme while it’s open in the File Editor in the WordPress dashboard is see if you can do a Find somewhere else, because Find in the dashboard may not work.

    Plugin Support Shameem R. a11n

    (@shameemreza)

    Hi @glazergallery

    We’re glad to hear that you were able to identify and thanks for sharing it with the community too! ??

    Should you have further inquiries, kindly create a new topic here.

    Meanwhile, if it isn’t too much to ask for – would you mind leaving us a review here?

    It only takes a couple of minutes but helps us tremendously. It would mean so much to us and would go a really long way.

    Thanks!

Viewing 9 replies - 1 through 9 (of 9 total)
  • You must be logged in to reply to this topic.