Bug 22024: Correct new installations with missing data
authorKatrin Fischer <katrin.fischer.83@web.de>
Tue, 18 Dec 2018 21:43:05 +0000 (22:43 +0100)
committerMartin Renvoize <martin.renvoize@ptfs-europe.com>
Thu, 20 Dec 2018 09:55:36 +0000 (09:55 +0000)
commit84248f354249482b9d5e1cbfaea1ee82bff10218
treeb65459177ae51e71028a55bdab9f49ed90f0a692
parentb55f0079e2f228db795634fd9f88cb77cfecd1dd
Bug 22024: Correct new installations with missing data

For a new installation the data in the class_* will be
missing as class_sources.sql couldn't be executed. It will
fail with:

DBD::mysql::st execute failed: Cannot add or update a child row:
a foreign key constraint fails (`koha_kohadev`.`class_sources`,
CONSTRAINT `class_source_ibfk_2` FOREIGN KEY (`class_split_rule`)
REFERENCES `class_split_rules` (`class_split_rule`)) at /usr/share/perl5/DBIx/RunSQL.pm line 273.

As this might have been missed and the web installer can still
be completed, this patch checks for the tables being empty and
adds the default data if they are.

To test:
- Without the patch
- Run the de-DE or another translated installer
- Verify the error is shown
- Complete the installer
- Verify class_sources table is empty
- Apply patches
- Run the database update
- Verify data classification sources, filing rules, and
  slitting rules are now complete

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
(cherry picked from commit c904db832ec4ee70bfb58ff918564a2502a53937)
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
installer/data/mysql/atomicupdate/bug_22024-splitting-rules.perl [new file with mode: 0644]