WordPress.org

Ready to get started?Download WordPress

Forums

Relevanssi - A Better Search
[resolved] term_reverse column not in wp_relevanssi table (6 posts)

  1. jjchinquist
    Member
    Posted 9 months ago #

    Hello, after taking over a somewhat outdated WordPress site, I am updating relevanssi from 3.1.6 to 3.1.9 and I have a missing table column: term_reverse.

    Your problem seems to be the following code block was never run when I called the updater from the administration GUI:
    if (get_option('relevanssi_db_version') < 16) {
    $sql = "ALTER TABLE $relevanssi_table ADD COLUMN term_reverse VARCHAR(50);";
    $wpdb->query($sql);
    $sql = "UPDATE $relevanssi_table SET term_reverse = REVERSE(term);";
    $wpdb->query($sql);
    $sql = "CREATE INDEX relevanssi_term_reverse_idx ON $relevanssi_table (term_reverse(10));";
    $wpdb->query($sql);
    }

    Could it be that you meant to say get_option('relevanssi_db_version') <= 16?

    http://wordpress.org/plugins/relevanssi/

  2. jjchinquist
    Member
    Posted 9 months ago #

    After manually running all 3 DB statements in phpmyadmin, the indexing works again.

  3. Mikko Saari
    Member
    Plugin Author

    Posted 9 months ago #

    No, it's just that updating plugins automatically doesn't trigger any actions that depend on plugin activation (or at least that's my experience). So, in this case, the solution would be to deactivate the plugin after the update and re-activating it.

  4. jjchinquist
    Member
    Posted 9 months ago #

    Hello,

    there must be something more to it because testing "disable" and "re-enable" also does not work. I have to completely uninstall the module and re-install it. I find this to be counter-productive.

    After a quick scan, I could not find a relevant hook http://codex.wordpress.org/Plugin_API/Filter_Reference that would be called during updates. Please correct me if I am wrong. As a messy but quick fix, please add the following code during the "re-index" site button call and tell the administrator to run a re-index:

    file: init.php

    function relevanssi_update_database_3_1_10() {
        global $wpdb;
    
        require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
    
        $relevanssi_table = $wpdb->prefix . "relevanssi";
    
        $sql = "SHOW COLUMNS FROM $relevanssi_table LIKE 'term_reverse'";
    
        if ($column = $wpdb->get_row($sql)) {
            return;
        }
    
        $sql = "ALTER TABLE $relevanssi_table ADD COLUMN term_reverse VARCHAR(50);";
        $wpdb->query($sql);
    
        $sql = "UPDATE $relevanssi_table SET term_reverse = REVERSE(term);";
        $wpdb->query($sql);
    
        $sql = "CREATE INDEX relevanssi_term_reverse_idx ON $relevanssi_table (term_reverse(10));";
        $wpdb->query($sql);
    }

    file: indexing.php

    function relevanssi_build_index($extend = false) {
    
        /**
         * Check that our database is correctly updated.
         */
        require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
        relevanssi_update_database_3_1_10();

    Or at least add instructions to the README file if nothing else.

  5. Mikko Saari
    Member
    Plugin Author

    Posted 8 months ago #

    The changelog does mention if it's necessary to reactivate the plugin manually. But yeah, I think from now on I'll make the plugin force the database changes when they happen, in order to avoid this.

    (Actually, your problem was older than this, because 3.1.6 introduced the database changes; the previous owner missed the deactivation after the upgrade to 3.1.6.)

  6. jjchinquist
    Member
    Posted 8 months ago #

    Thanks for the feedback. Post if you need more input or help

Reply

You must log in to post.

About this Plugin

About this Topic

Tags