Bugzilla – Attachment 134353 Details for
Bug 10517
koha-restore fails to create mysqluser@mysql_hostname so zebra update fails
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 10517: Use `DROP USER IF EXISTS` and remove ` || true`.
Bug-10517-Use-DROP-USER-IF-EXISTS-and-remove---tru.patch (text/plain), 2.57 KB, created by
Marcel de Rooy
on 2022-04-29 09:20:53 UTC
(
hide
)
Description:
Bug 10517: Use `DROP USER IF EXISTS` and remove ` || true`.
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2022-04-29 09:20:53 UTC
Size:
2.57 KB
patch
obsolete
>From ef57a428942136ab45e2294c3b537d87c35e237c Mon Sep 17 00:00:00 2001 >From: Rudolf Byker <rudolfbyker@gmail.com> >Date: Wed, 8 Jan 2020 11:20:02 +0200 >Subject: [PATCH] Bug 10517: Use `DROP USER IF EXISTS` and remove ` || true`. >Content-Type: text/plain; charset=utf-8 > >When restoring a Koha instance, and the database user does not exist, an error is shown, >although it is prevented from stopping the script by ` || true`. This patch removes the >` || true` guard, and rather uses `DROP USER IF EXISTS` which does exactly what one >would expect, without confusing error messages, whether the user existed or not. > >To test: >1) Assume your Koha instance is called `asdf`. >1) Export the Koha instance using `koha-dump`. >2) Remove the instance completely using `koha-remove`. >3) Import it again using `koha-restore`. >4) No error should be shown, and the import should work. There was NO user to drop, therefore `DROP USER IF EXISTS` did nothing. >5) A database user called `koha_asdf` should exist, and have all privileges on the database of the same name. >6) Remove the instance again using `koha-remove`. >7) Now create a database user in MySQL called `koha_instance` where instance is the name of your dumped koha instance. >8) Import your koha instance again using `koha-restore`. >9) Again, no error should be shown, and the import should work. There WAS a user to drop, therefore `DROP USER IF EXISTS` dropped the user before creating a new one. >10) Again, a database user called `koha_asdf` should exist, and have all privileges on the database of the same name. > >Sponsored-by: Reformational Study Centre >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >--- > debian/scripts/koha-restore | 6 ++---- > 1 file changed, 2 insertions(+), 4 deletions(-) > >diff --git a/debian/scripts/koha-restore b/debian/scripts/koha-restore >index e8ec053ee0..7c68d65c29 100755 >--- a/debian/scripts/koha-restore >+++ b/debian/scripts/koha-restore >@@ -72,10 +72,8 @@ mysqldb="koha_$name" > mysqluser="koha_$name" > mysqlpwd="$( xmlstarlet sel -t -v 'yazgfs/config/pass' /etc/koha/sites/$name/koha-conf.xml )" > zcat "$sqldump" | mysql --defaults-extra-file=/etc/mysql/koha-common.cnf >-mysql --defaults-extra-file=/etc/mysql/koha-common.cnf <<eof || true >-DROP USER '$mysqluser'; >-eof >-mysql --defaults-extra-file=/etc/mysql/koha-common.cnf << eof || true >+mysql --defaults-extra-file=/etc/mysql/koha-common.cnf <<eof >+DROP USER IF EXISTS '$mysqluser'; > CREATE USER '$mysqluser' IDENTIFIED BY '$mysqlpwd'; > GRANT ALL PRIVILEGES ON $mysqldb.* TO '$mysqluser'; > FLUSH PRIVILEGES; >-- >2.20.1
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 10517
:
19284
|
89529
|
96975
|
127865
|
133758
| 134353 |
134354