Bugzilla – Attachment 100393 Details for
Bug 24830
dbic_merge_prefetch is not handling recursive cases correctly
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 24830: Fix parse_prefetch recursion and +count cases
Bug-24830-Fix-parseprefetch-recursion-and-count-ca.patch (text/plain), 2.53 KB, created by
Agustín Moyano
on 2020-03-09 16:10:50 UTC
(
hide
)
Description:
Bug 24830: Fix parse_prefetch recursion and +count cases
Filename:
MIME Type:
Creator:
Agustín Moyano
Created:
2020-03-09 16:10:50 UTC
Size:
2.53 KB
patch
obsolete
>From 026ab29f307d0ee7dc6083a24356286a8b9ad8cb Mon Sep 17 00:00:00 2001 >From: Agustin Moyano <agustinmoyano@theke.io> >Date: Mon, 9 Mar 2020 12:05:03 -0300 >Subject: [PATCH] Bug 24830: Fix parse_prefetch recursion and +count cases > >When a child of a prefetched element wasn't found on element's >prefetch_whitelist, no prefetch element was returned.. including element >it self. Now we return element's name if no child was found. > >Also, embeded keys that ended with +count where taken literaly. Now we >search the correct key by stripping _count of embedded element if it was >declared as "is_count" >--- > Koha/REST/Plugin/Query.pm | 22 +++++++++++++--------- > 1 file changed, 13 insertions(+), 9 deletions(-) > >diff --git a/Koha/REST/Plugin/Query.pm b/Koha/REST/Plugin/Query.pm >index 46296e638a..ea6695ff37 100644 >--- a/Koha/REST/Plugin/Query.pm >+++ b/Koha/REST/Plugin/Query.pm >@@ -124,7 +124,7 @@ Generates the DBIC prefetch attribute based on embedded relations, and merges in > return unless defined $embed; > > my @prefetches; >- foreach my $key (keys %{$embed}) { >+ foreach my $key (sort keys(%{$embed})) { > my $parsed = _parse_prefetch($key, $embed, $result_set); > push @prefetches, $parsed if defined $parsed; > } >@@ -353,20 +353,24 @@ sub _merge_embed { > sub _parse_prefetch { > my ( $key, $embed, $result_set) = @_; > >- return unless exists $result_set->prefetch_whitelist->{$key}; >+ my $pref_key = $key; >+ $pref_key =~ s/_count$// if $embed->{$key}->{is_count}; >+ return unless exists $result_set->prefetch_whitelist->{$pref_key}; > >- my $ko_class = $result_set->prefetch_whitelist->{$key}; >- return $key unless defined $embed->{$key}->{children} && defined $ko_class; >+ my $ko_class = $result_set->prefetch_whitelist->{$pref_key}; >+ return $pref_key unless defined $embed->{$key}->{children} && defined $ko_class; > >- my $prefetch = {}; >- foreach my $child (keys %{$embed->{$key}->{children}}) { >+ my @prefetches; >+ foreach my $child (sort keys(%{$embed->{$key}->{children}})) { > my $parsed = _parse_prefetch($child, $embed->{$key}->{children}, $ko_class->new); >- $prefetch->{$key} = $parsed if defined $parsed; >+ push @prefetches, $parsed if defined $parsed; > } > >- return unless scalar(keys %{$prefetch}); >+ return $pref_key unless scalar(@prefetches); > >- return $prefetch; >+ return {$pref_key => $prefetches[0]} if scalar(@prefetches) eq 1; >+ >+ return {$pref_key => \@prefetches}; > } > > sub _from_api_param { >-- >2.25.0
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 24830
:
100393
|
100664
|
100665
|
100666
|
100689
|
100690
|
101089
|
101090