Forums » Plugin: Relevanssi - A Better Search » PHP Fatal error when Expand shortcodes is enabled

  • Resolved Tema

    (@madeinua)


    Hi there,

    I have an error during the website indexing when the option “Expand shortcodes” is enabled:

    PHP Fatal error: Uncaught Error: Call to undefined function relevanssi_enable_tablepress_shortcodes() in /wp-content/plugins/relevanssi/lib/indexing.php:1420
    Stack trace:
    #0 /wp-content/plugins/relevanssi/lib/indexing.php(548): relevanssi_index_content(Array, Object(WP_Post), ‘3’, false)
    #1 /wp-content/plugins/relevanssi/lib/indexing.php(758): relevanssi_index_doc(12032, true, ‘all’, true)
    #2 /wp-content/plugins/relevanssi/lib/indexing.php(815): relevanssi_publish(12032, true)
    #3 /wp-includes/class-wp-hook.php(290): relevanssi_insert_edit(12032)
    #4 /wp-includes/class-wp-hook.php(312): WP_Hook->apply_filters(”, Array)
    #5 /wp-includes/plugin.php(478): WP_Hook->do_action(Array)
    #6 /wp-includes/post.php(4241): do_action(‘wp_insert_post’, 12032, Object(WP_Post), true)
    #7 /wp-content/plugins/wp-missed-schedule in /wp-content/plugins/relevanssi/lib/indexing.php on line 1420

    The reason is quite simple – I don’t have installed TablePress on my website.

Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Author Mikko Saari

    (@msaari)

    No, having TablePress or not has nothing to do with this. Your Relevanssi installation is missing a file which defines the function. I would recommend reinstalling Relevanssi to make sure no files are missing.

    Thread Starter Tema

    (@madeinua)

    Okay, thanks. This is not the missed file but the problem with the other plugin. The topic can be closed.

    Plugin Author Mikko Saari

    (@msaari)

    No, you are getting the error because you are missing the file that defines the relevanssi_enable_tablepress_shortcodes() function. Trust me, I wrote this code, I know. This function should always be defined, whether you use TablePress or not, it’s a Relevanssi function, not a TablePress function.

    Thread Starter Tema

    (@madeinua)

    I have another plugin that tries to insert a post before your plugin initializes relevanssi_init() which includes tablepress and other classes.

    Thread Starter Tema

    (@madeinua)

    Just an example that will cause the problem:

    add_action( 'init', function () {
    wp_insert_post(..);
    }, 0);
    Plugin Author Mikko Saari

    (@msaari)

    Ok, that explains it: you’re acting too early. Move your function to a priority later than Relevanssi (Relevanssi runs on default 10). At the time your function runs, Relevanssi is active, but hasn’t loaded up everything yet. Move your function to priority 11 or later, and it shoud run just fine.

    Thread Starter Tema

    (@madeinua)

    Up.

    Hi, finally I would say this is the error because even this code leads to the fatal error:

    add_action( 'init', function () {
    wp_insert_post(..);
    });

    Quite normal case – creating posts inside the ‘init’ hook with the default priority. However even it throws the error message.

    Thanks.

    Plugin Author Mikko Saari

    (@msaari)

    I’ll move Relevanssi initialization to priority 1 to avoid problems like this, but still, I’d seriously warn about creating posts on init on priority 10 – at that point, most plugins haven’t done their initialization yet, and you’re bound to run into problems. Acting on priority 11 will make sure all the plugins that init on priority 10 have got their stuff together.

    @msaari I would hate to reopen this, but I’m getting the same error when I use the “Duplicate Post” plugin to create new posts.

    I’m using version 2.6.1. Have you changed your plugin’s priority already?

    Since this is another plugin’s code, I would rather not edit its code myself.

    Plugin Author Mikko Saari

    (@msaari)

    It’s fixed, but the fix hasn’t been released. Next release is coming in August, I guess, and will contain the fix.

    To hotfix this now, change /lib/init.php

    add_action( 'init', 'relevanssi_init' );

    to

    add_action( 'init', 'relevanssi_init', 1 );

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘PHP Fatal error when Expand shortcodes is enabled’ is closed to new replies.