From 8112b40f22a9db012e81080631c3f483cc658c7e Mon Sep 17 00:00:00 2001 From: Pedro Amorim Date: Fri, 15 Dec 2023 16:20:58 +0000 Subject: [PATCH] Bug 35570: (QA follow-up): Make QA script green, fix: - Variables declared in condition - Use of DateTime->now should certainly be replaced with dt_from_string (bug 24840) - missing_filter - forbidden pattern: Do not use line breaks inside template tags (bug 18675) - Attribute type should not be used for script tags (bug 20053) - File must have the exec flag - forbidden pattern: trailing space char - valid_template: /shared-includes/custom_fields.inc: not found --- Koha/ILL/Backend/Standard.pm | 27 +-- Koha/ILL/Backend/intra-includes/cancel.inc | 7 +- Koha/ILL/Backend/intra-includes/confirm.inc | 7 +- Koha/ILL/Backend/intra-includes/create.inc | 26 +-- Koha/ILL/Backend/intra-includes/edititem.inc | 162 +++++++++--------- Koha/ILL/Backend/intra-includes/migrate.inc | 10 +- Koha/ILL/Backend/opac-includes/create.inc | 12 +- .../Backend/shared-includes/custom_fields.inc | 4 +- .../Backend/shared-includes/forms/article.inc | 20 +-- .../Backend/shared-includes/forms/book.inc | 20 +-- .../Backend/shared-includes/forms/chapter.inc | 26 +-- .../shared-includes/forms/conference.inc | 22 +-- .../Backend/shared-includes/forms/journal.inc | 12 +- .../shared-includes/forms/resource.inc | 26 +-- .../Backend/shared-includes/forms/thesis.inc | 10 +- Koha/ILL/Request.pm | 4 +- about.pl | 2 +- .../data/mysql/atomicupdate/bug_35570.pl | 3 +- 18 files changed, 201 insertions(+), 199 deletions(-) mode change 100644 => 100755 installer/data/mysql/atomicupdate/bug_35570.pl diff --git a/Koha/ILL/Backend/Standard.pm b/Koha/ILL/Backend/Standard.pm index 748680ad1a..95c4eec858 100644 --- a/Koha/ILL/Backend/Standard.pm +++ b/Koha/ILL/Backend/Standard.pm @@ -22,9 +22,10 @@ use DateTime; use File::Basename qw( dirname ); use C4::Installer; +use Koha::DateUtils qw/ dt_from_string /; use Koha::ILL::Requests; use Koha::ILL::Request::Attribute; -use C4::Biblio qw( AddBiblio ); +use C4::Biblio qw( AddBiblio ); use C4::Charset qw( MarcToUTF8Record ); =head1 NAME @@ -225,7 +226,7 @@ sub create { }; } elsif ( $stage eq 'form' ) { - # We may be recieving a submitted form due to an additional + # We may be receiving a submitted form due to an additional # custom field being added or deleted, or the material type # having been changed, so check for these things if ( !_can_create_request($other) ) { @@ -383,7 +384,7 @@ sub edititem { }; } elsif ( $stage eq 'form' ) { - # We may be recieving a submitted form due to an additional + # We may be receiving a submitted form due to an additional # custom field being added or deleted, or the material type # having been changed, so check for these things if ( defined $other->{'add_new_custom'} @@ -452,7 +453,7 @@ sub edititem { # ...Update Illrequest my $request = $params->{request}; - $request->updated( DateTime->now ); + $request->updated( dt_from_string() ); $request->store; # ...Populate Illrequestattributes @@ -638,7 +639,7 @@ sub migrate { my $core_fields = _get_core_string(); - # We may be recieving a submitted form due to an additional + # We may be receiving a submitted form due to an additional # custom field being added or deleted, or the material type # having been changed, so check for these things if ( defined $other->{'add_new_custom'} @@ -679,7 +680,7 @@ sub migrate { }; } - # Recieve a new request from another backend and suppliment it with + # Receive a new request from another backend and supplement it with # anything we require specifically for this backend. if ( !$stage || $stage eq 'immigrate' ) { my $original_request = Koha::ILL::Requests->find( $other->{illrequest_id} ); @@ -688,8 +689,8 @@ sub migrate { $new_request->branchcode( $original_request->branchcode ); $new_request->status('NEW'); $new_request->backend( $self->name ); - $new_request->placed( DateTime->now ); - $new_request->updated( DateTime->now ); + $new_request->placed( dt_from_string() ); + $new_request->updated( dt_from_string() ); $new_request->store; my @default_attributes = (qw/title type author year volume isbn issn article_title article_author pages/); @@ -972,8 +973,8 @@ sub add_request { $request->branchcode( $params->{other}->{branchcode} ); $request->status('NEW'); $request->backend( $params->{other}->{backend} ); - $request->placed( DateTime->now ); - $request->updated( DateTime->now ); + $request->placed( dt_from_string() ); + $request->updated( dt_from_string() ); $request->batch_id( $params->{other}->{ill_batch_id} ? $params->{other}->{ill_batch_id} : $params->{other}->{batch_id} ) if column_exists( 'illrequests', 'batch_id' ); @@ -1151,9 +1152,9 @@ sub _standard_request2biblio { return 0 unless $metadata->{type} eq 'book'; # We're going to try and populate author, title & ISBN - my $author = $metadata->{author} if $metadata->{author}; - my $title = $metadata->{title} if $metadata->{title}; - my $isbn = $metadata->{isbn} if $metadata->{isbn}; + my $author = $metadata->{author} // ''; + my $title = $metadata->{title} // ''; + my $isbn = $metadata->{isbn} // ''; # Create the MARC::Record object and populate my $record = MARC::Record->new(); diff --git a/Koha/ILL/Backend/intra-includes/cancel.inc b/Koha/ILL/Backend/intra-includes/cancel.inc index 6c107abb30..51dd40c325 100644 --- a/Koha/ILL/Backend/intra-includes/cancel.inc +++ b/Koha/ILL/Backend/intra-includes/cancel.inc @@ -9,9 +9,8 @@

If you can confirm this has been done, please proceed.

[% base_url = "/cgi-bin/koha/ill/ill-requests.pl" %] - [% proceed_url = base_url _ "?method=cancel&stage=confirm" _ - "&illrequest_id=" _ request.illrequest_id %] - Revert request - Cancel + [% proceed_url = base_url _ "?method=cancel&stage=confirm" _ "&illrequest_id=" _ request.illrequest_id %] + Revert request + Cancel

[% END %] diff --git a/Koha/ILL/Backend/intra-includes/confirm.inc b/Koha/ILL/Backend/intra-includes/confirm.inc index dcd003752e..ad9646f305 100644 --- a/Koha/ILL/Backend/intra-includes/confirm.inc +++ b/Koha/ILL/Backend/intra-includes/confirm.inc @@ -9,10 +9,9 @@

If you can confirm this has been done, please proceed.

[% base_url = "/cgi-bin/koha/ill/ill-requests.pl" %] - [% proceed_url = base_url _ "?method=confirm&stage=confirm" _ - "&illrequest_id=" _ request.illrequest_id %] - Confirm request - Cancel + [% proceed_url = base_url _ "?method=confirm&stage=confirm" _ "&illrequest_id=" _ request.illrequest_id %] + Confirm request + Cancel

[% ELSE %]

Unknown stage. This should not have happened. diff --git a/Koha/ILL/Backend/intra-includes/create.inc b/Koha/ILL/Backend/intra-includes/create.inc index b2c78449fb..2510060172 100644 --- a/Koha/ILL/Backend/intra-includes/create.inc +++ b/Koha/ILL/Backend/intra-includes/create.inc @@ -15,7 +15,7 @@ [% IF whole.stage == "form" %]

Create a manual ILL request

-
+
General details
    @@ -93,8 +93,8 @@ @@ -110,7 +110,7 @@ [% BLOCK backend_jsinclude %] - @@ -157,22 +157,22 @@ [% ELSIF whole.stage == "borrowers" %]

    Borrower selection

    -
    + [% FOREACH prop IN whole.value.other.keys %] [% IF prop != 'custom_key' && prop != 'custom_value' && prop != 'cardnumber' %] - + [% END %] [% END %] [% keys = whole.value.other.custom_key.split('\0') %] [% values = whole.value.other.custom_value.split('\0') %] [% i = 0 %] [% FOREACH key IN keys %] - - + + [% i = i + 1 %] [% END %]
    - Available borrowers for surname [% surname %] + Available borrowers for surname [% surname | html %] [% FOREACH opt IN whole.value %] [% IF opt.key == "brw" %]
      @@ -181,8 +181,8 @@ @@ -193,7 +193,7 @@
    - Cancel + Cancel
    diff --git a/Koha/ILL/Backend/intra-includes/edititem.inc b/Koha/ILL/Backend/intra-includes/edititem.inc index bb34ce293a..58dfb4bcae 100644 --- a/Koha/ILL/Backend/intra-includes/edititem.inc +++ b/Koha/ILL/Backend/intra-includes/edititem.inc @@ -6,83 +6,87 @@ [% END %] [% END %] -

    Edit a manual ILL request

    -
    -
    - General details -
      -
    1. - - -
    2. -
    -
    - [% cwd = whole.cwd %] - [% type = whole.value.other.type %] - [% IF type %] - [% INCLUDE "${cwd}/shared-includes/forms/${type}.inc" %] +[% IF whole.stage == "form" %] +

    Edit a manual ILL request

    + +
    + General details +
      +
    1. + + +
    2. +
    +
    + [% cwd = whole.cwd %] + [% type = whole.value.other.type %] + [% IF type %] + [% INCLUDE "${cwd}/shared-includes/forms/${type}.inc" %] + [% END %] + [% INCLUDE "${cwd}/shared-includes/custom_fields.inc" %] +
    + + Cancel +
    + + + + +
    + [% BLOCK backend_jsinclude %] + [% END %] - [% INCLUDE "${cwd}/shared-includes/custom_fields.inc" %] -
    - - Cancel -
    - - - - - -[% BLOCK backend_jsinclude %] - -[% END %] +[% ELSE %] +

    Unknown stage. This should not have happened. +[% END %] \ No newline at end of file diff --git a/Koha/ILL/Backend/intra-includes/migrate.inc b/Koha/ILL/Backend/intra-includes/migrate.inc index fbeb8ff69b..ea85d7e1e8 100644 --- a/Koha/ILL/Backend/intra-includes/migrate.inc +++ b/Koha/ILL/Backend/intra-includes/migrate.inc @@ -14,7 +14,7 @@ [% IF whole.stage == "form" %]

    Migrating an ILL request

    -
    +
    General details
      @@ -66,7 +66,7 @@ [% ELSE %] - [% END %] + [% END %]
    @@ -92,8 +92,8 @@ @@ -106,7 +106,7 @@
    [% BLOCK backend_jsinclude %] -