Bugzilla – Attachment 126817 Details for
Bug 11175
Show the parent record's component parts in the detailed views
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 11175: (QA follow-up) Do not fetch twice
Bug-11175-QA-follow-up-Do-not-fetch-twice.patch (text/plain), 8.24 KB, created by
Marcel de Rooy
on 2021-10-25 09:46:46 UTC
(
hide
)
Description:
Bug 11175: (QA follow-up) Do not fetch twice
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2021-10-25 09:46:46 UTC
Size:
8.24 KB
patch
obsolete
>From 160aafa6ad199e55bf3f520569fb2ba5c1b49c5c Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Sun, 24 Oct 2021 12:11:02 +0000 >Subject: [PATCH] Bug 11175: (QA follow-up) Do not fetch twice >Content-Type: text/plain; charset=utf-8 > >We were fetching components in the first call of XSLTParse4Display >(opac-detail around L220). And again (opac-detail around L660). >Same for catalogue/detail.pl. >Moving the XSLT block in both scripts and removing the code from >XSLT.pm which again makes the tests obsolete. > >Not hiding the link when there are components. Might be helpful too. > >Also fixing biblionumber in the XSLTParse4Display call for parts. > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >--- > C4/XSLT.pm | 18 ------------- > catalogue/detail.pl | 36 +++++++++++++------------ > opac/opac-detail.pl | 65 +++++++++++++++++++++------------------------ > 3 files changed, 50 insertions(+), 69 deletions(-) > >diff --git a/C4/XSLT.pm b/C4/XSLT.pm >index d133cdf675..125f887cb0 100644 >--- a/C4/XSLT.pm >+++ b/C4/XSLT.pm >@@ -281,24 +281,6 @@ sub XSLTParse4Display { > } > } > >- # possibly show analytics link in Detail views >- if ( $xslsyspref eq "OPACXSLTDetailsDisplay" || $xslsyspref eq "XSLTDetailsDisplay" ) { >- $biblio //= Koha::Biblios->find( $biblionumber ); >- my $components = $biblio->get_marc_components(); >- $variables->{show_analytics_link} = ( scalar @{$components} == 0 ) ? 0 : 1; >- >- my $showcomp = C4::Context->preference('ShowComponentRecords'); >- if ( >- $variables->{show_analytics_link} >- && ( $showcomp eq 'both' >- || ( $showcomp eq 'staff' && $xslsyspref !~ m/OPAC/ ) >- || ( $showcomp eq 'opac' && $xslsyspref =~ m/OPAC/ ) ) >- ) >- { >- $variables->{show_analytics_link} = 0; >- } >- } >- > my $varxml = "<variables>\n"; > while (my ($key, $value) = each %$variables) { > $varxml .= "<variable name=\"$key\">$value</variable>\n"; >diff --git a/catalogue/detail.pl b/catalogue/detail.pl >index 8eae1832b0..3846777ebe 100755 >--- a/catalogue/detail.pl >+++ b/catalogue/detail.pl >@@ -123,22 +123,6 @@ my $fw = GetFrameworkCode($biblionumber); > my $showallitems = $query->param('showallitems'); > my $marcflavour = C4::Context->preference("marcflavour"); > >-{ >- # XSLT processing of some stuff >- >- $template->param( >- XSLTDetailsDisplay => '1', >- XSLTBloc => XSLTParse4Display( >- { >- biblionumber => $biblionumber, >- record => $record, >- xsl_syspref => "XSLTDetailsDisplay", >- fix_amps => 1, >- } >- ), >- ); >-} >- > $template->param( 'SpineLabelShowPrintOnBibDetails' => C4::Context->preference("SpineLabelShowPrintOnBibDetails") ); > > # Catch the exception as Koha::Biblio::Metadata->record can explode if the MARCXML is invalid >@@ -213,16 +197,19 @@ foreach my $subscription (@subscriptions) { > > # Get component parts details > my $showcomp = C4::Context->preference('ShowComponentRecords'); >+my $show_analytics; > if ( $showcomp eq 'both' || $showcomp eq 'staff' ) { > if ( my $components = $biblio->get_marc_components(C4::Context->preference('MaxComponentRecords')) ) { >+ $show_analytics = 1; # just show link when having results > my $parts; > for my $part ( @{$components} ) { > $part = C4::Search::new_record_from_zebra( 'biblioserver', $part ); >+ my $id = Koha::SearchEngine::Search::extract_biblionumber( $part ); > > push @{$parts}, > XSLTParse4Display( > { >- biblionumber => $biblionumber, >+ biblionumber => $id, > record => $part, > xsl_syspref => "XSLTResultsDisplay", > fix_amps => 1, >@@ -232,8 +219,23 @@ if ( $showcomp eq 'both' || $showcomp eq 'staff' ) { > $template->param( ComponentParts => $parts ); > $template->param( ComponentPartsQuery => $biblio->get_components_query ); > } >+} else { # check if we should show analytics anyway >+ $show_analytics = 1 if @{$biblio->get_marc_components(1)}; # count matters here, results does not > } > >+# XSLT processing of some stuff >+my $xslt_variables = { show_analytics_link => $show_analytics }; >+$template->param( >+ XSLTDetailsDisplay => '1', >+ XSLTBloc => XSLTParse4Display({ >+ biblionumber => $biblionumber, >+ record => $record, >+ xsl_syspref => "XSLTDetailsDisplay", >+ fix_amps => 1, >+ xslt_variables => $xslt_variables, >+ }), >+); >+ > # Get acquisition details > if ( C4::Context->preference('AcquisitionDetails') ) { > my $orders = Koha::Acquisition::Orders->search( >diff --git a/opac/opac-detail.pl b/opac/opac-detail.pl >index eb3124a06d..aed49fde16 100755 >--- a/opac/opac-detail.pl >+++ b/opac/opac-detail.pl >@@ -195,38 +195,6 @@ SetUTF8Flag($record); > my $marcflavour = C4::Context->preference("marcflavour"); > my $ean = GetNormalizedEAN( $record, $marcflavour ); > >-{ >- my $variables = { >- anonymous_session => ($borrowernumber) ? 0 : 1, >- }; >- >- my $lang = C4::Languages::getlanguage(); >- my @plugin_responses = Koha::Plugins->call( >- 'opac_detail_xslt_variables', >- { >- biblio_id => $biblionumber, >- lang => $lang, >- patron_id => $borrowernumber >- >- } >- ); >- for my $plugin_variables ( @plugin_responses ) { >- $variables = { %$variables, %$plugin_variables }; >- } >- >- $template->param( >- XSLTBloc => XSLTParse4Display( >- { >- biblionumber => $biblionumber, >- record => $record, >- xsl_syspref => 'OPACXSLTDetailsDisplay', >- fix_amps => 1, >- xslt_variables => $variables >- } >- ), >- ); >-} >- > my $OpacBrowseResults = C4::Context->preference("OpacBrowseResults"); > > # We look for the busc param to build the simple paging from the search >@@ -659,16 +627,18 @@ my $max_items_to_display = C4::Context->preference('OpacMaxItemsToDisplay') // 5 > > # Get component parts details > my $showcomp = C4::Context->preference('ShowComponentRecords'); >-my $parts; >+my ( $parts, $show_analytics ); > if ( $showcomp eq 'both' || $showcomp eq 'opac' ) { > if ( my $components = $biblio->get_marc_components(C4::Context->preference('MaxComponentRecords')) ) { >+ $show_analytics = 1; # just show link when having results > for my $part ( @{$components} ) { > $part = C4::Search::new_record_from_zebra( 'biblioserver', $part ); >+ my $id = Koha::SearchEngine::Search::extract_biblionumber( $part ); > > push @{$parts}, > XSLTParse4Display( > { >- biblionumber => $biblionumber, >+ biblionumber => $id, > record => $part, > xsl_syspref => 'OPACXSLTResultsDisplay', > fix_amps => 1, >@@ -678,8 +648,35 @@ if ( $showcomp eq 'both' || $showcomp eq 'opac' ) { > $template->param( ComponentParts => $parts ); > $template->param( ComponentPartsQuery => $biblio->get_components_query ); > } >+} else { # check if we should show analytics anyway >+ $show_analytics = 1 if @{$biblio->get_marc_components(1)}; # count matters here, results does not > } > >+# XSLT processing of some stuff >+my $variables = {}; >+my @plugin_responses = Koha::Plugins->call( >+ 'opac_detail_xslt_variables', >+ { >+ biblio_id => $biblionumber, >+ lang => C4::Languages::getlanguage(), >+ patron_id => $borrowernumber, >+ }, >+); >+for my $plugin_variables ( @plugin_responses ) { >+ $variables = { %$variables, %$plugin_variables }; >+} >+$variables->{anonymous_session} = $borrowernumber ? 0 : 1; >+$variables->{show_analytics_link} = $show_analytics; >+$template->param( >+ XSLTBloc => XSLTParse4Display({ >+ biblionumber => $biblionumber, >+ record => $record, >+ xsl_syspref => 'OPACXSLTDetailsDisplay', >+ fix_amps => 1, >+ xslt_variables => $variables, >+ }), >+); >+ > # Get items on order > my ( @itemnumbers_on_order ); > if ( C4::Context->preference('OPACAcquisitionDetails' ) ) { >-- >2.20.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 11175
:
22612
|
22649
|
23049
|
24788
|
24789
|
24790
|
24791
|
26402
|
26403
|
26404
|
26405
|
26766
|
26767
|
78022
|
78023
|
78024
|
79687
|
79803
|
79809
|
79810
|
105631
|
105641
|
105703
|
105706
|
105707
|
106692
|
112838
|
112839
|
112840
|
112841
|
112846
|
112847
|
112851
|
112852
|
112853
|
112854
|
112855
|
112856
|
112857
|
113649
|
113650
|
113962
|
113964
|
114326
|
114327
|
114328
|
114329
|
114330
|
114331
|
114332
|
114333
|
114334
|
116819
|
116820
|
116821
|
116822
|
116823
|
116824
|
116825
|
116826
|
116827
|
116828
|
119499
|
119506
|
120206
|
122707
|
122708
|
122709
|
122710
|
122711
|
122712
|
122713
|
122714
|
122715
|
122716
|
122717
|
122718
|
123081
|
123082
|
123083
|
123084
|
123085
|
123086
|
123087
|
123088
|
123089
|
123090
|
123091
|
123092
|
123093
|
123406
|
123410
|
123508
|
123509
|
123510
|
123511
|
123512
|
123513
|
123514
|
123515
|
123516
|
123517
|
123518
|
123519
|
123520
|
123521
|
123522
|
123523
|
123524
|
123541
|
123542
|
123543
|
123544
|
123545
|
123546
|
123547
|
123548
|
123549
|
123550
|
123551
|
123552
|
123553
|
123554
|
123555
|
123556
|
123557
|
123562
|
123564
|
123569
|
123570
|
123571
|
123572
|
123573
|
123574
|
123582
|
123583
|
123608
|
123609
|
123611
|
123612
|
123613
|
123614
|
123617
|
123618
|
123619
|
123620
|
123621
|
123622
|
123623
|
123624
|
123625
|
123626
|
123627
|
123628
|
123629
|
123630
|
123631
|
123632
|
123633
|
123634
|
123635
|
123636
|
123637
|
123638
|
123736
|
123737
|
123738
|
123739
|
123740
|
123741
|
123742
|
123743
|
123744
|
123745
|
123746
|
123747
|
123748
|
123749
|
123750
|
123751
|
123752
|
123753
|
123754
|
123755
|
123756
|
124134
|
124135
|
124136
|
124137
|
124138
|
124139
|
124140
|
124141
|
124142
|
124143
|
124144
|
124145
|
124146
|
124147
|
124148
|
124149
|
124150
|
124151
|
124152
|
124153
|
124154
|
124155
|
124382
|
124383
|
124384
|
124385
|
124386
|
124387
|
124388
|
124389
|
124390
|
124391
|
124392
|
124393
|
124394
|
124395
|
124396
|
124397
|
124398
|
124399
|
124400
|
124401
|
124402
|
124403
|
124404
|
124534
|
124535
|
124536
|
124537
|
124538
|
124539
|
124540
|
124541
|
124542
|
124544
|
124545
|
124546
|
124547
|
124548
|
124549
|
124550
|
124551
|
124552
|
124553
|
124554
|
124555
|
124556
|
124557
|
126057
|
126058
|
126059
|
126060
|
126061
|
126062
|
126063
|
126064
|
126065
|
126066
|
126067
|
126068
|
126069
|
126070
|
126071
|
126072
|
126073
|
126074
|
126075
|
126076
|
126077
|
126078
|
126079
|
126080
|
126081
|
126084
|
126441
|
126442
|
126443
|
126687
|
126688
|
126689
|
126690
|
126692
|
126693
|
126694
|
126695
|
126696
|
126697
|
126698
|
126699
|
126700
|
126701
|
126702
|
126703
|
126704
|
126705
|
126706
|
126707
|
126708
|
126709
|
126710
|
126711
|
126712
|
126713
|
126714
|
126715
|
126716
|
126717
|
126718
|
126719
|
126720
|
126721
|
126722
|
126723
|
126724
|
126725
|
126726
|
126727
|
126728
|
126729
|
126730
|
126731
|
126732
|
126733
|
126734
|
126735
|
126736
|
126737
|
126738
|
126739
|
126740
|
126741
|
126742
|
126743
|
126744
|
126745
|
126816
|
126817
|
126869
|
126870
|
126871
|
126872
|
126873
|
126874
|
126875
|
126876
|
126877
|
126878
|
126879
|
126880
|
126881
|
126882
|
126883
|
126884
|
126885
|
126886
|
126887
|
126888
|
126889
|
126890
|
126891
|
126892
|
126893
|
126894
|
126895
|
126897
|
126898
|
126904
|
126911
|
126912
|
126913