Commit 098699bc authored by Cecilia Vela Gurovic's avatar Cecilia Vela Gurovic
Browse files

Bug 1785985: remove prefix from db table before adding to ES queue

behatnotneeded

Change-Id: I860ebcc892361a7af6b2edeed2d9f7a9b4f42d86
parent 51d25e53
...@@ -1103,9 +1103,6 @@ function get_table_from_query($sql) { ...@@ -1103,9 +1103,6 @@ function get_table_from_query($sql) {
$idsql = 'SELECT * FROM ' . $matches[2]; $idsql = 'SELECT * FROM ' . $matches[2];
$type = 'update'; $type = 'update';
} }
if (get_config('dbprefix')) {
$table = str_replace(get_config('dbprefix'), $table, '');
}
return array($type, $table, $idsql, $bindoffset); return array($type, $table, $idsql, $bindoffset);
} }
...@@ -1290,6 +1287,9 @@ function table_need_trigger($table) { ...@@ -1290,6 +1287,9 @@ function table_need_trigger($table) {
} }
function pseudo_trigger($table, $data, $id, $savetype = 'insert') { function pseudo_trigger($table, $data, $id, $savetype = 'insert') {
if ($dbprefix = get_config('dbprefix')) {
$table = preg_replace('/' . $dbprefix . '/', '', $table);
}
if ($type = table_need_trigger($table)) { if ($type = table_need_trigger($table)) {
if ($type == 'es') { if ($type == 'es') {
$artefacttype = ($table == 'artefact' && isset($data->artefacttype)) ? $data->artefacttype : null; $artefacttype = ($table == 'artefact' && isset($data->artefacttype)) ? $data->artefacttype : null;
......
...@@ -2266,7 +2266,9 @@ class ElasticsearchIndexing { ...@@ -2266,7 +2266,9 @@ class ElasticsearchIndexing {
* Add to queue - a replacement for the triggers * Add to queue - a replacement for the triggers
*/ */
public static function add_to_queue($id, $table, $artefacttype=null) { public static function add_to_queue($id, $table, $artefacttype=null) {
if ($dbprefix = get_config('dbprefix')) {
$table = preg_replace('/' . $dbprefix . '/', '', $table);
}
$artefacttypes_str = self::artefacttypes_filter_string(); $artefacttypes_str = self::artefacttypes_filter_string();
if ($table == 'view_artefact') { if ($table == 'view_artefact') {
$sql = "INSERT INTO {search_elasticsearch_queue} (itemid, type, artefacttype) $sql = "INSERT INTO {search_elasticsearch_queue} (itemid, type, artefacttype)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment