[Koha-patches] [PATCH 35/35] Removing hyphens from isbn and issn when cataloging a biblio. It removes hyphens from isbn and issn only in marcxml, not in the field isbn in biblioitems where it is in the original format

Ian Walls ian.walls at bywatersolutions.com
Thu Jul 14 20:32:49 CEST 2011


Juan,


It's a good idea, to be sure, but some additional work needs to be done
before it can pass Koha QA.

1.  As Nicole said, even though it's an enhancement, we need a bug report on
file in bugs.koha-community.org.  Part of the paperwork we do to keep track
of things.  This is where you can lay out all the details of the
development, any limitations to it, and how to test.

2.  The new system preference needs to be added to the system preferences
editor, mostly logically under Cataloging.

3.  The new system preference must also be added to the system preference
SQL files for each of the non-English languages that come in the git repo.
This ensures that anyone doing a new installation will get this system
preference, regardless of their install language.

4.  The new system preference should default to "off", not "on", so that the
original system behaviour is preserved when folks upgrade.  It should be
"opt-in", not "opt-out".

5.  This enhancement ignores NORMARC, the third marcflavour supported by
Koha.  I don't know what fields ISBN/ISSN are in, and if they're the same as
one of the other flavours, then an explicit check should be added to that
part of the conditional (for future growth and stability of the system).

6.  Koha version setting is done by the Release Manager; typically, we don't
include changes to kohaversion.pl in the submitted patch, and the value in
updatedatabase.pl is "3.05.00.XXX" instead of what the next DB revision
number would be at the time of submission.


Sorry to throw more work at you; your contribution is very much appreciated,
and it's just these small matters that need attending to before we can get
it into Koha (well, that and testing, of course).

Cheers,


-Ian
QA Manager for Koha 3.6

On Thu, Jul 14, 2011 at 2:03 PM, Juan F. Romay Sieira <
juan.sieira at xercode.es> wrote:

> **
> There is not a bug, I think. The question is about the search of an isbn
> without hyphens. If isbn is indexed with hyphens, and you try to search for
> it with them, you'll not found it. This feature will index the isbn and issn
> whithout hyphens and will remove hyphens from search if you try to find a
> query like 978-84-92404-61-2.
> To try the patch, simply execute installer/data/mysql/updatedatabase.pl to
> insert the new syspref, insert a biblio and try to search it.
>
>
>  El 14/07/11 19:33, Nicole Engard escribió:
>
> What is the bug number for this? and can you include instructions for
> testing on the bug or in the patch please.
>
>
> Nicole
>
> On Thu, Jul 14, 2011 at 1:01 PM, Juan Romay Sieira <juan.sieira at xercode.es
> > wrote:
>
>> ---
>>  C4/Biblio.pm                                   |   34
>> ++++++++++++++++++++++++
>>  C4/Search.pm                                   |    1 +
>>  installer/data/mysql/en/mandatory/sysprefs.sql |    1 +
>>  installer/data/mysql/updatedatabase.pl         |    7 +++++
>>  kohaversion.pl                                 |    2 +-
>>  5 files changed, 44 insertions(+), 1 deletions(-)
>>
>> diff --git a/C4/Biblio.pm b/C4/Biblio.pm
>> index d797f40..332d476 100644
>> --- a/C4/Biblio.pm
>> +++ b/C4/Biblio.pm
>> @@ -3461,6 +3461,40 @@ sub ModBiblioMarc {
>>         # the previous version of the record
>>         $oldRecord = GetMarcBiblio($biblionumber);
>>     }
>> +
>> +    #
>> +    if (C4::Context->preference("IsbnIssnRemoveHyphens")){
>> +           my $isbn;
>> +           my $issn;
>> +               if ( $encoding eq 'UNIMARC' ) {
>> +                       if ( my $f010 = $record->field('010') ) {
>> +                               if ( $f010->subfield('a') ) {
>> +                                       $isbn = $f010->subfield('a');
>> +                                       $isbn =~ s/-//g;
>> +                                       $f010->update( 'a' => $isbn );
>> +                               }
>> +                       }
>> +                       if ( my $f011 = $record->field('011') ) {
>> +                               if ( $f011->subfield('a') ) {
>> +                                       $issn = $f011->subfield('a');
>> +                                       $issn =~ s/-//g;
>> +                                       $f011->update( 'a' => $issn );
>> +                               }
>> +                       }
>> +               } else {
>> +                       if ( my $f020 = $record->field('020') ) {
>> +                               $isbn = $f020->subfield('a');
>> +                               $isbn =~ s/-//g;
>> +                               $f020->update( 'a' => $isbn );
>> +                       }
>> +                       if ( my $f022 = $record->field('022') ) {
>> +                               $issn = $f022->subfield('a');
>> +                               $issn =~ s/-//g;
>> +                               $f022->update( 'a' => $issn );
>> +                       }
>> +               }
>> +    }
>> +
>>     $sth = $dbh->prepare("UPDATE biblioitems SET marc=?,marcxml=? WHERE
>> biblionumber=?");
>>     $sth->execute( $record->as_usmarc(),
>> $record->as_xml_record($encoding), $biblionumber );
>>     $sth->finish;
>> diff --git a/C4/Search.pm b/C4/Search.pm
>> index c3cff65..2bc934f 100644
>> --- a/C4/Search.pm
>> +++ b/C4/Search.pm
>> @@ -1159,6 +1159,7 @@ sub buildQuery {
>>                 }
>>                 # ISBN,ISSN,Standard Number, don't need special treatment
>>                 elsif ( $index eq 'nb' || $index eq 'ns' ) {
>> +                       $operand =~ s/-//g if
>> (C4::Context->preference("IsbnIssnRemoveHyphens"));
>>                     (
>>                         $stemming,      $auto_truncation,
>>                         $weight_fields, $fuzzy_enabled,
>> diff --git a/installer/data/mysql/en/mandatory/sysprefs.sql
>> b/installer/data/mysql/en/mandatory/sysprefs.sql
>> index 0abf9d8..991c80a 100755
>> --- a/installer/data/mysql/en/mandatory/sysprefs.sql
>> +++ b/installer/data/mysql/en/mandatory/sysprefs.sql
>> @@ -314,3 +314,4 @@ INSERT INTO `systempreferences`
>> (variable,value,explanation,options,type) VALUES
>>  INSERT INTO `systempreferences` (variable,value,explanation,options,type)
>> VALUES('OpacHiddenItems','','This syspref allows to define custom rules for
>> hiding specific items at opac. See docs/opac/OpacHiddenItems.txt for more
>> informations.','','Textarea');
>>  INSERT INTO `systempreferences` (variable,value,explanation,options,type)
>> VALUES('numSearchRSSResults',50,'Specify the maximum number of results to
>> display on a RSS page of results',NULL,'Integer');
>>  INSERT INTO systempreferences (variable,value,explanation,options,type)
>> VALUES ('OpacRenewalBranch','checkoutbranch','Choose how the branch for an
>> OPAC renewal is recorded in
>> statistics','itemhomebranch|patronhomebranch|checkoutbranch|null','Choice');
>> +INSERT INTO `systempreferences` (`variable`, `value`, `options`,
>> `explanation`, `type`) VALUES ('IsbnIssnRemoveHyphens', '1', '', 'Remove or
>> not hyphens from ISBN and ISSN', 'YesNo');
>> diff --git a/installer/data/mysql/updatedatabase.plb/installer/data/mysql/
>> updatedatabase.pl
>> index 8fb9656..23daacf 100755
>> --- a/installer/data/mysql/updatedatabase.pl
>> +++ b/installer/data/mysql/updatedatabase.pl
>> @@ -4370,6 +4370,13 @@ if (C4::Context->preference("Version") <
>> TransformToNum($DBversion)) {
>>     SetVersion($DBversion);
>>  }
>>
>> +$DBversion = "3.05.00.005";
>> +if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
>> +    $dbh->do("INSERT INTO `systempreferences` (`variable`, `value`,
>> `options`, `explanation`, `type`) VALUES ('IsbnIssnRemoveHyphens', '1', '',
>> 'Remove or not hyphens from ISBN and ISSN', 'YesNo');");
>> +    print "Upgrade to $DBversion done (Add SysPref to remove hyphens or
>> not into isbn and issn)\n";
>> +    SetVersion($DBversion);
>> +}
>> +
>>  =head1 FUNCTIONS
>>
>>  =head2 DropAllForeignKeys($table)
>> diff --git a/kohaversion.pl b/kohaversion.pl
>> index 00bdbec..9021eb0 100644
>> --- a/kohaversion.pl
>> +++ b/kohaversion.pl
>> @@ -16,7 +16,7 @@ the kohaversion is divided in 4 parts :
>>  use strict;
>>
>>  sub kohaversion {
>> -    our $VERSION = '3.05.00.004';
>> +    our $VERSION = '3.05.00.005';
>>     # version needs to be set this way
>>     # so that it can be picked up by Makefile.PL
>>     # during install
>> --
>> 1.7.1
>>
>> _______________________________________________
>> Koha-patches mailing list
>> Koha-patches at lists.koha-community.org
>> http://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-patches
>> website : http://www.koha-community.org/
>> git : http://git.koha-community.org/
>> bugs : http://bugs.koha-community.org/
>>
>
>
> _______________________________________________
> Koha-patches mailing list
> Koha-patches at lists.koha-community.org
> http://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-patches
> website : http://www.koha-community.org/
> git : http://git.koha-community.org/
> bugs : http://bugs.koha-community.org/
>



-- 
Ian Walls
Lead Development Specialist
ByWater Solutions
Phone # (888) 900-8944
http://bywatersolutions.com
ian.walls at bywatersolutions.com
Twitter: @sekjal
-------------- next part --------------
An HTML attachment was scrubbed...
URL: </pipermail/koha-patches/attachments/20110714/9fee65bb/attachment-0001.htm>


More information about the Koha-patches mailing list