Koha-clms/misc/maintenance
Tomas Cohen Arazi 2d91c1e0eb
Bug 36365: Add a way for compare_es_to_db.pl to fix problems
This patch adds a new option switch `--fix` (or `-f`) to make the script
try to fix the problems it found.

Bonus: `--help` option switch added.

To test:
1. Apply this patch
2. Run:
   $ ktd --shell
  k$ perl -MKoha::SearchEngine -MKoha::SearchEngine::Indexer -e 'my $i = Koha::SearchEngine::Indexer->new({index => $Koha::SearchEngine::BIBLIOS_INDEX}); $i->delete_index([1]);'
=> SUCCESS: Bibliographic record #deleted from ES index
3. Run:
  k$ koha-mysql kohadev
   > DELETE FROM biblio WHERE biblionumber=2 OR biblionumber=3;
=> SUCCESS: Bibliographic records 2 and 3 deleted directly from the
database, no reindex triggered by Koha.
4. Run:
  k$ perl misc/maintenance/compare_es_to_db.pl
=> SUCCESS: The results from (2) and (3) are explained. [1]
5. Run:
  k$ perl misc/maintenance/compare_es_to_db.pl --fix
=> SUCCESS: It says it is gonna fix things
6. Repeat 4
=> SUCCESS: The problems we generated are no longer reported! They've
been fixed!
7. Sign off :-D

[1] Note KTD ships some broken records on purpose so devs need to deal
with a not-perfect DB everyday, and catch misses in the code.

Signed-off-by: Andrew Fuerste Henry <andrew@bywatersolutions.com>
Signed-off-by: Lisette Scheer <lisette@bywatersolutions.com>
Signed-off-by: Thomas Klausner <domm@plix.at>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
(cherry picked from commit 3669cb0eed)
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
2025-04-22 23:02:29 +02:00
..
UNIMARC_fix_collectiontitle.pl Bug 28617: Remove kohalib.pl and rely on PERL5LIB 2021-12-07 12:16:28 -10:00
UNIMARC_sync_date_created_with_marc_biblio.pl Bug 37791: (follow-up) Last occurence 2024-10-11 12:21:30 +02:00
acq_cancel_obsolete_orders.pl Bug 36068: (QA follow-up) Add OPTIONS section in POD 2024-04-19 18:06:31 +02:00
audit_database.pl Bug 36039: (QA follow-up): Improve audit messages 2025-03-19 23:57:33 +01:00
auth_show_hidden_data.pl Bug 17600: Standardize our EXPORT_OK 2021-07-16 08:58:47 +02:00
borrowers-force-messaging-defaults.pl Bug 33239: (QA follow-up) Tidy and improve description 2023-10-11 10:31:46 -03:00
check_syspref_cache.pl Bug 32922: Remove space in shebang 2023-02-20 09:44:06 -03:00
check_sysprefs.sh
…
cmp_sysprefs.pl Bug 17600: Standardize our EXPORT_OK 2021-07-16 08:58:47 +02:00
compare_es_to_db.pl Bug 36365: Add a way for compare_es_to_db.pl to fix problems 2025-04-22 23:02:29 +02:00
dedup_authorities.pl Bug 13706: Minor tidy/spelling issues 2024-04-26 14:14:54 +02:00
fix_accountlines_date.pl Bug 28617: Remove kohalib.pl and rely on PERL5LIB 2021-12-07 12:16:28 -10:00
fix_accountlines_rmdupfines_bug8253.pl Bug 28617: Remove kohalib.pl and rely on PERL5LIB 2021-12-07 12:16:28 -10:00
fix_invalid_dates.pl Bug 38857: Update cronjobs to log run before processing parameters 2025-04-22 23:01:33 +02:00
fix_mysql_constraints.pl Bug 28617: Remove kohalib.pl and rely on PERL5LIB 2021-12-07 12:16:28 -10:00
fix_tags_weight.pl Bug 17600: Standardize our EXPORT_OK 2021-07-16 08:58:47 +02:00
generate_MARC21Languages.pl Bug 33341: Address some perlcritic errors in 5.36 2023-03-28 14:50:33 +02:00
make_zebra_dom_cfg_from_record_abs Bug 22600: Set 'commandline' interface appropriately 2019-04-10 19:43:11 +00:00
process_record_through_filter.pl Bug 37791: (follow-up) Last occurence 2024-10-11 12:21:30 +02:00
pseudonymize_statistics.pl Bug 37181: Add --confirm option to pseudonymize_statistics.pl 2024-06-27 14:04:54 +02:00
remove_items_from_biblioitems.pl Bug 29697: Replace GetMarcBiblio occurrences with $biblio->metadata->record 2022-07-22 15:24:11 -03:00
sanitize_records.pl Bug 29697: Replace GetMarcBiblio occurrences with $biblio->metadata->record 2022-07-22 15:24:11 -03:00
search_for_data_inconsistencies.pl Bug 31143: (QA follow-up) Tidy 2024-10-23 20:02:21 +02:00
sync_db_comments.pl Bug 32334: Fix spelling 2023-04-12 11:22:04 -03:00
touch_all_biblios.pl Bug 37037: (RM follow-up) Add hint at end of script run 2024-06-13 13:40:06 +01:00
touch_all_items.pl Bug 28617: Remove kohalib.pl and rely on PERL5LIB 2021-12-07 12:16:28 -10:00
update_authorities.pl Bug 17600: Standardize our EXPORT_OK 2021-07-16 08:58:47 +02:00
update_localuse_from_statistics.pl Bug 37790: Add skip indexing and holds queue options and verbosity to update localuse script 2024-11-18 17:04:32 +01:00