diff --git a/CHANGELOG.md b/CHANGELOG.md index 4fd0891..aa12396 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,7 @@ # Änderungen von search_it + +## Version 6.6.4 (2019-02-25) +- Reindexierung überarbeitet, zusätzlicher EP "MEDIA_DELETED" - highlighter fix #186 thx @alexwenz - rex_escape statt htmlspecialchars - Versuch fix PHP 7.3 @rolandsee diff --git a/LICENSE b/LICENSE index 4a696e1..deb2c87 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -The MIT License (MIT) +MIT License Copyright (c) 2016 Friends Of REDAXO diff --git a/boot.php b/boot.php index a0f39af..e1dce37 100644 --- a/boot.php +++ b/boot.php @@ -66,6 +66,7 @@ 'CAT_UPDATED', 'MEDIA_ADDED', 'MEDIA_UPDATED', + 'MEDIA_DELETED', 'SLICE_ADDED', 'SLICE_DELETED', 'SLICE_UPDATED', diff --git a/functions/functions_search_it.php b/functions/functions_search_it.php index 38fc189..b801622 100644 --- a/functions/functions_search_it.php +++ b/functions/functions_search_it.php @@ -262,9 +262,11 @@ function search_it_handle_extensionpoint($_ep){ break; case 'MEDIA_ADDED': + case 'MEDIA_DELETED': foreach( $includeColumns as $table => $columnArray){ if($table == rex::getTable('media')){ - foreach($columnArray as $column) {$tex[] = $table.$column; + foreach($columnArray as $column) { + // extension point liefert nicht die id des neuen/entfernten Mediums $search_it->indexColumn($table, $column); } } diff --git a/lib/search_it.php b/lib/search_it.php index dc9a125..58aac7f 100644 --- a/lib/search_it.php +++ b/lib/search_it.php @@ -393,35 +393,37 @@ public function unindexArticle($_id, $_clang = false) * * @return mixed */ - public function indexColumn($_table, $_column, $_idcol = false, $_id = false, $_start = false, $_count = false, $_where = false) + public function indexColumn($_table, $_column, $_idcol = false, $_id = false, $_start = false, $_count = false, $_wherecondition = false) { $delete = rex_sql::factory(); + $delete->setTable($this->tablePrefix . 'search_it_index'); $where = sprintf(" `ftable` = '%s' AND `fcolumn` = '%s' AND `texttype` = 'db_column'", $_table, $_column); //lus: reaktiviert damit einzeln gelöscht werden kann if (is_string($_idcol) AND ($_id !== false)) { $where .= sprintf(' AND fid = %d', $_id); + + } elseif (is_numeric($_start) AND is_numeric($_count)) { + $where .= ' LIMIT ' . $_start . ',' . $_count; } + $delete->setWhere($where); + + $cache = clone $delete; // delete from cache - $select = rex_sql::factory(); - $select->setTable($this->tablePrefix . 'search_it_index'); - $select->setWhere($where); $indexIds = array(); - if ($select->select('id')) { - foreach ($select->getArray() as $result) { + if ($cache->select('id')) { + foreach ($cache->getArray() as $result) { $indexIds[] = $result['id']; } $this->deleteCache($indexIds); } - // delete old data + lus: immer alle löschen - if ($_start === 0 || $_start === false || (is_string($_idcol) AND ($_id !== false))) { - $delete->setTable($this->tablePrefix . 'search_it_index'); - $delete->setWhere($where); + // delete from index $delete->delete(); - } + + // NEW $sql = rex_sql::factory(); // get primary key column(s) @@ -433,20 +435,15 @@ public function indexColumn($_table, $_column, $_idcol = false, $_id = false, $_ // index column $sql->flushValues(); $sql->setTable($_table); + $where = '1 '; if (is_string($_idcol) AND $_id) { $where .= sprintf(' AND (%s = %d)', $_idcol, $_id); - } - if (!empty($_where) AND is_string($_where)) { - // lus: sorry,muss ale neu schreiben, weil ich oben alle lösche - //$where .= ' AND (' . $_where . ')'; - } - - if (is_numeric($_start) AND is_numeric($_count)) { + } elseif (is_numeric($_start) AND is_numeric($_count)) { $where .= ' LIMIT ' . $_start . ',' . $_count; } - $sql->setWhere($where); + $count = false; if ($sql->select('*')) { @@ -485,7 +482,8 @@ public function indexColumn($_table, $_column, $_idcol = false, $_id = false, $_ } if (is_null($indexData['fid'])) { - $indexData['fid'] = $this->getMinFID(); + // keine id Spalte und keine primär schlüssel auch die views landen hier + $indexData['fid'] = $this->getMaxFID($_table); } if (array_key_exists('parent_id', $row)) { $indexData['catid'] = $row['parent_id']; @@ -543,9 +541,6 @@ public function indexColumn($_table, $_column, $_idcol = false, $_id = false, $_ $this->storeKeywords($keywords, false); - - } else { - return false; } return $count; @@ -815,6 +810,14 @@ private static function getMinFID() return ($minfid < 0) ? --$minfid : -1; } + private static function getMaxFID($_table) + { + $maxfid_sql = rex_sql::factory(); + $maxfid_result = $maxfid_sql->getArray('SELECT MAX(CONVERT(fid, SIGNED)) as maxfid FROM `' . rex::getTable('search_it_index') . '` WHERE ftable = "'.$_table.'" '); + $maxfid = intval($maxfid_result[0]['maxfid']); + + return ($maxfid > 0) ? ++$maxfid : 1; + } /** * Deletes the complete search index. * diff --git a/package.yml b/package.yml index 6c01b20..ffb8326 100644 --- a/package.yml +++ b/package.yml @@ -1,5 +1,5 @@ package: search_it -version: '6.6.3' +version: '6.6.4' author: Friends Of REDAXO supportpage: https://github.com/FriendsOfREDAXO/search_it diff --git a/plugins/autocomplete/package.yml b/plugins/autocomplete/package.yml index 43665d6..66d39b6 100644 --- a/plugins/autocomplete/package.yml +++ b/plugins/autocomplete/package.yml @@ -1,15 +1,15 @@ -package: search_it/autocomplete -version: '6.6.3' -author: Manétage - -title: 'translate:search_it_autocomplete_plugin_title' -description: 'translate:search_it_autocomplete_plugin' - -page: - perm: search_it[plugin:autocomplete] - title: 'translate:search_it_autocomplete_plugin_title' - icon: rex-icon fa-commenting - -requires: - php: - extensions: [gd] +package: search_it/autocomplete +version: '6.6.4' +author: Manétage + +title: 'translate:search_it_autocomplete_plugin_title' +description: 'translate:search_it_autocomplete_plugin' + +page: + perm: search_it[plugin:autocomplete] + title: 'translate:search_it_autocomplete_plugin_title' + icon: rex-icon fa-commenting + +requires: + php: + extensions: [gd] diff --git a/plugins/documentation/package.yml b/plugins/documentation/package.yml index c99cd4c..9e569a9 100644 --- a/plugins/documentation/package.yml +++ b/plugins/documentation/package.yml @@ -1,5 +1,5 @@ package: search_it/documentation -version: '6.6.3' +version: '6.6.4' author: Friends Of REDAXO title: 'translate:search_it_documentation_title' diff --git a/plugins/plaintext/package.yml b/plugins/plaintext/package.yml index 707a176..c681ef0 100644 --- a/plugins/plaintext/package.yml +++ b/plugins/plaintext/package.yml @@ -1,5 +1,5 @@ package: search_it/plaintext -version: '6.6.3' +version: '6.6.4' author: Friends Of REDAXO title: 'translate:search_it_plaintext_title' diff --git a/plugins/stats/package.yml b/plugins/stats/package.yml index 98439fb..f98dacc 100644 --- a/plugins/stats/package.yml +++ b/plugins/stats/package.yml @@ -1,5 +1,5 @@ package: search_it/stats -version: '6.6.3' +version: '6.6.4' author: Friends Of REDAXO title: 'translate:search_it_stats_plugin_title'