From 759cfa8deabf8b7ee649d7b2c91552b79a555af2 Mon Sep 17 00:00:00 2001
From: Nick Clemens <nick@bywatersolutions.com>
Date: Wed, 31 Jul 2019 20:14:34 +0000
Subject: [PATCH] Bug 23407: Don't process items for XSLT on details pages

To test:
1 - Add 1000 items to a record
    Go to biblio
    Edit items
    Add multiple copies of this item
    Add 1000 and confirm
    Wait..
2 - Load the record in staff client and OPAC, note how long it takes
    Press F12 in browser to open the console
    use the Network tab of the console
    note the load time
    refresh a few times to see average time
3 - Apply patch
4 - Restart all the things
5 - Reload the record in staff and opac
6 - Note decresed time
7 - Verify nothing on the page has changed

QA can grep the standard XSLT files for details pages for 'item' to note occurences do not use items information
---
 C4/XSLT.pm | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/C4/XSLT.pm b/C4/XSLT.pm
index 648bab28ab..cec410fe08 100644
--- a/C4/XSLT.pm
+++ b/C4/XSLT.pm
@@ -242,7 +242,12 @@ sub XSLTParse4Display {
 
     # grab the XML, run it through our stylesheet, push it out to the browser
     my $record = transformMARCXML4XSLT($biblionumber, $orig_record);
-    my $itemsxml  = buildKohaItemsNamespace($biblionumber, $hidden_items);
+    my $itemsxml;
+    if ( $xslsyspref eq "OPACXSLTDetailsDisplay" || $xslsyspref eq "XSLTDetailsDisplay" || $xslsyspref eq "XSLTResultsDisplay" ) {
+        $itemsxml = ""; #We don't use XSLT for items display on these pages
+    } else {
+        $itemsxml = buildKohaItemsNamespace($biblionumber, $hidden_items);
+    }
     my $xmlrecord = $record->as_xml(C4::Context->preference('marcflavour'));
 
     $variables ||= {};
-- 
2.11.0