koha-dump-defaults runs mysqldump and then pipes the result to sed, to replace every occurence of the site name with the placeholder __KOHASITE__ mysqldump --databases --host="$mysqlhost" --user="$mysqluser" \ --password="$mysqlpass" "$mysqldb" | sed "s/$name/__KOHASITE__/g" I had used the silly name "data" as the site name for my "template instance", and this resulted in innocent things like -- Dumping __KOHASITE__ for table `zebraqueue` and bad things like 'Edit catalog (Modify bibliographic/holdings __KOHASITE__)' or this, in biblioitems.marcxml: <__KOHASITE__field> All told there were 7235 occurences of __KOHASITE__ in my rather small SQL file. As suggested by drojf on IRC, I *think* this would be fixed if we replaced "koha_$name" __INSTANCENAME__, instead of just $name.
(In reply to Magnus Enger from comment #0) > As suggested by drojf on IRC, I *think* this would be fixed if we replaced > "koha_$name" __INSTANCENAME__, instead of just $name. That should of course be __KOHASITE__, not __INSTANCENAME__.
...and we would need to change line 744 of koha-create accordingly: sed "s/__KOHASITE__/$name/g" |
Created attachment 55338 [details] [review] Bug 17265 - Make koha-create-defaults less greedy koha-create-defaults substitutes the instance name with the placeholder __KOHASITE__ in the SQL file that it creates. If the instance name is something common, like "data", this means that way too many substitutions will be made, and when koha-create uses the SQL file as a template, broken data can be the result. The solution in this patch was suggested by drojf on IRC. To test: - Create an instance called "data" - Run "sudo koha-dump-defaults data > test.sql" - Take a look at test.sql and verify there are way too many occurences of __KOHASITE__, like "-- Dumping __KOHASITE__ for table `accountlines`" - Apply the patch - Copy the resulting koha-create and koha-dump-defaults to somewhere running off the packages - Run "sudo koha-dump-defaults data > test.sql" again and verify there are only 4 occurrences of __KOHASITE__, in places that make sense - Create an instance with something like: $ gzip test.sql $ sudo koha-create --create-db --defaultsql test.sql.gz test17265 - Verify that you have a working Koha install
Apologies for being pedantic, but may I suggest a small change to the bug title? 'koha-create-defaults' is not a valid command. In order to find this bug in future BZ/git searches for 'koha-create' or 'koha-dump-defaults' I think the title should be: "Make koha-create and koha-dump-defaults less greedy"
Created attachment 55458 [details] [review] Bug 17265 - Make koha-create-defaults less greedy koha-create-defaults substitutes the instance name with the placeholder __KOHASITE__ in the SQL file that it creates. If the instance name is something common, like "data", this means that way too many substitutions will be made, and when koha-create uses the SQL file as a template, broken data can be the result. The solution in this patch was suggested by drojf on IRC. To test: - Create an instance called "data" - Run "sudo koha-dump-defaults data > test.sql" - Take a look at test.sql and verify there are way too many occurences of __KOHASITE__, like "-- Dumping __KOHASITE__ for table `accountlines`" - Apply the patch - Copy the resulting koha-create and koha-dump-defaults to somewhere running off the packages - Run "sudo koha-dump-defaults data > test.sql" again and verify there are only 4 occurrences of __KOHASITE__, in places that make sense - Create an instance with something like: $ gzip test.sql $ sudo koha-create --create-db --defaultsql test.sql.gz test17265 - Verify that you have a working Koha install Signed-off-by: Andreas Roussos <arouss1980@gmail.com> Works as expected.
Changed the bug title according to Andreas' suggestion. :)
Sorry, forgot to set Status to 'Signed Off', setting it now.
Created attachment 58540 [details] [review] Bug 17265 - Make koha-create-defaults less greedy koha-create-defaults substitutes the instance name with the placeholder __KOHASITE__ in the SQL file that it creates. If the instance name is something common, like "data", this means that way too many substitutions will be made, and when koha-create uses the SQL file as a template, broken data can be the result. The solution in this patch was suggested by drojf on IRC. To test: - Create an instance called "data" - Run "sudo koha-dump-defaults data > test.sql" - Take a look at test.sql and verify there are way too many occurences of __KOHASITE__, like "-- Dumping __KOHASITE__ for table `accountlines`" - Apply the patch - Copy the resulting koha-create and koha-dump-defaults to somewhere running off the packages - Run "sudo koha-dump-defaults data > test.sql" again and verify there are only 4 occurrences of __KOHASITE__, in places that make sense - Create an instance with something like: $ gzip test.sql $ sudo koha-create --create-db --defaultsql test.sql.gz test17265 - Verify that you have a working Koha install Signed-off-by: Andreas Roussos <arouss1980@gmail.com> Works as expected. Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Pushed to master for 17.05, thanks Magnus!
This patch has been pushed to 16.11.x and will be in 16.11.02.
Pushed to 3.22.x for 3.22.15
Pushed to 16.05.x, for 16.05.08 release