Bugzilla – Attachment 140222 Details for
Bug 31351
Worker dies on reindex job when operator last name/first name/branch name contains non-ASCII chars
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 31351: encode bytes to unicode in JSON for background tasks context
Bug-31351-encode-bytes-to-unicode-in-JSON-for-back.patch (text/plain), 3.15 KB, created by
Peter Vashchuk
on 2022-09-06 11:36:03 UTC
(
hide
)
Description:
Bug 31351: encode bytes to unicode in JSON for background tasks context
Filename:
MIME Type:
Creator:
Peter Vashchuk
Created:
2022-09-06 11:36:03 UTC
Size:
3.15 KB
patch
obsolete
>From 7227319831493eceb33a12642c2dd78b5b3af7f1 Mon Sep 17 00:00:00 2001 >From: Petro Vashchuk <stalkernoid@gmail.com> >Date: Fri, 12 Aug 2022 17:33:54 +0300 >Subject: [PATCH] Bug 31351: encode bytes to unicode in JSON for background > tasks context >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >"malformed UTF-8 character in JSON string, at character offset 38 (before "\x{fffd}"register_id...") at /home/vagrant/kohaclone/Koha/BackgroundJob.pm line 170." > >Steps to reproduce: >1. Go to your user settings and change your current logged user's name/surname so it contains non-ASCII character, for example "ä" (U+00E4). >2. Log out and log back in with the same user so session will be refreshed with updated info. >3. Open any biblio record in marc-record edit mode and save it back: just to initiate ElasticSearch background reindex job creation. >4. Open background jobs admin page, you will see there "Update Elasticsearch index" job that is in status "New". Normal behaviour for it is to already get to "Finished" status, as this job is simple and going to be completed quickly, but it's going to remain in "New" status and never get to the "Finished" state. That's why: >5. Stop Koha-worker from the root user: `koha-worker --stop %YOUR_KOHA_INSTANCE%` (%YOUR_KOHA_INSTANCE% is your Koha instance name, for ex. 'kohadev'), and stop RabbitMQ service inside machine from root: `service rabbitmq-server stop`, then if you run misc/background_jobs_worker.pl inside of your koha machine from under koha user, that script won't be able to connect to RabbitMQ (it warns about this) so it will process tasks one-by-one itself in "no-server-available" mode, and thus you will be able to find the problem, why background job task remains "New": you will see the "malformed UTF-8 character in JSON string" error. >6. Apply the patch. >7. Run background_jobs_worker.pl script again, ensure that after it warns about "Connection refused" to RabbitMQ server, it processes all "New" tasks again like in step 5, but the "malformed UTF-8 character in JSON string" error is gone and if you check background jobs admin page, the status of that same job is now "Finished". This means since now the bug solved, so: >8. Start RabbitMQ service inside machine from root: `service rabbitmq-server start`. Start Koha-worker from the root user: `koha-worker --start %YOUR_KOHA_INSTANCE%`. >8. Repeat from step 3: edit biblio and save the record again, to create another background job. >9. Check that the background job page and see that new job now has "Finished" status, so patch works. > >Signed-off-by: David Nind <david@davidnind.com> >--- > Koha/BackgroundJob.pm | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > >diff --git a/Koha/BackgroundJob.pm b/Koha/BackgroundJob.pm >index dcfba14659d..987e4729971 100644 >--- a/Koha/BackgroundJob.pm >+++ b/Koha/BackgroundJob.pm >@@ -167,7 +167,7 @@ sub process { > $args ||= {}; > > if ( $self->context ) { >- my $context = decode_json($self->context); >+ my $context = decode_json(encode_utf8($self->context)); > C4::Context->_new_userenv(-1); > C4::Context->interface( $context->{interface} ); > C4::Context->set_userenv( >-- >2.35.3
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 31351
:
139058
|
139438
|
140222
|
140236
|
140262
|
140310
|
140311
|
140312
|
140313
|
140314
|
140315