Bug 31223 - Batch edit items explodes if plugins disabled
Summary: Batch edit items explodes if plugins disabled
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Cataloging (show other bugs)
Version: Main
Hardware: All All
: P5 - low major with 10 votes (vote)
Assignee: Tomás Cohen Arazi
QA Contact: Joonas Kylmälä
URL:
Keywords:
Depends on:
Blocks: 31351
  Show dependency treegraph
 
Reported: 2022-07-22 15:22 UTC by Isabel Pineda
Modified: 2023-12-28 20:43 UTC (History)
11 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Trivial patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
22.11.00, 22.05.05


Attachments
Bug 31223: Regression tests (1.95 KB, patch)
2022-07-26 13:00 UTC, Tomás Cohen Arazi
Details | Diff | Splinter Review
Bug 31223: Do not explode if plugins disabled (1.30 KB, patch)
2022-07-26 13:00 UTC, Tomás Cohen Arazi
Details | Diff | Splinter Review
Bug 31223: Do not try to report results if task not started (1023 bytes, patch)
2022-07-26 13:12 UTC, Tomás Cohen Arazi
Details | Diff | Splinter Review
Bug 31223: Regression tests (1.38 KB, patch)
2022-07-26 13:51 UTC, Tomás Cohen Arazi
Details | Diff | Splinter Review
Bug 31223: Do not explode if plugins disabled (1.31 KB, patch)
2022-07-26 13:51 UTC, Tomás Cohen Arazi
Details | Diff | Splinter Review
Bug 31223: Do not try to report results if task not started (1023 bytes, patch)
2022-07-26 13:51 UTC, Tomás Cohen Arazi
Details | Diff | Splinter Review
Bug 31223: Regression tests (1.43 KB, patch)
2022-07-26 17:40 UTC, Kyle M Hall
Details | Diff | Splinter Review
Bug 31223: Do not explode if plugins disabled (1.36 KB, patch)
2022-07-26 17:41 UTC, Kyle M Hall
Details | Diff | Splinter Review
Bug 31223: Do not try to report results if task not started (1.05 KB, patch)
2022-07-26 17:41 UTC, Kyle M Hall
Details | Diff | Splinter Review
Bug 31223: Regression tests (1.57 KB, patch)
2022-07-30 16:59 UTC, Joonas Kylmälä
Details | Diff | Splinter Review
Bug 31223: Do not explode if plugins disabled (1.50 KB, patch)
2022-07-30 16:59 UTC, Joonas Kylmälä
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Isabel Pineda 2022-07-22 15:22:07 UTC
In a register with several items I select all (or some) items and click "edit selected items". I make the modification (write a public note, change the signature, change item type etc.) and click "Save", the modifications don't get saved.
It used to work in previous versions.
Comment 1 Katrin Fischer 2022-07-24 21:45:02 UTC
Hi Isabel, there could be a time delay while the job is processed by the background jobs. If you go to Aministration > Background jobs, do you see any finished/unfinished jobs of type "Batch item record modification" there?
Comment 2 Isabel Pineda 2022-07-25 13:19:12 UTC
(In reply to Katrin Fischer from comment #1)
> Hi Isabel, there could be a time delay while the job is processed by the
> background jobs. If you go to Aministration > Background jobs, do you see
> any finished/unfinished jobs of type "Batch item record modification" there?

Hi Katrin.

I have just tried: When I click on the link to view the details of the queued job, I get a 500 error.
The intranet-error logfile gives this output:

AH01215: CGI::param called in list context from /usr/share/koha/intranet/cgi-bin/catalogue/detail.pl line 622, this can lead to vulnerabilities. See the warning in "Fetching the value or values of a single named parameter" at /usr/share/perl5/CGI.pm line 415.: /usr/share/koha/intranet/cgi-bin/catalogue/detail.pl, referer: https://biblioteca-intra.ds.edu.sv/cgi-bin/koha/tools/batchMod.pl

AH01215: Use of uninitialized value $mode in string ne at /usr/share/koha/intranet/cgi-bin/cataloguing/addbiblio.pl line 886.: /usr/share/koha/intranet/cgi-bin/cataloguing/addbiblio.pl, referer: https://biblioteca-intra.ds.edu.sv/cgi-bin/koha/cataloguing/addbiblio.pl?biblionumber=18080

AH01215: CGI::param called in list context from /usr/share/koha/intranet/cgi-bin/catalogue/detail.pl line 622, this can lead to vulnerabilities. See the warning in "Fetching the value or values of a single named parameter" at /usr/share/perl5/CGI.pm line 415.: /usr/share/koha/intranet/cgi-bin/catalogue/detail.pl, referer: https://biblioteca-intra.ds.edu.sv/cgi-bin/koha/cataloguing/addbiblio.pl?biblionumber=18080

AH01215: Can't use an undefined value as an ARRAY reference at /usr/share/koha/lib/Koha/BackgroundJob/BatchUpdateItem.pm line 175.: /usr/share/koha/intranet/cgi-bin/admin/background_jobs.pl, referer: https://biblioteca-intra.ds.edu.sv/cgi-bin/koha/tools/batchMod.pl
End of script output before headers: background_jobs.pl, referer: https://biblioteca-intra.ds.edu.sv/cgi-bin/koha/tools/batchMod.pl
Comment 3 Jonathan Druart 2022-07-25 13:26:06 UTC
Identify the id of the job in the URL and request the DB

select * from background_jobs where id=X
Comment 4 Isabel Pineda 2022-07-25 13:35:33 UTC
(In reply to Jonathan Druart from comment #3)
> Identify the id of the job in the URL and request the DB
> 
> select * from background_jobs where id=X

Ok. This is the content that I get in the fields:
id: 357
status: new
size: 2
borrowernumber: 2
type: batch_item_record_modification 	
queue: default
data: {"exclude_from_local_holds_priority":null,"regex_mod":null,"record_ids":["38409","42755"],"new_values":{"itemnotes":"test","dateaccessioned":"2022-07-25"}}

The other fields are empty.
Comment 5 Isabel Pineda 2022-07-25 13:38:02 UTC
(In reply to Jonathan Druart from comment #3)
> Identify the id of the job in the URL and request the DB
> 
> select * from background_jobs where id=X

Sorry, I forgot one field:

id: 357
status: new
size: 2
borrowernumber: 2
type: batch_item_record_modification 	
queue: default
data: {"exclude_from_local_holds_priority":null,"regex_mod":null,"record_ids":["38409","42755"],"new_values":{"itemnotes":"test","dateaccessioned":"2022-07-25"}}
enqueued_on: 2022-07-25 07:14:34

The other fields are empty.
Comment 6 Jonathan Druart 2022-07-25 13:41:37 UTC
Do you see the two koha-worker processes?

  ps aux | grep koha-worker
Comment 7 Isabel Pineda 2022-07-25 13:50:28 UTC
(In reply to Jonathan Druart from comment #6)
> Do you see the two koha-worker processes?
> 
>   ps aux | grep koha-worker

I get this output:
bibliot+   21230  0.0  0.0   8468   156 ?        S    Jul04   0:00 daemon --name=biblioteca-koha-worker --errlog=/var/log/koha/biblioteca/worker-error.log --stdout=/var/log/koha/biblioteca/worker.log --output=/var/log/koha/biblioteca/worker-output.log --pidfiles=/var/run/koha/biblioteca/ --verbose=1 --respawn --delay=30 --user=biblioteca-koha.biblioteca-koha -- /usr/share/koha/bin/background_jobs_worker.pl --queue default
biblio   4191795  0.0  0.0   9208  2216 pts/0    S+   07:46   0:00 grep --color=auto koha-worker


I have just looked into the worker-error logfile, but it is empty. The worker-output logfile gives this output:
Can't call method "GetPlugins" on an undefined value at /usr/share/koha/lib/Koha/BackgroundJob.pm line 402.
Comment 8 Tomás Cohen Arazi 2022-07-26 13:00:47 UTC
Created attachment 138126 [details] [review]
Bug 31223: Regression tests

This patch adds tests so we are sure things don't explode with/without
plugins enabled.

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Comment 9 Tomás Cohen Arazi 2022-07-26 13:00:52 UTC
Created attachment 138127 [details] [review]
Bug 31223: Do not explode if plugins disabled

This patch makes the code skip calculating the plugin-related task
codes => class mapping if plugins are entirely disbaled.

To test:
1. Apply the regression tests
2. Run:
   $ kshell
  k$ prove t/db_dependent/Koha/BackgroundJob.t
=> FAIL: Tests explode with: Can't call method "GetPlugins" on an
undefined value at... Koha/BackgroundJob.pm line 424.
3. Apply this patch
4. Repeat 2
=> SUCCESS: Tests pass!
5. Sign off :-D

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Comment 10 Tomás Cohen Arazi 2022-07-26 13:12:44 UTC
Created attachment 138128 [details] [review]
Bug 31223: Do not try to report results if task not started

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Comment 11 Tomás Cohen Arazi 2022-07-26 13:22:07 UTC
Need to re-do the tests.
Comment 12 Tomás Cohen Arazi 2022-07-26 13:51:46 UTC
Created attachment 138129 [details] [review]
Bug 31223: Regression tests

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Comment 13 Tomás Cohen Arazi 2022-07-26 13:51:50 UTC
Created attachment 138130 [details] [review]
Bug 31223: Do not explode if plugins disabled

This patch makes the code skip calculating the plugin-related task
codes => class mapping if plugins are entirely disbaled.

To test:
1. Apply the regression tests
2. Run:
   $ kshell
  k$ prove t/db_dependent/Koha/Plugins/BackgroundJob.t
=> FAIL: Tests explode with: Can't call method "GetPlugins" on an
undefined value at... Koha/BackgroundJob.pm line 424.
3. Apply this patch
4. Repeat 2
=> SUCCESS: Tests pass!
5. Sign off :-D

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Comment 14 Tomás Cohen Arazi 2022-07-26 13:51:55 UTC
Created attachment 138131 [details] [review]
Bug 31223: Do not try to report results if task not started

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Comment 15 Tomás Cohen Arazi 2022-07-26 14:15:35 UTC
(In reply to Isabel Pineda from comment #0)
> In a register with several items I select all (or some) items and click
> "edit selected items". I make the modification (write a public note, change
> the signature, change item type etc.) and click "Save", the modifications
> don't get saved.
> It used to work in previous versions.

In the meantime, you should enable plugins in koha-conf.xml until this is pushed.

Also, I noticed that the task will stay as 'new' because it is not being picked by the message queue. So I suggest you:

- systemctl stop rabbitmq
- koha-worker --restart --queue default <instance>

so it is picked again.
Comment 16 Isabel Pineda 2022-07-26 15:29:19 UTC
(In reply to Tomás Cohen Arazi from comment #15)
> (In reply to Isabel Pineda from comment #0)
> > In a register with several items I select all (or some) items and click
> > "edit selected items". I make the modification (write a public note, change
> > the signature, change item type etc.) and click "Save", the modifications
> > don't get saved.
> > It used to work in previous versions.
> 
> In the meantime, you should enable plugins in koha-conf.xml until this is
> pushed.
> 
> Also, I noticed that the task will stay as 'new' because it is not being
> picked by the message queue. So I suggest you:
> 
> - systemctl stop rabbitmq
> - koha-worker --restart --queue default <instance>
> 
> so it is picked again.

Thank you.
The plugins were enabled, actually I am using the coverflow plugin on the OPAC.
But for some reason the koha-worker wasn't working. So the line
- koha-worker --restart --queue default <instance>
solved the problem for me.
Comment 17 Kyle M Hall 2022-07-26 17:40:58 UTC
Created attachment 138142 [details] [review]
Bug 31223: Regression tests

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Comment 18 Kyle M Hall 2022-07-26 17:41:30 UTC
Created attachment 138143 [details] [review]
Bug 31223: Do not explode if plugins disabled

This patch makes the code skip calculating the plugin-related task
codes => class mapping if plugins are entirely disbaled.

To test:
1. Apply the regression tests
2. Run:
   $ kshell
  k$ prove t/db_dependent/Koha/Plugins/BackgroundJob.t
=> FAIL: Tests explode with: Can't call method "GetPlugins" on an
undefined value at... Koha/BackgroundJob.pm line 424.
3. Apply this patch
4. Repeat 2
=> SUCCESS: Tests pass!
5. Sign off :-D

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Comment 19 Kyle M Hall 2022-07-26 17:41:34 UTC
Created attachment 138144 [details] [review]
Bug 31223: Do not try to report results if task not started

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Comment 20 Jonathan Druart 2022-07-27 08:33:37 UTC
Comment on attachment 138144 [details] [review]
Bug 31223: Do not try to report results if task not started

Moved to bug 31245.
Comment 21 Tomás Cohen Arazi 2022-07-27 10:35:16 UTC
(In reply to Jonathan Druart from comment #20)
> Comment on attachment 138144 [details] [review] [review]
> Bug 31223: Do not try to report results if task not started
> 
> Moved to bug 31245.

Ok!
Comment 22 Joonas Kylmälä 2022-07-30 16:59:48 UTC
Created attachment 138390 [details] [review]
Bug 31223: Regression tests

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>

Signed-off-by: Joonas Kylmälä <joonas.kylmala@iki.fi>
Comment 23 Joonas Kylmälä 2022-07-30 16:59:52 UTC
Created attachment 138391 [details] [review]
Bug 31223: Do not explode if plugins disabled

This patch makes the code skip calculating the plugin-related task
codes => class mapping if plugins are entirely disbaled.

To test:
1. Apply the regression tests
2. Run:
   $ kshell
  k$ prove t/db_dependent/Koha/Plugins/BackgroundJob.t
=> FAIL: Tests explode with: Can't call method "GetPlugins" on an
undefined value at... Koha/BackgroundJob.pm line 424.
3. Apply this patch
4. Repeat 2
=> SUCCESS: Tests pass!
5. Sign off :-D

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>

Signed-off-by: Joonas Kylmälä <joonas.kylmala@iki.fi>
Comment 24 Tomás Cohen Arazi 2022-08-01 12:11:19 UTC
Pushed to master for 22.11.

Nice work everyone, thanks!
Comment 25 Katrin Fischer 2022-09-09 09:39:59 UTC
Lucas, please backport this one urgently.
Comment 26 Lucas Gass 2022-09-12 14:59:15 UTC
Backported to 22.05.x for 22.05.05
Comment 27 Arthur Suzuki 2022-09-14 10:02:50 UTC
won't backport to 21.11.x.
depends on backgroundjobs (not available in 21.11.x).
Comment 28 Alex Buckley 2022-09-22 03:04:45 UTC
(In reply to Arthur Suzuki from comment #27)
> won't backport to 21.11.x.
> depends on backgroundjobs (not available in 21.11.x).

Hi Arthur,

Backgroundjobs do appear to be available in Koha 21.11.x - see https://git.koha-community.org/Koha-community/Koha/src/branch/21.11.x/Koha/BackgroundJob

Is this what you meant or are you referring to another set of files that are not in 21.11.x?

It would be great to have this fix backported to 21.11.x!

Many thanks,
Alex