[Koha-patches] [PATCH] added another check to MARC framework test

Galen Charlton galen.charlton at liblime.com
Sat Apr 19 00:11:42 CEST 2008


Check verifies that all subfields for each tag
are assigned to the same editor tab (or are ignored).

This situation can lead to data corruption, because
if an incoming MARC record has a field whose subfields
are assigned to different tabs, the first time that
record is saved in the bib editor, the field
will be split into multiple versions, each containing
the subfields assigned to a given tab.

Errors identified by this test known
in the MARC21 frameworks - I'm working on a patch to
correct those.
---
 admin/checkmarc.pl                                 |   17 ++++++++++
 .../prog/en/modules/admin/checkmarc.tmpl           |   33 ++++++++++++++++++++
 2 files changed, 50 insertions(+), 0 deletions(-)

diff --git a/admin/checkmarc.pl b/admin/checkmarc.pl
index 2283f20..0632cd4 100755
--- a/admin/checkmarc.pl
+++ b/admin/checkmarc.pl
@@ -181,6 +181,23 @@ if ($res) {
 	$total++;
 }
 
+# verify that all of a field's subfields (except the ones explicitly ignore) 
+# are in the same tab
+$sth = $dbh->prepare("SELECT tagfield, frameworkcode, frameworktext, GROUP_CONCAT(DISTINCT tab) AS tabs
+                      FROM marc_subfield_structure
+                      LEFT JOIN biblio_framework USING (frameworkcode)
+                      WHERE tab != -1
+                      GROUP BY tagfield, frameworkcode, frameworktext
+                      HAVING COUNT(DISTINCT tab) > 1");
+$sth->execute;
+my $inconsistent_tabs = $sth->fetchall_arrayref({});
+if (scalar(@$inconsistent_tabs) > 0) {
+    $total++;
+    $template->param(inconsistent_tabs => 1);
+    $template->param(tab_info => $inconsistent_tabs);
+}
+
 $template->param(total => $total,
 		);
+
 output_html_with_http_headers $input, $cookie, $template->output;
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/checkmarc.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/checkmarc.tmpl
index 81a04cb..dd6e1f6 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/checkmarc.tmpl
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/checkmarc.tmpl
@@ -155,6 +155,39 @@
         </tr>
     <!-- /TMPL_IF -->
 
+    <!-- TMPL_IF NAME="inconsistent_tabs" -->
+        <tr>
+            <td style="vertical-align:top;">subfields not in same tabs</td>
+            <td>Not all subfields for the following tags are in the same tab (or marked 'ignored').
+                <table>
+                    <tr>
+                        <th>Codek</th>
+                        <th>Description</th>
+                        <th>Tag</th>
+                        <th>Tabs in use</th>
+                    </tr>
+                    <!-- TMPL_LOOP NAME="tab_info" -->
+                        <tr>
+                            <td><!-- TMPL_VAR NAME="frameworkcode" --></td>
+                            <!-- TMPL_IF NAME="frameworkcode" -->
+                                <td><!-- TMPL_VAR NAME="frameworktext" --></td>
+                            <!-- TMPL_ELSE -->
+                                <td>Default framework</td>
+                            <!-- /TMPL_IF -->
+                            <td><!-- TMPL_VAR NAME="tagfield" --></td>
+                            <td><!-- TMPL_VAR NAME="tabs" --></td>
+                        </tr>
+                    <!-- /TMPL_LOOP -->
+                </table>
+            </td>
+        </tr>
+    <!-- TMPL_ELSE -->
+        <tr>
+            <td>OK</td>
+            <td>all subfields for each tag are in the same tab (or ignored)</td>
+        </tr>
+    <!-- /TMPL_IF -->
+
 <!-- -->
 <!-- TMPL_IF name="total" -->
     <tr>
-- 
1.5.5.rc0.16.g02b00




More information about the Koha-patches mailing list