INFRA-132 - CRM/Contribute - Misc
[civicrm-core.git] / CRM / Core / InnoDBIndexer.php
index cce2802e5add02e4183b6f8e3fec7ddf7b0d4ec0..5f880e1d2b21e7541f2d9b829f2051f34b761bce 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.5                                                |
+ | CiviCRM version 4.6                                                |
  +--------------------------------------------------------------------+
  | Copyright CiviCRM LLC (c) 2004-2014                                |
  +--------------------------------------------------------------------+
@@ -75,7 +75,7 @@ class CRM_Core_InnoDBIndexer {
           array('name'),
         ),
       );
-      $active = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'enable_innodb_fts', NULL, FALSE);
+      $active = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SEARCH_PREFERENCES_NAME, 'enable_innodb_fts', NULL, FALSE);
       self::$singleton = new self($active, $indices);
     }
     return self::$singleton;
@@ -87,7 +87,8 @@ class CRM_Core_InnoDBIndexer {
    *
    * @param bool $oldValue
    * @param bool $newValue
-   * @param array $metadata Specification of the setting (per *.settings.php)
+   * @param array $metadata
+   *   Specification of the setting (per *.settings.php).
    */
   public static function onToggleFts($oldValue, $newValue, $metadata) {
     $indexer = CRM_Core_InnoDBIndexer::singleton();
@@ -128,7 +129,8 @@ class CRM_Core_InnoDBIndexer {
    * Determine if an index is expected to exist
    *
    * @param string $table
-   * @param array $fields list of field names that must be in the index
+   * @param array $fields
+   *   List of field names that must be in the index.
    * @return bool
    */
   public function hasDeclaredIndex($table, $fields) {
@@ -156,6 +158,13 @@ class CRM_Core_InnoDBIndexer {
    * @return array (string $indexName => string $indexName)
    */
   public function findActualFtsIndexNames($table) {
+    $mysqlVersion = CRM_Core_DAO::singleValueQuery('SELECT VERSION()');
+    if (version_compare($mysqlVersion, '5.6', '<')) {
+      // If we're not on 5.6+, then there cannot be any InnoDB FTS indices!
+      // Also: information_schema.innodb_sys_indexes is only available on 5.6+.
+      return array();
+    }
+
     // Note: this only works in MySQL 5.6,  but this whole system is intended to only work in MySQL 5.6
     $sql = "
       SELECT i.name as index_name
@@ -254,7 +263,7 @@ class CRM_Core_InnoDBIndexer {
   }
 
   /**
-   * @param boolean $isActive
+   * @param bool $isActive
    */
   public function setActive($isActive) {
     $this->isActive = $isActive;