Bugzilla – Attachment 149953 Details for
Bug 24975
Refactor database translations
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 24975: Fix db_t
Bug-24975-Fix-dbt.patch (text/plain), 2.25 KB, created by
Jonathan Druart
on 2023-04-20 12:45:01 UTC
(
hide
)
Description:
Bug 24975: Fix db_t
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2023-04-20 12:45:01 UTC
Size:
2.25 KB
patch
obsolete
>From f9755c5a12beda5d1529e4ce84b7b6a940c7afd7 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Wed, 30 Mar 2022 12:53:43 +0100 >Subject: [PATCH] Bug 24975: Fix db_t > >The query here is difficult.. I wanted to return FULL LEFT JOIN, but >filtering on the joined data (l10n_targets.language) means we drop the >l10n_source rows where there are no corresponding l10n_targets with >language code. > >I tried setting `l10n_targets.language => [ $language, undef ]` to >include null values, but that doesn't work either. I then tried coming >up with a correlate subquery instead of the join and couldn't get dbic >to play nicely there either. > >As such, I've fallen back to multiple queries over the relationship.. >I'm sure we can do better... but this works for now. >--- > Koha/I18N.pm | 25 ++++++++++++------------- > 1 file changed, 12 insertions(+), 13 deletions(-) > >diff --git a/Koha/I18N.pm b/Koha/I18N.pm >index cd7c4570a71..a5f517d6ace 100644 >--- a/Koha/I18N.pm >+++ b/Koha/I18N.pm >@@ -250,22 +250,21 @@ sub db_t { > my $translations = $cache->get_from_cache($cache_key); > unless ($translations) { > my $schema = Koha::Database->new->schema; >- my $rs = $schema->resultset('L10nSource'); >+ my $source_rs = $schema->resultset('L10nSource'); > >- my @targets = $rs->search( >+ my $sources = $source_rs->search( > { >- 'group' => $group, >- 'l10n_targets.language' => $language, >- }, >- { >- join => 'l10n_targets', >- prefetch => 'l10n_targets', >- result_class => 'DBIx::Class::ResultClass::HashRefInflator', >- }, >+ 'group' => $group >+ } > ); >- $translations = >- { map { $_->{key} => $_->{l10n_targets}->[0]{translation} //= $_->{text} } >- @targets }; >+ while ( my $source = $sources->next ) { >+ my $translation = >+ $source->l10n_targets->search( { language => $language } ); >+ $translations->{ $source->key } = >+ $translation->count >+ ? $translation->first->translation >+ : $source->text; >+ } > > $cache->set_in_cache($cache_key, $translations); > } >-- >2.25.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 24975
:
101703
|
101786
|
102387
|
102388
|
102513
|
102514
|
102688
|
102701
|
132388
|
132508
|
132509
|
132510
|
132511
|
132512
|
132513
|
132514
|
132515
|
132516
|
132517
|
132518
|
132519
|
132520
|
132521
|
132522
|
132523
|
132524
|
132525
|
132526
|
132527
|
132528
|
132529
|
132530
|
132531
|
132532
|
132533
|
132546
|
132562
|
132563
|
132564
|
132565
|
132566
|
132567
|
132568
|
132569
|
132570
|
132571
|
132572
|
132573
|
132574
|
132575
|
149941
|
149942
|
149943
|
149944
|
149945
|
149946
|
149947
|
149948
|
149949
|
149950
|
149951
|
149952
| 149953 |
149954
|
149956
|
149957
|
150015
|
150033
|
150034