Support » Plugin: Header Footer Code Manager » Not compartibel with W3TC Plugin

  • Resolved krut1

    (@krut1)


    Header Footer Code Manager tries to create a table in the database on each page call. It will be nice to create the table one time and set a flag in blog_optioins.

    Error: [15-Jan-2020 13:25:21 UTC] PHP Warning: mysqli_num_fields() expects parameter 1 to be mysqli_result, bool given in /var/www/wirecard-supr/supr2/s2-app/wordpress/wp-includes/wp-db.php on line 3283

    Backtrace:

    [15-Jan-2020 13:25:21 UTC] [DEBUG] Backtrace:
    Array
    (
        [0] => Array
            (
                [file] => /wordpress/wp-includes/wp-db.php
                [line] => 663
                [function] => load_col_info
                [class] => wpdb
                [type] => ->
            )
    
        [1] => Array
            (
                [file] => /wordpress/wp-content/plugins/w3-total-cache/DbCache_WpdbInjection_QueryCaching.php
                [line] => 176
                [function] => __get
                [class] => wpdb
                [type] => ->
            )
    
        [2] => Array
            (
                [file] => /wordpress/wp-content/plugins/w3-total-cache/DbCache_WpdbLegacy.php
                [line] => 119
                [function] => query
                [class] => W3TC\DbCache_WpdbInjection_QueryCaching
                [type] => ->
            )
    
        [3] => Array
            (
                [file] => /wordpress/wp-includes/wp-db.php
                [line] => 2579
                [function] => query
                [class] => W3TC\DbCache_WpdbLegacy
                [type] => ->
            )
    
        [4] => Array
            (
                [file] => /wordpress/wp-admin/includes/upgrade.php
                [line] => 2602
                [function] => get_results
                [class] => wpdb
                [type] => ->
            )
    
        [5] => Array
            (
                [file] => /wordpress/wp-content/plugins/header-footer-code-manager/99robots-header-footer-code-manager.php
                [line] => 60
                [function] => dbDelta
            )
    
        [6] => Array
            (
                [file] => /wordpress/wp-content/plugins/header-footer-code-manager/99robots-header-footer-code-manager.php
                [line] => 93
                [function] => hfcm_options_install
            )
    
        [7] => Array
            (
                [file] => /wordpress/wp-includes/class-wp-hook.php
                [line] => 286
                [function] => hfcm_db_update_check
            )
    
        [8] => Array
            (
                [file] => /wordpress/wp-includes/class-wp-hook.php
                [line] => 310
                [function] => apply_filters
                [class] => WP_Hook
                [type] => ->
            )
    
        [9] => Array
            (
                [file] => /wordpress/wp-includes/plugin.php
                [line] => 465
                [function] => do_action
                [class] => WP_Hook
                [type] => ->
            )
    
        [10] => Array
            (
                [file] => /wordpress/wp-settings.php
                [line] => 394
                [function] => do_action
            )
    
        [11] => Array
            (
                [file] => /wordpress/wp-config.php
                [line] => 145
                [args] => Array
                    (
                        [0] => /wordpress/wp-settings.php
                    )
    
                [function] => require_once
            )
    
        [12] => Array
            (
                [file] => /wordpress/wp-load.php
                [line] => 37
                [args] => Array
                    (
                        [0] => /wordpress/wp-config.php
                    )
    
                [function] => require_once
            )
    
        [13] => Array
            (
                [file] => /wordpress/wp-blog-header.php
                [line] => 13
                [args] => Array
                    (
                        [0] => /wordpress/wp-load.php
                    )
    
                [function] => require_once
            )
    
        [14] => Array
            (
                [file] => /wordpress/index.php
                [line] => 17
                [args] => Array
                    (
                        [0] => /wordpress/wp-blog-header.php
                    )
    
                [function] => require
            )
    
    )
Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Support 99robotsteam

    (@99robotsteam)

    Hello @krut1 – Our plugin creates the Database only once, and as you suggested correctly, it creates options with flags thereon. It seems like you might have the Database cache option on in W3TC, which might lead to this issue. We were unable to replicate this on our end. Can you please tell us the exact steps to follow to replicate this issue. Any screenshots will be helpful as well.

    Thank you,

    Thanks for an answer. I can say you where is the bug 🙂

    In your hfcm_db_update_check you check the site_option, but then you update a blog_option.

    function hfcm_db_update_check() {
        global $hfcm_db_version;
        global $wpdb;
        $table_name      = $wpdb->prefix . 'hfcm_scripts';
        if ( get_site_option( 'hfcm_db_version' ) != $hfcm_db_version ) {
        ...
        }
        update_option( 'hfcm_db_version', $hfcm_db_version );
    }

    In multisite WordPress it is the different things 🙁

    And it will be nice to move updating of option in IF. It schould look like:

    function hfcm_db_update_check() {
        global $hfcm_db_version;
        global $wpdb;
        $table_name      = $wpdb->prefix . 'hfcm_scripts';
        if ( get_site_option( 'hfcm_db_version' ) !== $hfcm_db_version ) {
            ...
            update_site_option( 'hfcm_db_version', $hfcm_db_version );
        }
    }

    You are welcome 😉

    • This reply was modified 3 months, 1 week ago by krut1.
    Plugin Support 99robotsteam

    (@99robotsteam)

    Thank you for the details @krut1

    Ah! – You are facing this issue on a multi-site. Can you please tell us the exact steps you faced to reproduce or view this error on the backend? Do you still face this when the W3TC plugin is deactivated?

    It is a general problem (without W3TC).

    Activate please Header Footer Code Manager in one subsite, but not in main-blog.

    And look in DB-Queries:

    mysql -u user -ppassord -h host -A wordpress
    
    SHOW FULL PROCESSLIST;

    And you will look on each siteloading: CREATE TABLE IF NOT EXISTS wp_2_hfcm_scripts....

    • This reply was modified 3 months, 1 week ago by krut1.
    • This reply was modified 3 months, 1 week ago by krut1.
    Plugin Support 99robotsteam

    (@99robotsteam)

    Hello @krut1 – Our team has gone over this, and for tracking and recording purposes, we have decided to let each sub-site have its own HFCM table. If this changes, we will keep you updated.

    @99robotsteam thanks. We are waiting for it.

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