• Hi,

    we have the folowing error on the Tutor LMS create new course page form frontend. Please help us solve the issue.

    Many thanks.

    Warning: Trying to access array offset on value of type bool in /home/hostname/public_html/wp-content/plugins/search-with-typesense/includes/Frontend/Frontend.php on line 76

    Fatal error: Uncaught TypeError: array_merge(): Argument #1 must be of type array, null given in /home/hostname/public_html/wp-content/plugins/search-with-typesense/includes/Frontend/Frontend.php:76 Stack trace: #0 /home/hostname/public_html/wp-content/plugins/search-with-typesense/includes/Frontend/Frontend.php(76): array_merge(NULL, Array) #1 /home/hostname/public_html/wp-includes/class-wp-hook.php(324): Codemanas\Typesense\Frontend\Frontend->load_scripts(”) #2 /home/hostname/public_html/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters(NULL, Array) #3 /home/hostname/public_html/wp-includes/plugin.php(517): WP_Hook->do_action(Array) #4 /home/hostname/public_html/wp-includes/script-loader.php(2299): do_action(‘wp_enqueue_scri…’) #5 /home/hostname/public_html/wp-includes/class-wp-hook.php(324): wp_enqueue_scripts(”) #6 /home/hostname/public_html/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters(NULL, Array) #7 /home/hostname/public_html/wp-includes/plugin.php(517): WP_Hook->do_action(Array) #8 /home/hostname/public_html/wp-includes/general-template.php(3192): do_action(‘wp_head’) #9 /home/hostname/public_html/wp-content/plugins/tutor/includes/tutor-general-functions.php(485): wp_head() #10 /home/hostname/public_html/wp-content/plugins/tutor/templates/dashboard/create-course.php(18): get_tutor_header(true) #11 /home/hostname/public_html/wp-includes/template-loader.php(106): include(‘/home/hostname/pub…’) #12 /home/hostname/public_html/wp-blog-header.php(19): require_once(‘/home/hostname/pub…’) #13 /home/hostname/public_html/index.php(17): require(‘/home/hostname/pub…’) #14 {main} thrown in /home/hostname/public_html/wp-content/plugins/search-with-typesense/includes/Frontend/Frontend.php on line 76

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Contributor digamberpradhan

    (@digamberpradhan)

    Hi @flaviusv

    Can you please tell me which version of the plugin are you looking at ?
    I just checked the latest version and i am unable to reproduce this error.

    Also please let me know your current PHP version.

    Thread Starter flaviopv

    (@flaviusv)

    Hi,

    Plugin version 2.0.16, PHP 8.1.33.

    Meanwhile we have found a solution to solve that empty array, we added the code below. Maybe will consider to include it in next patch to update the plugin:


    home/hostname/public_html/wp-content/plugins/search-with-typesense/includes/Frontend/Frontend.php : public function load_scripts()

    public function load_scripts()

    {

    $admin_settings = Admin::get_default_settings();

    $search_config_settings = Admin::get_search_config_settings();

    $build_path = CODEMANAS_TYPESENSE_ROOT_URI_PATH . '/build/';



    $instant_search_script = @include CODEMANAS_TYPESENSE_ROOT_DIR_PATH . '/build/frontend/instant-search.asset.php';

    $autocomplete_script = @include CODEMANAS_TYPESENSE_ROOT_DIR_PATH . '/build/frontend/autocomplete.asset.php';

    $popup_script = @include CODEMANAS_TYPESENSE_ROOT_DIR_PATH . '/build/frontend/popup.asset.php';

    // --------- INSTANT SEARCH: deps + version safe ----------

    $instant_deps = [ 'wp-util' ];

    $instant_version = false;

    if ( is_array( $instant_search_script ) ) {

    if ( ! empty( $instant_search_script['dependencies'] ) && is_array( $instant_search_script['dependencies'] ) ) {

    $instant_deps = array_merge(

    $instant_search_script['dependencies'],

    [ 'wp-util' ]

    );

    }

    if ( ! empty( $instant_search_script['version'] ) ) {

    $instant_version = $instant_search_script['version'];

    }

    }

    // --------------------------------------------------------

    // --------- AUTOCOMPLETE: deps + version safe ------------

    $autocomplete_deps = [ 'wp-util' ];

    $autocomplete_version = false;

    if ( is_array( $autocomplete_script ) ) {

    if ( ! empty( $autocomplete_script['dependencies'] ) && is_array( $autocomplete_script['dependencies'] ) ) {

    $autocomplete_deps = array_merge(

    $autocomplete_script['dependencies'],

    [ 'wp-util' ]

    );

    }

    if ( ! empty( $autocomplete_script['version'] ) ) {

    $autocomplete_version = $autocomplete_script['version'];

    }

    }

    // --------------------------------------------------------

    // --------- POPUP: deps + version safe -------------------

    $popup_deps = [ 'wp-util' ];

    $popup_version = false;

    if ( is_array( $popup_script ) ) {

    if ( ! empty( $popup_script['dependencies'] ) && is_array( $popup_script['dependencies'] ) ) {

    $popup_deps = array_merge(

    $popup_script['dependencies'],

    [ 'wp-util' ]

    );

    }

    if ( ! empty( $popup_script['version'] ) ) {

    $popup_version = $popup_script['version'];

    }

    }

    // --------------------------------------------------------

    // === JS: INSTANT SEARCH ===

    wp_register_script(

    'cm-typesense-instant-search',

    $build_path . 'frontend/instant-search.js',

    $instant_deps,

    $instant_version,

    true

    );

    wp_localize_script(

    'cm-typesense-instant-search',

    'cm_typesense_instant_search_default_settings',

    [

    'debug' => SCRIPT_DEBUG,

    'search_api_key' => $admin_settings['search_api_key'] ?? '',

    'port' => $admin_settings['port'] ?? '',

    'node' => $admin_settings['node'] ?? '',

    'protocol' => $admin_settings['protocol'] ?? '',

    'enabled_post_types' => $search_config_settings['enabled_post_types'] ?? [],

    'available_post_types' => $search_config_settings['available_post_types'] ?? [],

    'search_config' => $search_config_settings['config'] ?? [],

    'date_format' => apply_filters( 'cm_typesense_date_format', get_option( 'date_format' ) ),

    'localized_strings' => [

    'load_more' => __( 'Load More', 'search-with-typesense' ),

    'show_less' => __( 'Show less', 'search-with-typesense' ),

    'show_more' => __( 'Show more', 'search-with-typesense' ),

    ],

    'elementor_edit_mode' => (

    Bootstrap::getInstance()->is_plugin_active( 'elementor/elementor.php' )

    && \Elementor\Plugin::$instance->preview->is_preview_mode()

    ) ? 'true' : 'false',

    ]

    );

    // === JS: AUTOCOMPLETE ===

    wp_register_script(

    'cm-typesense-autocomplete',

    $build_path . 'frontend/autocomplete.js',

    $autocomplete_deps,

    $autocomplete_version,

    true

    );

    wp_localize_script(

    'cm-typesense-autocomplete',

    'cm_typesense_autocomplete_default_settings',

    [

    'debug' => SCRIPT_DEBUG,

    'search_api_key' => $admin_settings['search_api_key'] ?? '',

    'port' => $admin_settings['port'] ?? '',

    'node' => $admin_settings['node'] ?? '',

    'protocol' => $admin_settings['protocol'] ?? '',

    'enabled_post_types' => $search_config_settings['enabled_post_types'] ?? [],

    'available_post_types' => $search_config_settings['available_post_types'] ?? [],

    'search_config' => $search_config_settings['config'] ?? [],

    'hijack_wp_search__type' => $search_config_settings['hijack_wp_search__type'] ?? '',

    'autocomplete_input_delay' => $search_config_settings['autocomplete_input_delay'] ?? 0,

    'autocomplete_submit_action' => $search_config_settings['autocomplete_submit_action'] ?? '',

    'elementor_edit_mode' => (

    Bootstrap::getInstance()->is_plugin_active( 'elementor/elementor.php' )

    && \Elementor\Plugin::$instance->preview->is_preview_mode()

    ) ? 'true' : 'false',

    ]

    );

    // === JS: POPUP ===

    wp_register_script(

    'cm-typesense-popup',

    $build_path . 'frontend/popup.js',

    $popup_deps,

    $popup_version,

    true

    );

    wp_localize_script(

    'cm-typesense-popup',

    'cm_typesense_popup_default_settings',

    [

    'hijack_wp_search__type' => $search_config_settings['hijack_wp_search__type'] ?? '',

    ]

    );

    // === CSS ===

    wp_register_style(

    'algolia-satellite',

    CODEMANAS_TYPESENSE_ROOT_URI_PATH . 'assets/vendor/css/algolia-satellite.min.css',

    false,

    $instant_version

    false

    );

    wp_register_style(

    'cm-typesense-frontend-style',

    CODEMANAS_TYPESENSE_ROOT_URI_PATH . 'build/frontend/style-instant-search.css',

    [ 'algolia-satellite' ],

    $instant_version,

    false

    );

    wp_enqueue_style( 'cm-typesense-frontend-style' );

    }
Viewing 2 replies - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.