Archivado en mayo 2011

Migración a 3.4: surgen problemas con registros|Migration to 3.4: record problems arise

31 mayo, 2011

Iniciando la planificación de la migración a Koha 3.4.1, nos topamos con que muchos registros contienen errores de codificación heredados de la migración inicial desde formatos muy diversos. Estos problemas pueden estar siendo arrastrados por décadas en las bases de datos, pero ahora que koha necesita eliminar los items de dentro de los registros MARC, al recorrer todo el catálogo estos problemas se convierten en un verdadero obstáculo para la actualización.

Para encarar una solución, analizamos las herramientas disponibles para chequear registros MARC21 en linea de comandos. Las soluciones usuales son MARC::Lint, y yaz-marcdump. Ambas son útiles en distinta medida, pero finalmente Koha tiene un tratamiento de los registros tan específico que fue necesario buscar en los scripts de koha las zonas donde suelen surgir los problemas y tratar de emular dicho funcionamiento.

Escribí entonces un script que llama a las funciones mas usuales que dan lugar a fallas graves por caracteres invalidos y otras yerbas.

Identificadas dichas operaciones problematicas, las invocamos dentro de un bloque try-catch para poder reportar el error. Con eso deberia bastar para generar una lista de biblionumbers a revisar antes de hacer un upgrade a 3.4 o cualquier otro tipo de chequeo de rutina que querramos hacer de la calidad de los registros que se van generando.

La sintaxis para usar el script es simple: los parámetros posibles son (1) '-d' si queremos un modo debug que nos va tirando los biblionumbers (no es muy útil realmente, solo lo use la primera vez para saber que script realmente estaba haciendo algo) y (2) -where "string" que permite limitar el chequeo a través de una clausula WHERE que se pega directamente al SELECT: para filtrar los biblionumbers digamos.

Como usa librerias de Koha y el archivo de configuracion para conectarse a la base de datos el comando debe ser llamado de la siguiente manera:
PERL5LIB=/usr/share/koha/lib KOHA_CONF=/etc/koha/koha-conf.xml /path/to/test_marc_records.pl

Para descargar el script hacer click aquí

Starting our planning for migrating to Koha 3.4.1, we found that during our first migration to koha we found that several registers contain encoding errors. This is normal as we migrated from several different sources and codifications, but as migration to 3.4 includes the removal of holdings data from MARC21 records, the script would fail to process our databases and hence this is a blocker for upgrading.

In finding a solution to the problem I used several useful tools like MARC::Lint and yaz-marcdump. Both are handy in different ways, but checking when koha would fail is easier once you notice the point of failure it has.

I then wrote a tiny script that calls those functions koha uses that aren't catched and are sentitive to encoding errors and other stuff.

I then wrap a call to those functions inside a try-catch block and report an error on failed records. That should be enough to have a list of biblionumbers that would make remove_items_from_biblioitems.pl fail when upgrading to 3.4.X or any other routine check you'd like to do.

The syntax used to run the script is pretty straight-forward: -d to print the current biblionumber (almost useless, only included as I wanted to know the script was doing *something*); and -where "string" which lets you introduce filters to the list of biblionumbers to be checked (copied from remove_items_from_biblioitems.pl).

As it uses several koha libs and configuration file to connect to th DB it should be called like this:
PERL5LIB=/usr/share/koha/lib KOHA_CONF=/etc/koha/koha-conf.xml /path/to/test_marc_records.pl

To download the script just click here