Bug 30847: Avoid fetching biblio object
[koha.git] / opac / opac-reserve.pl
1 #!/usr/bin/perl
2
3
4 # Copyright Katipo Communications 2002
5 # Copyright Koha Development team 2012
6 #
7 # This file is part of Koha.
8 #
9 # Koha is free software; you can redistribute it and/or modify it
10 # under the terms of the GNU General Public License as published by
11 # the Free Software Foundation; either version 3 of the License, or
12 # (at your option) any later version.
13 #
14 # Koha is distributed in the hope that it will be useful, but
15 # WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
18 #
19 # You should have received a copy of the GNU General Public License
20 # along with Koha; if not, see <http://www.gnu.org/licenses>.
21
22 use Modern::Perl;
23
24 use CGI qw ( -utf8 );
25 use C4::Auth qw( get_template_and_user );
26 use C4::Koha qw( getitemtypeimagelocation getitemtypeimagesrc );
27 use C4::Circulation qw( GetBranchItemRule );
28 use C4::Reserves qw( CanItemBeReserved CanBookBeReserved AddReserve GetReservesControlBranch ItemsAnyAvailableAndNotRestricted IsAvailableForItemLevelRequest );
29 use C4::Biblio qw( GetBiblioData GetFrameworkCode );
30 use C4::Output qw( output_html_with_http_headers );
31 use C4::Context;
32 use C4::Members;
33 use C4::Overdues;
34
35 use Koha::AuthorisedValues;
36 use Koha::Biblios;
37 use Koha::CirculationRules;
38 use Koha::Items;
39 use Koha::ItemTypes;
40 use Koha::Checkouts;
41 use Koha::Libraries;
42 use Koha::Patrons;
43 use List::MoreUtils qw( uniq );
44
45 my $maxreserves = C4::Context->preference("maxreserves");
46
47 my $query = CGI->new;
48
49 # if OPACHoldRequests (for placing holds) is disabled, leave immediately
50 if ( ! C4::Context->preference('OPACHoldRequests') ) {
51     print $query->redirect("/cgi-bin/koha/errors/404.pl");
52     exit;
53 }
54
55 my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
56     {
57         template_name   => "opac-reserve.tt",
58         query           => $query,
59         type            => "opac",
60     }
61 );
62
63 my $patron = Koha::Patrons->find( $borrowernumber, { prefetch => ['categorycode'] } );
64 my $category = $patron->category;
65
66 my $can_place_hold_if_available_at_pickup = C4::Context->preference('OPACHoldsIfAvailableAtPickup');
67 unless ( $can_place_hold_if_available_at_pickup ) {
68     my @patron_categories = split ',', C4::Context->preference('OPACHoldsIfAvailableAtPickupExceptions');
69     if ( @patron_categories ) {
70         my $categorycode = $patron->categorycode;
71         $can_place_hold_if_available_at_pickup = grep { $_ eq $categorycode } @patron_categories;
72     }
73 }
74
75 # check if this user can place a reserve, -1 means use sys pref, 0 means dont block, 1 means block
76 if ( $category->effective_BlockExpiredPatronOpacActions ) {
77
78     if ( $patron->is_expired ) {
79
80         # cannot reserve, their card has expired and the rules set mean this is not allowed
81         $template->param( message => 1, expired_patron => 1 );
82         output_html_with_http_headers $query, $cookie, $template->output, undef, { force_no_caching => 1 };
83         exit;
84     }
85 }
86
87 # Pass through any reserve charge
88 my $reservefee = $category->reservefee;
89 if ( $reservefee > 0){
90     $template->param( RESERVE_CHARGE => $reservefee);
91 }
92
93 my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search_with_localization->unblessed } };
94
95 # There are two ways of calling this script, with a single biblio num
96 # or multiple biblio nums.
97 my $biblionumbers = $query->param('biblionumbers');
98 my $reserveMode = $query->param('reserve_mode');
99 if ($reserveMode && ($reserveMode eq 'single')) {
100     my $bib = $query->param('single_bib');
101     $biblionumbers = "$bib/";
102 }
103 if (! $biblionumbers) {
104     $biblionumbers = $query->param('biblionumber');
105 }
106
107 if ((! $biblionumbers) && (! $query->param('place_reserve'))) {
108     $template->param(message=>1, no_biblionumber=>1);
109     output_html_with_http_headers $query, $cookie, $template->output, undef, { force_no_caching => 1 };
110     exit;
111 }
112
113 # Pass the numbers to the page so they can be fed back
114 # when the hold is confirmed. TODO: Not necessary?
115 $template->param( biblionumbers => $biblionumbers );
116
117 # Each biblio number is suffixed with '/', e.g. "1/2/3/"
118 my @biblionumbers = split /\//, $biblionumbers;
119 if (($#biblionumbers < 0) && (! $query->param('place_reserve'))) {
120     # TODO: New message?
121     $template->param(message=>1, no_biblionumber=>1);
122     output_html_with_http_headers $query, $cookie, $template->output, undef, { force_no_caching => 1 };
123     exit;
124 }
125
126
127 # pass the pickup branch along....
128 my $branch = $query->param('branch') || $patron->branchcode || C4::Context->userenv->{branch} || '' ;
129 $template->param( branch => $branch );
130
131 #
132 #
133 # Build hashes of the requested biblio(item)s and items.
134 #
135 #
136
137 my %biblioDataHash; # Hash of biblionumber to biblio/biblioitems record.
138 foreach my $biblioNumber (@biblionumbers) {
139
140     my $biblioData = GetBiblioData($biblioNumber);
141     $biblioDataHash{$biblioNumber} = $biblioData;
142
143     my $biblio = Koha::Biblios->find( $biblioNumber );
144     next unless $biblio;
145
146     my $marcrecord = $biblio->metadata->record;
147
148     my $items = Koha::Items->search_ordered(
149         [
150             biblionumber => $biblioNumber,
151             'me.itemnumber' => {
152                 -in => [
153                     $biblio->host_items->get_column('itemnumber')
154                 ]
155             }
156         ],
157         { prefetch => [ 'issue', 'homebranch', 'holdingbranch' ] }
158     )->filter_by_visible_in_opac({ patron => $patron });
159
160     $biblioData->{items} = [$items->as_list]; # FIXME Potentially a lot in memory here!
161
162     # Compute the priority rank.
163     $biblioData->{object} = $biblio;
164     my $reservecount = $biblio->holds->search({ found => [ {"!=" => "W"},undef] })->count;
165     $biblioData->{reservecount} = $reservecount;
166     $biblioData->{rank} = $reservecount + 1;
167 }
168
169 #
170 #
171 # If this is the second time through this script, it
172 # means we are carrying out the hold request, possibly
173 # with a specific item for each biblionumber.
174 #
175 #
176 if ( $query->param('place_reserve') ) {
177     my $reserve_cnt = 0;
178     if ($maxreserves) {
179         $reserve_cnt = $patron->holds->count;
180     }
181
182     # List is composed of alternating biblio/item/branch
183     my $selectedItems = $query->param('selecteditems');
184
185     if ($query->param('reserve_mode') eq 'single') {
186         # This indicates non-JavaScript mode, so there was
187         # only a single biblio number selected.
188         my $bib = $query->param('single_bib');
189         my $item = $query->param("checkitem_$bib");
190         if ($item eq 'any') {
191             $item = '';
192         }
193         my $branch = $query->param('branch');
194         $selectedItems = "$bib/$item/$branch/";
195     }
196
197     $selectedItems =~ s!/$!!;
198     my @selectedItems = split /\//, $selectedItems, -1;
199
200     # Make sure there is a biblionum/itemnum/branch triplet for each item.
201     # The itemnum can be 'any', meaning next available.
202     my $selectionCount = @selectedItems;
203     if (($selectionCount == 0) || (($selectionCount % 3) != 0)) {
204         $template->param(message=>1, bad_data=>1);
205         output_html_with_http_headers $query, $cookie, $template->output, undef, { force_no_caching => 1 };
206         exit;
207     }
208
209     my $failed_holds = 0;
210     while (@selectedItems) {
211         my $biblioNum = shift(@selectedItems);
212         my $itemNum   = shift(@selectedItems);
213         my $branch    = shift(@selectedItems);    # i.e., branch code, not name
214
215         my $canreserve = 0;
216
217         my $singleBranchMode = Koha::Libraries->search->count == 1;
218         if ( $singleBranchMode || ! C4::Context->preference("OPACAllowUserToChooseBranch") )
219         {    # single branch mode or disabled user choosing
220             $branch = $patron->branchcode;
221         }
222
223         # FIXME We shouldn't need to fetch the item here
224         my $item = $itemNum ? Koha::Items->find( $itemNum ) : undef;
225         # When choosing a specific item, the default pickup library should be dictated by the default hold policy
226         if ( ! C4::Context->preference("OPACAllowUserToChooseBranch") && $item ) {
227             my $type = $item->effective_itemtype;
228             my $rule = GetBranchItemRule( $patron->branchcode, $type );
229
230             if ( $rule->{hold_fulfillment_policy} eq 'any' || $rule->{hold_fulfillment_policy} eq 'patrongroup' ) {
231                 $branch = $patron->branchcode;
232             } elsif ( $rule->{hold_fulfillment_policy} eq 'holdgroup' ){
233                 $branch = $item->homebranch;
234             } else {
235                 my $policy = $rule->{hold_fulfillment_policy};
236                 $branch = $item->$policy;
237             }
238         }
239
240         # if we have an item, we are placing the hold on the item's bib, in case of analytics
241         if ( $item ) {
242             $biblioNum = $item->biblionumber;
243         }
244
245         my $biblioData = $biblioDataHash{$biblioNum};
246         my $found;
247
248         # Check for user supplied reserve date
249         my $startdate;
250         if (   C4::Context->preference('AllowHoldDateInFuture')
251             && C4::Context->preference('OPACAllowHoldDateInFuture') )
252         {
253             $startdate = $query->param("reserve_date_$biblioNum");
254         }
255
256         my $patron_expiration_date = $query->param("expiration_date_$biblioNum");
257
258         my $itemtype = $query->param('itemtype') || undef;
259         $itemtype = undef if $itemNum;
260
261         my $rank = $biblioData->{rank};
262         if ( $item ) {
263             $canreserve = 1 if CanItemBeReserved( $patron, $item, $branch )->{status} eq 'OK';
264         }
265         else {
266             $canreserve = 1
267               if CanBookBeReserved( $borrowernumber, $biblioNum, $branch, { itemtype => $itemtype } )->{status} eq 'OK';
268
269             # Inserts a null into the 'itemnumber' field of 'reserves' table.
270             $itemNum = undef;
271         }
272         my $notes = $query->param('notes_'.$biblioNum)||'';
273
274         if (   $maxreserves
275             && $reserve_cnt >= $maxreserves )
276         {
277             $canreserve = 0;
278         }
279
280         unless ( $can_place_hold_if_available_at_pickup ) {
281             my $items_in_this_library = Koha::Items->search({ biblionumber => $biblioNum, holdingbranch => $branch });
282             my $nb_of_items_issued = $items_in_this_library->search({ 'issue.itemnumber' => { not => undef }}, { join => 'issue' })->count;
283             my $nb_of_items_unavailable = $items_in_this_library->search({ -or => { lost => { '!=' => 0 }, damaged => { '!=' => 0 }, } });
284             if ( $items_in_this_library->count > $nb_of_items_issued + $nb_of_items_unavailable ) {
285                 $canreserve = 0
286             }
287         }
288
289         # Here we actually do the reserveration. Stage 3.
290         if ($canreserve) {
291             my $reserve_id = AddReserve(
292                 {
293                     branchcode       => $branch,
294                     borrowernumber   => $borrowernumber,
295                     biblionumber     => $biblioNum,
296                     priority         => $rank,
297                     reservation_date => $startdate,
298                     expiration_date  => $patron_expiration_date,
299                     notes            => $notes,
300                     title            => $biblioData->{title},
301                     itemnumber       => $itemNum,
302                     found            => $found,
303                     itemtype         => $itemtype,
304                 }
305             );
306             $failed_holds++ unless $reserve_id;
307             ++$reserve_cnt;
308         }
309     }
310
311     print $query->redirect("/cgi-bin/koha/opac-user.pl?" . ( $failed_holds ? "failed_holds=$failed_holds" : q|| ) . "#opac-user-holds");
312     exit;
313 }
314
315 #
316 #
317 # Here we check that the borrower can actually make reserves Stage 1.
318 #
319 #
320 my $noreserves     = 0;
321 my $maxoutstanding = C4::Context->preference("maxoutstanding");
322 my $amountoutstanding = $patron->account->balance;
323 if ( $amountoutstanding && ($amountoutstanding > $maxoutstanding) ) {
324     my $amount = sprintf "%.02f", $amountoutstanding;
325     $template->param( message => 1 );
326     $noreserves = 1;
327     $template->param( too_much_oweing => $amount );
328 }
329
330 if ( $patron->gonenoaddress && ($patron->gonenoaddress == 1) ) {
331     $noreserves = 1;
332     $template->param(
333         message => 1,
334         GNA     => 1
335     );
336 }
337
338 if ( $patron->lost && ($patron->lost == 1) ) {
339     $noreserves = 1;
340     $template->param(
341         message => 1,
342         lost    => 1
343     );
344 }
345
346 if ( $patron->is_debarred ) {
347     $noreserves = 1;
348     $template->param(
349         message          => 1,
350         debarred         => 1,
351         debarred_comment => $patron->debarredcomment,
352         debarred_date    => $patron->debarred,
353     );
354 }
355
356 my $holds = $patron->holds;
357 my $reserves_count = $holds->count;
358 $template->param( RESERVES => $holds->unblessed );
359 if ( $maxreserves && ( $reserves_count >= $maxreserves ) ) {
360     $template->param( message => 1 );
361     $noreserves = 1;
362     $template->param( too_many_reserves => $holds->count );
363 }
364
365 unless ( $noreserves ) {
366     my $requested_reserves_count = scalar( @biblionumbers );
367     if ( $maxreserves && ( $reserves_count + $requested_reserves_count > $maxreserves ) ) {
368         $template->param( new_reserves_allowed => $maxreserves - $reserves_count );
369     }
370 }
371
372 unless ($noreserves) {
373     $template->param( select_item_types => 1 );
374 }
375
376
377 #
378 #
379 # Build the template parameters that will show the info
380 # and items for each biblionumber.
381 #
382 #
383
384 my $biblioLoop = [];
385 my $numBibsAvailable = 0;
386 my $itemdata_enumchron = 0;
387 my $itemdata_ccode = 0;
388 my $anyholdable = 0;
389 my $itemLevelTypes = C4::Context->preference('item-level_itypes');
390 my $pickup_locations = Koha::Libraries->search({ pickup_location => 1 });
391 $template->param('item_level_itypes' => $itemLevelTypes);
392
393 my $patron_unblessed = $patron->unblessed;
394 foreach my $biblioNum (@biblionumbers) {
395
396     # Init the bib item with the choices for branch pickup
397     my %biblioLoopIter;
398
399     # Get relevant biblio data.
400     my $biblioData = $biblioDataHash{$biblioNum};
401     if (! $biblioData) {
402         $template->param(message=>1, bad_biblionumber=>$biblioNum);
403         output_html_with_http_headers $query, $cookie, $template->output, undef, { force_no_caching => 1 };
404         exit;
405     }
406
407     my @not_available_at = ();
408     my $biblio = $biblioData->{object};
409     foreach my $library ( $pickup_locations->as_list ) {
410         push( @not_available_at, $library->branchcode ) unless $biblio->can_be_transferred({ to => $library });
411     }
412
413     my $frameworkcode = GetFrameworkCode( $biblioData->{biblionumber} );
414     $biblioLoopIter{biblionumber} = $biblioData->{biblionumber};
415     $biblioLoopIter{title} = $biblioData->{title};
416     $biblioLoopIter{subtitle} = $biblioData->{'subtitle'};
417     $biblioLoopIter{medium} = $biblioData->{medium};
418     $biblioLoopIter{part_number} = $biblioData->{part_number};
419     $biblioLoopIter{part_name} = $biblioData->{part_name};
420     $biblioLoopIter{author} = $biblioData->{author};
421     $biblioLoopIter{rank} = $biblioData->{rank};
422     $biblioLoopIter{reservecount} = $biblioData->{reservecount};
423     $biblioLoopIter{already_reserved} = $biblioData->{already_reserved};
424     $biblioLoopIter{reqholdnotes}=0; #TODO: For future use
425
426     if (!$itemLevelTypes && $biblioData->{itemtype}) {
427         $biblioLoopIter{translated_description} = $itemtypes->{$biblioData->{itemtype}}{translated_description};
428         $biblioLoopIter{imageurl} = getitemtypeimagesrc() . "/". $itemtypes->{$biblioData->{itemtype}}{imageurl};
429     }
430
431
432
433     $biblioLoopIter{itemLoop} = [];
434     my $numCopiesAvailable = 0;
435     my $numCopiesOPACAvailable = 0;
436     # iterating through all items first to check if any of them available
437     # to pass this value further inside down to IsAvailableForItemLevelRequest to
438     # it's complicated logic to analyse.
439     # (before this loop was inside that sub loop so it was O(n^2) )
440     my $items_any_available;
441     $items_any_available = ItemsAnyAvailableAndNotRestricted( { biblionumber => $biblioNum, patron => $patron }) if $patron;
442     foreach my $item (@{$biblioData->{items}}) {
443
444         my $item_info = $item->unblessed;
445         $item_info->{holding_branch} = $item->holding_branch;
446         $item_info->{home_branch}    = $item->home_branch;
447         if ($itemLevelTypes) {
448             my $itemtype = $item->itemtype;
449             $item_info->{'imageurl'} = getitemtypeimagelocation( 'opac',
450                 $itemtypes->{ $itemtype->itemtype }->{'imageurl'} );
451             $item_info->{'translated_description'} =
452               $itemtypes->{ $itemtype->itemtype }->{translated_description};
453         }
454
455         # checking for holds
456         my $holds = $item->current_holds;
457         if ( my $first_hold = $holds->next ) {
458             $item_info->{first_hold} = $first_hold;
459         }
460
461         $item_info->{checkout} = $item->checkout;
462
463         # Check of the transferred documents
464         my $transfer = $item->get_transfer;
465         if ( $transfer && $transfer->in_transit ) {
466             $item_info->{transfertwhen} = $transfer->datesent;
467             $item_info->{transfertfrom} = $transfer->frombranch;
468             $item_info->{transfertto} = $transfer->tobranch;
469             $item_info->{nocancel} = 1;
470         }
471
472         # if the items belongs to a host record, show link to host record
473         if ( $item_info->{biblionumber} ne $biblioNum ) {
474             $item_info->{hostbiblionumber} = $item->biblionumber;
475             $item_info->{hosttitle}        = Koha::Biblios->find( $item_info->{biblionumber} )->title;
476         }
477
478         my $branch = GetReservesControlBranch( $item_info, $patron_unblessed );
479
480         # items_any_available defined outside of the current loop,
481         # so we avoiding loop inside IsAvailableForItemLevelRequest:
482         my $policy_holdallowed =
483             CanItemBeReserved( $patron, $item )->{status} eq 'OK' &&
484             IsAvailableForItemLevelRequest($item, $patron, undef, $items_any_available);
485
486         if ($policy_holdallowed) {
487             my $opac_hold_policy = Koha::CirculationRules->get_opacitemholds_policy( { item => $item, patron => $patron } );
488             if ( $opac_hold_policy ne 'N' ) { # If Y or F
489                 $item_info->{available} = 1;
490                 $numCopiesOPACAvailable++;
491                 $biblioLoopIter{force_hold} = 1 if $opac_hold_policy eq 'F';
492             }
493             $numCopiesAvailable++;
494
495             unless ( $can_place_hold_if_available_at_pickup ) {
496                 my $items_in_this_library = Koha::Items->search({ biblionumber => $item->biblionumber, holdingbranch => $item->holdingbranch });
497                 my $nb_of_items_issued = $items_in_this_library->search({ 'issue.itemnumber' => { not => undef }}, { join => 'issue' })->count;
498                 if ( $items_in_this_library->count > $nb_of_items_issued ) {
499                     push @not_available_at, $item->holdingbranch;
500                 }
501             }
502         }
503
504         # Show serial enumeration when needed
505         if ($item_info->{enumchron}) {
506             $itemdata_enumchron = 1;
507         }
508         # Show collection when needed
509         if ($item_info->{ccode}) {
510             $itemdata_ccode = 1;
511         }
512
513         push @{$biblioLoopIter{itemLoop}}, $item_info;
514     }
515     $template->param(
516         itemdata_enumchron => $itemdata_enumchron,
517         itemdata_ccode     => $itemdata_ccode,
518     );
519
520     if ($numCopiesAvailable > 0) {
521         $numBibsAvailable++;
522         $biblioLoopIter{bib_available} = 1;
523         $biblioLoopIter{holdable} = 1;
524         $biblioLoopIter{itemholdable} = 1 if $numCopiesOPACAvailable;
525     }
526     if ($biblioLoopIter{already_reserved}) {
527         $biblioLoopIter{holdable} = undef;
528         $biblioLoopIter{itemholdable} = undef;
529     }
530     if ( $biblioLoopIter{holdable} ) {
531         @not_available_at = uniq @not_available_at;
532         $biblioLoopIter{not_available_at} = \@not_available_at ;
533     }
534
535     unless ( $can_place_hold_if_available_at_pickup ) {
536         @not_available_at = uniq @not_available_at;
537         $biblioLoopIter{not_available_at} = \@not_available_at ;
538         # The record is not holdable is not available at any of the libraries
539         if ( Koha::Libraries->search->count == @not_available_at ) {
540             $biblioLoopIter{holdable} = 0;
541         }
542     }
543
544     my $status = CanBookBeReserved( $borrowernumber, $biblioNum )->{status};
545     $biblioLoopIter{holdable} &&= $status eq 'OK';
546     $biblioLoopIter{$status} = 1;
547
548     if ( $biblioLoopIter{holdable} and C4::Context->preference('AllowHoldItemTypeSelection') ) {
549         # build the allowed item types loop
550         my $rs = $biblio->items->search_ordered(
551             undef,
552             {   select => [ { distinct => 'itype' } ],
553                 as     => 'item_type'
554             }
555         );
556
557         my @item_types =
558           grep { CanBookBeReserved( $borrowernumber, $biblioNum, $branch, { itemtype => $_ } )->{status} eq 'OK' }
559           $rs->get_column('item_type');
560
561         $biblioLoopIter{allowed_item_types} = \@item_types;
562     }
563
564     if ( $status eq 'recall' ) {
565         $biblioLoopIter{recall} = 1;
566     }
567
568     # For multiple holds per record, if a patron has previously placed a hold,
569     # the patron can only place more holds of the same type. That is, if the
570     # patron placed a record level hold, all the holds the patron places must
571     # be record level. If the patron placed an item level hold, all holds
572     # the patron places must be item level
573     my $forced_hold_level = Koha::Holds->search(
574         {
575             borrowernumber => $borrowernumber,
576             biblionumber   => $biblioNum,
577             found          => undef,
578         }
579     )->forced_hold_level();
580     if ($forced_hold_level) {
581         $biblioLoopIter{force_hold}   = 1 if $forced_hold_level eq 'item';
582         $biblioLoopIter{itemholdable} = 0 if $forced_hold_level eq 'record';
583         $biblioLoopIter{forced_hold_level} = $forced_hold_level;
584     }
585
586
587     push @$biblioLoop, \%biblioLoopIter;
588
589     $anyholdable = 1 if $biblioLoopIter{holdable};
590 }
591
592 unless ($pickup_locations->count) {
593     $numBibsAvailable = 0;
594     $anyholdable = 0;
595     $template->param(
596         message => 1,
597         no_pickup_locations => 1
598     );
599 }
600
601 if ( $numBibsAvailable == 0 || $anyholdable == 0) {
602     $template->param( none_available => 1 );
603 }
604
605 if (scalar @biblionumbers > 1) {
606     $template->param( multi_hold => 1);
607 }
608
609 my $show_notes=C4::Context->preference('OpacHoldNotes');
610 $template->param(OpacHoldNotes=>$show_notes);
611
612 # display infos
613 $template->param(bibitemloop => $biblioLoop);
614 # can set reserve date in future
615 if (
616     C4::Context->preference( 'AllowHoldDateInFuture' ) &&
617     C4::Context->preference( 'OPACAllowHoldDateInFuture' )
618     ) {
619     $template->param(
620             reserve_in_future         => 1,
621     );
622 }
623
624 output_html_with_http_headers $query, $cookie, $template->output, undef, { force_no_caching => 1 };