2013051700-1.8.15-add_missing_group_index-52a63a3a3ffaced2.php 750 B

1234567891011121314151617181920212223242526272829
  1. <?php
  2. /**
  3. * Elgg 1.8.15 upgrade 2013051700
  4. * add_missing_group_index
  5. *
  6. * Some Elgg sites are missing the groups_entity full text index on name and
  7. * description. This checks if it exists and adds it if it does not.
  8. */
  9. $db_prefix = elgg_get_config('dbprefix');
  10. $full_text_index_exists = false;
  11. $results = get_data("SHOW INDEX FROM {$db_prefix}groups_entity");
  12. if ($results) {
  13. foreach ($results as $result) {
  14. if ($result->Index_type === 'FULLTEXT') {
  15. $full_text_index_exists = true;
  16. }
  17. }
  18. }
  19. if ($full_text_index_exists == false) {
  20. $query = "ALTER TABLE {$db_prefix}groups_entity
  21. ADD FULLTEXT name_2 (name, description)";
  22. if (!update_data($query)) {
  23. elgg_log("Failed to add full text index to groups_entity table", 'ERROR');
  24. }
  25. }