From 86c7f1b97418aaea450637971a09682570907249 Mon Sep 17 00:00:00 2001 From: Jared Hancock <jared@osticket.com> Date: Mon, 13 Jul 2015 09:00:19 -0500 Subject: [PATCH] search: Auto reindex when _search is created This patch automatically configures reindexing of the search table when the table is dropped and recreated. --- include/class.search.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/include/class.search.php b/include/class.search.php index d4616307a..9bdefa354 100644 --- a/include/class.search.php +++ b/include/class.search.php @@ -454,7 +454,7 @@ class MysqlSearchBackend extends SearchBackend { $galera = db_result(db_query($sql)); if ($galera && !$mysql56) - throw new Exception('Galera cannot be used with MyISAM tables'); + throw new Exception('Galera cannot be used with MyISAM tables. Upgrade to MariaDB 10 / MySQL 5.6 is required'); $engine = $galera ? 'InnodB' : ($mysql56 ? '' : 'MyISAM'); if ($engine) $engine = 'ENGINE='.$engine; @@ -467,12 +467,17 @@ class MysqlSearchBackend extends SearchBackend { primary key `object` (`object_type`, `object_id`), fulltext key `search` (`title`, `content`) ) $engine CHARSET=utf8"; - return db_query($sql); + if (!db_query($sql)) + return false; + + // Start rebuilding the index + $this->getConfig()->set('reindex', 1); + return true; } /** * Cooperates with the cron system to automatically find content that is - * not index in the _search table and add it to the index. + * not indexed in the _search table and add it to the index. */ function IndexOldStuff() { $class = get_class(); -- GitLab