Bug 23871: data inconsistencies - check title exists
authorFridolin Somers <fridolin.somers@biblibre.com>
Tue, 22 Oct 2019 12:31:08 +0000 (14:31 +0200)
committerMartin Renvoize <martin.renvoize@ptfs-europe.com>
Tue, 14 Apr 2020 15:55:13 +0000 (16:55 +0100)
In biblio records, a field must be linked to biblio.title.
200$a in UNIMARC, 100$a MARC21 (and other).

If this field is undefined, some pages like checkouts table can fail.

Test plan :
1) Remove biblio title in SQL :
   UPDATE biblio SET title='' WHERE biblionumber=XXX
2) Run misc/maintenance/search_for_data_inconsistencies.pl
3) You see the record as an inconsistency
4) Reset a title
   UPDATE biblio SET title='50 shades of Grey' WHERE biblionumber=XXX
5) Run misc/maintenance/search_for_data_inconsistencies.pl
6) Record is no longer an inconsistency

Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

misc/maintenance/search_for_data_inconsistencies.pl

index 1790495..fd66200 100755 (executable)
@@ -25,6 +25,7 @@ use Koha::BiblioFrameworks;
 use Koha::Biblioitems;
 use Koha::Items;
 use Koha::ItemTypes;
+use C4::Biblio;
 
 {
     my $items = Koha::Items->search({ -or => { homebranch => undef, holdingbranch => undef }});
@@ -187,6 +188,20 @@ use Koha::ItemTypes;
     }
 }
 
+{
+    my $biblios = Koha::Biblios->search({ -or => { title => undef, title => '' }});
+    if ( $biblios->count ) {
+        my ( $title_tag, $title_subtag ) = C4::Biblio::GetMarcFromKohaField( 'biblio.title' );
+        my $title_field = $title_tag // '';
+        $title_field .= '$'.$title_subtag if $title_subtag;
+        new_section("Biblio without title $title_field");
+        while ( my $biblio = $biblios->next ) {
+            new_item(sprintf "Biblio with biblionumber=%s does not have title defined", $biblio->biblionumber);
+        }
+        new_hint("Edit these biblio records to defined a title");
+    }
+}
+
 sub new_section {
     my ( $name ) = @_;
     say "\n== $name ==";