Bugzilla – Attachment 91308 Details for
Bug 17885
Koha::SearchEngine::Elasticsearch->reset_elasticsearch_mappings throws DBD::mysql Duplicate entry exceptions
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 17885: Koha::SearchEngine::Elasticsearch->reset_elasticsearch_mappings throws DBD::mysql Duplicate entry exceptions
0001-Bug-17885-Koha-SearchEngine-Elasticsearch-reset_elas.patch (text/plain), 3.10 KB, created by
Johanna Räisä
on 2019-07-05 05:23:50 UTC
(
hide
)
Description:
Bug 17885: Koha::SearchEngine::Elasticsearch->reset_elasticsearch_mappings throws DBD::mysql Duplicate entry exceptions
Filename:
MIME Type:
Creator:
Johanna Räisä
Created:
2019-07-05 05:23:50 UTC
Size:
3.10 KB
patch
obsolete
>From 9e84de748a5d46dd3211a294a50769ab03d33527 Mon Sep 17 00:00:00 2001 >From: =?UTF-8?q?Joonas=20Kylm=C3=A4l=C3=A4?= <joonas.kylmala@helsinki.fi> >Date: Fri, 31 Aug 2018 15:32:20 +0300 >Subject: [PATCH] Bug 17885: > Koha::SearchEngine::Elasticsearch->reset_elasticsearch_mappings throws > DBD::mysql Duplicate entry exceptions > >When executing >Koha::SearchEngine::Elasticsearch->reset_elasticsearch_mappings() >against populated search engine mappings tables, one gets this >exception: > >DBD::mysql::st execute failed: Duplicate entry '388-73' for key >'PRIMARY' [for Statement \"INSERT INTO `search_marc_to_field` ( `facet`, >`search_field_id`, `search_marc_map_id`, `sort`, `suggestible`) VALUES ( >?, ?, ?, ?, ? )\" with ParamValues: 0='', 1='73', 2='388', 3=undef, >4=''] at /usr/share/perl5/DBIx/Class/Storage/DBI.pm line >1834.\nDBIx::Class::Storage::DBI::_dbh_execute(): Duplicate entry >'388-73' for key 'PRIMARY' at /home/koha/Koha/Koha/SearchField.pm line >38" > >This patch fixes this, by first deleting all entries, then adding the >default ones. > >If a subroutine says reset_elasticsearch_mappings(), I expect it to >reset the elasticsearch mappings without errors. When writing tests it >is better to call that one subroutine reset_elasticsearch_mappings >instead of the bunch of code in >admin/searchengine/elasticsearch/mappings.pl?op=reset_confirmed >Also this promotes code reuse. > >TEST PLAN: > >a. perl -e 'use Koha::SearchEngine::Elasticsearch; Koha::SearchEngine::Elasticsearch->reset_elasticsearch_mappings' >b. Run misc/devel/populate_db.pl on an already populated DB and you eventually >face this problem. > >After this patch, step a. works. > >This patch is adapted from the original patch made by Olli-Antti >Kivilahti <olli-antti.kivilahti@jns.fi>. > >Signed-off-by: Johanna Raisa <johanna.raisa@gmail.com> >--- > Koha/SearchEngine/Elasticsearch.pm | 3 +++ > admin/searchengine/elasticsearch/mappings.pl | 2 -- > 2 files changed, 3 insertions(+), 2 deletions(-) > >diff --git a/Koha/SearchEngine/Elasticsearch.pm b/Koha/SearchEngine/Elasticsearch.pm >index 8a52d574ec..6e778d1b52 100644 >--- a/Koha/SearchEngine/Elasticsearch.pm >+++ b/Koha/SearchEngine/Elasticsearch.pm >@@ -282,6 +282,9 @@ sub reset_elasticsearch_mappings { > $mappings_yaml ||= C4::Context->config('intranetdir') . '/admin/searchengine/elasticsearch/mappings.yaml'; > my $indexes = LoadFile( $mappings_yaml ); > >+ Koha::SearchMarcMaps->delete; >+ Koha::SearchFields->delete; >+ > while ( my ( $index_name, $fields ) = each %$indexes ) { > while ( my ( $field_name, $data ) = each %$fields ) { > my $field_type = $data->{type}; >diff --git a/admin/searchengine/elasticsearch/mappings.pl b/admin/searchengine/elasticsearch/mappings.pl >index f91399aa9d..62fdb8bd29 100755 >--- a/admin/searchengine/elasticsearch/mappings.pl >+++ b/admin/searchengine/elasticsearch/mappings.pl >@@ -143,8 +143,6 @@ if ( $op eq 'edit' ) { > } > } > elsif( $op eq 'reset_confirmed' ) { >- Koha::SearchMarcMaps->delete; >- Koha::SearchFields->delete; > Koha::SearchEngine::Elasticsearch->reset_elasticsearch_mappings; > push @messages, { type => 'message', code => 'success_on_reset' }; > } >-- >2.17.1 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 17885
:
58825
|
58940
|
58941
|
69338
|
78327
|
91308
|
97198