[Koha] Software error: Can't call method "branchname" on an undefined value at /usr/share/koha/lib/C4/Biblio.pm line 1627.

Katrin Fischer katrin.fischer.83 at web.de
Mon Jan 20 04:28:24 NZDT 2020


Hi Bruck,

I am honestly not sure what to recommend to you in order to fix this. :(

You can't set the branchcode to NULL or empty - the branchcode is the
primary key of the branches table and referenced in a lot of other
tables. Which is why this is not an easy fix. Ideally changing it in the
branches table would update the other tables - but I doubt that we have
FK in place for all the tables you'd want that to happen. You already
created a mix of values by running the SQL query on your items table.

If doing it in the GUI, the easiest way might be to create a new branch,
move all items, move all patrons and then delete the old branch. This
way you would still have statistics referring to the old branch, but it
might give you a clean starting point again.

Katrin


On 17.01.20 09:28, Tadesse, Bruck wrote:
>
> Hi Katrin,
>
> Thanks. The result of the first query shows that there were two items
> that had the extra space. That fixes the problem with the “in transit”
> issue. The result of second query “
>
> mysql>
>
> SELECT * from branches WHERE CHAR_LENGTH(branchcode) !=
> CHAR_LENGTH("WIDER");” shows one record. From what I see there is only
> one record in the whole table, please see below the result and it
> seems that branchcode has extra space on it.
>
> | branchcode  | branchname        |
>
> +------------+-------------------+
>
> | WIDER      | UNU-WIDER Library |
>
> +------------+-------------------
>
> My question are:
>
>   * whether it is possible to set this value to null/empty since we
>     have only have on branch?
>   * Where is the best place to rectify the extra space for the
>     branchcode - in the backend or on staff/client?
>
> Many thanks,
>
> Thanks,
>
> Bruck T.
>
> *From:* Katrin Fischer <katrin.fischer.83 at web.de>
> *Sent:* Thursday, January 16, 2020 12:31 AM
> *To:* Tadesse, Bruck <bruck at wider.unu.edu>
> *Cc:* koha at lists.katipo.co.nz
> *Subject:* Re: [Koha] Software error: Can't call method "branchname"
> on an undefined value at /usr/share/koha/lib/C4/Biblio.pm line 1627.
>
> Hi Bruck,
>
> that's a wild guess now, but it's something we have seen happen: an
> extra space somewhere will not show in your SQL queries and results -
> branchcodes with and without will even group together. But Perl
> notices the difference when comparing strings. Say Koha finds "WIDER"
> in the item, but your configured branch is  "WIDER " - then it will
> attempt to send it to the latter and put the item 'in transit'.
>
> I am not quite sure how to best check for that, something along these
> lines might work:
>
> SELECT * from items WHERE
>     CHAR_LENGTH(homebranch) != CHAR_LENGTH("WIDER")
>     OR CHAR_LENGTH(holding) != CHAR_LENGTH("WIDER");
>
> SELECT * from branches WHERE CHAR_LENGTH(branchcode) !=
> CHAR_LENGTH("WIDER")
>
> Also: Check if you have default values set for $a $b in your
> frameworks and if there are any extra spaces there.
>
> Hope this helps,
>
> Katrin
>
> On 15.01.20 11:09, Tadesse, Bruck wrote:
>
>     Hi Katrin,
>
>     Thanks, please see below the result of the queries. After encountering the problem, we added a value (the same value as our home branch since we only have one library) to the branch in the backend.  The system picks it as a separate entity and a checked in item is set to ‘in transit’.  Somehow, adding the branch value cause another issue in our check-in. And it did not resolve our existing branch problem. All these functions were working well before our upgrade.
>
>     *******************************************
>
>     mysql> select homebranch, holdingbranch from items group by homebranch, holdingbranch;
>
>     +------------+---------------+
>
>     | homebranch | holdingbranch |
>
>     +------------+---------------+
>
>     | WIDER      | WIDER         |
>
>     +------------+---------------+
>
>     *******************************************************
>
>     mysql> select frameworkcode, tagfield, tagsubfield, authorised_value from marc_subfield_structure where authorised_value = 'branches';
>
>     +---------------+----------+-------------+------------------+
>
>     | frameworkcode | tagfield | tagsubfield | authorised_value |
>
>     +---------------+----------+-------------+------------------+
>
>     |               | 952      | a           | branches         |
>
>     |               | 952      | b           | branches         |
>
>     | AR            | 952      | a           | branches         |
>
>     | AR            | 952      | b           | branches         |
>
>     | BKS           | 952      | a           | branches         |
>
>     | BKS           | 952      | b           | branches         |
>
>     | CD            | 952      | a           | branches         |
>
>     | CD            | 952      | b           | branches         |
>
>     | DBS           | 952      | a           | branches         |
>
>     | DBS           | 952      | b           | branches         |
>
>     | EBK           | 952      | a           | branches         |
>
>     | EBK           | 952      | b           | branches         |
>
>     | EBS           | 952      | a           | branches         |
>
>     | EBS           | 952      | b           | branches         |
>
>     | EJ            | 952      | a           | branches         |
>
>     | EJ            | 952      | b           | branches         |
>
>     | FA            | 952      | a           | branches         |
>
>     | FA            | 952      | b           | branches         |
>
>     | ILLS          | 952      | a           | branches         |
>
>     | ILLS          | 952      | b           | branches         |
>
>     | IR            | 952      | a           | branches         |
>
>     | IR            | 952      | b           | branches         |
>
>     | LD            | 952      | a           | branches         |
>
>     | LD            | 952      | b           | branches         |
>
>     | MONO          | 952      | a           | branches         |
>
>     | MONO          | 952      | b           | branches         |
>
>     | OECD          | 952      | a           | branches         |
>
>     | OECD          | 952      | b           | branches         |
>
>     | OECE          | 952      | a           | branches         |
>
>     | OECE          | 952      | b           | branches         |
>
>     | ON            | 952      | a           | branches         |
>
>     | ON            | 952      | b           | branches         |
>
>     | PER           | 952      | a           | branches         |
>
>     | PER           | 952      | b           | branches         |
>
>     | WID           | 952      | a           | branches         |
>
>     | WID           | 952      | b           | branches         |
>
>     +---------------+----------+-------------+------------------+
>
>     Thanks,
>
>     Bruck T.
>
>     -----Original Message-----
>
>     From: Katrin Fischer<katrin.fischer.83 at web.de>  <mailto:katrin.fischer.83 at web.de>
>
>     Sent: Wednesday, January 15, 2020 9:11 AM
>
>     To: Tadesse, Bruck<bruck at wider.unu.edu>  <mailto:bruck at wider.unu.edu>
>
>     Cc:koha at lists.katipo.co.nz  <mailto:koha at lists.katipo.co.nz>
>
>     Subject: Re: [Koha] Software error: Can't call method "branchname" on an undefined value at /usr/share/koha/lib/C4/Biblio.pm line 1627.
>
>     Hi Bruck,
>
>     first thing that comes to mind is if you have modified your frameworks from the default, especially the 952 fields?
>
>     Some things that could be interesting:
>
>     select homebranch, holdingbranch from items group by homebranch, holdingbranch;
>
>     You should then see if there are values that are not valid branchcodes in your system.
>
>     What does the configuration of your 952 fields look like? Especially $a and $b?
>
>     select tagfield, tagsubfield from marc_subfield_structure where authorised_value="branches";
>
>     What does your item form look like? For example you can compare it to one of our demo installations that should be closer to default.
>
>     Maybe this could get you a step closer.
>
>     Katrin
>
>     On 13.01.20 14:11, Tadesse, Bruck wrote:
>
>         Hi Jonathan and Katrin,
>
>         Happy New Year! The problem with our Koha instances still is not resolved. We are still unable to edit items. Since you know the problem already, I am turning to you again for help.
>
>         Many thanks,
>
>         Bruck T.
>
>         -----Original Message-----
>
>         From: Koha<koha-bounces at lists.katipo.co.nz>  <mailto:koha-bounces at lists.katipo.co.nz>  On Behalf Of Tadesse,
>
>         Bruck
>
>         Sent: Thursday, December 19, 2019 2:11 PM
>
>         To: Katrin Fischer<Katrin.Fischer.83 at web.de>  <mailto:Katrin.Fischer.83 at web.de>
>
>         Cc:koha at lists.katipo.co.nz  <mailto:koha at lists.katipo.co.nz>
>
>         Subject: Re: [Koha] Software error: Can't call method "branchname" on an undefined value at /usr/share/koha/lib/C4/Biblio.pm line 1627.
>
>         Hi Katrin,
>
>         Thanks, I have never used a client for IRC, but I will try pidgin. What would be the address then? Is it irc.oftc.net:6667  ?
>
>         thanks,
>
>         Bruck T
>
>         From: Katrin Fischer<Katrin.Fischer.83 at web.de>  <mailto:Katrin.Fischer.83 at web.de>
>
>         Sent: Thursday, December 19, 2019 12:21 PM
>
>         To: Tadesse, Bruck<bruck at wider.unu.edu>  <mailto:bruck at wider.unu.edu>
>
>         Cc: Jonathan Druart<jonathan.druart at bugs.koha-community.org>  <mailto:jonathan.druart at bugs.koha-community.org>;
>
>         koha at lists.katipo.co.nz  <mailto:koha at lists.katipo.co.nz>
>
>         Subject: Aw: Re: [Koha] Software error: Can't call method "branchname" on an undefined value at /usr/share/koha/lib/C4/Biblio.pm line 1627.
>
>         Hi Bruck,
>
>         the web link hasn't worked for me in a while - the #koha tab doesn't open and only the status one is shown for me. Do you have access to a program like pidgin or another IRC client maybe that you could use instead?
>
>         Katrin
>
>         Gesendet: Donnerstag, 19. Dezember 2019 um 11:03 Uhr
>
>         Von: "Tadesse, Bruck"
>
>         <bruck at wider.unu.edu  <mailto:bruck at wider.unu.edu><mailto:bruck at wider.unu.edu>  <mailto:bruck at wider.unu.edu>>
>
>         An: "Jonathan Druart"
>
>         <jonathan.druart at bugs.koha-community.org  <mailto:jonathan.druart at bugs.koha-community.org><mailto:jonathan.druart at bugs.k  <mailto:jonathan.druart at bugs.koha-community.org>
>
>         oha-community.org>
>         <mailto:jonathan.druart at bugs.koha-community.org>>
>
>         Cc: "koha at lists.katipo.co.nz  <mailto:koha at lists.katipo.co.nz><mailto:koha at lists.katipo.co.nz>  <mailto:koha at lists.katipo.co.nz>"
>
>         <koha at lists.katipo.co.nz  <mailto:koha at lists.katipo.co.nz><mailto:koha at lists.katipo.co.nz>  <mailto:koha at lists.katipo.co.nz>>
>
>         Betreff: Re: [Koha] Software error: Can't call method "branchname" on an undefined value at /usr/share/koha/lib/C4/Biblio.pm line 1627.
>
>         Hi Jonathan,
>
>         I have been connected to this Koha channel (https://webchat.oftc.net/?channels=koha) through a browser for a while now, but I do not see any activity. May be I am not in the right, Can you send me the link to the right channel.
>
>         Many thanks,
>
>         Bruck T.
>
>         -----Original Message-----
>
>         From: Jonathan Druart
>
>         <jonathan.druart at bugs.koha-community.org  <mailto:jonathan.druart at bugs.koha-community.org><mailto:jonathan.druart at bugs.k  <mailto:jonathan.druart at bugs.koha-community.org>
>
>         oha-community.org>
>         <mailto:jonathan.druart at bugs.koha-community.org>>
>
>         Sent: Wednesday, December 18, 2019 6:36 PM
>
>         To: Tadesse, Bruck <bruck at wider.unu.edu  <mailto:bruck at wider.unu.edu><mailto:bruck at wider.unu.edu>  <mailto:bruck at wider.unu.edu>>
>
>         Cc:koha at lists.katipo.co.nz  <mailto:koha at lists.katipo.co.nz><mailto:koha at lists.katipo.co.nz>  <mailto:koha at lists.katipo.co.nz>
>
>         Subject: Re: [Koha] Software error: Can't call method "branchname" on an undefined value at /usr/share/koha/lib/C4/Biblio.pm line 1627.
>
>         I am expecting to see something just before this error. Maybe you did not restart plack?
>
>         Consider jumping into IRC and catch me there, that would be easier ;)
>
>         Le mer. 18 déc. 2019 à 17:09, Tadesse, Bruck <bruck at wider.unu.edu  <mailto:bruck at wider.unu.edu><mailto:bruck at wider.unu.edu>  <mailto:bruck at wider.unu.edu>> a écrit :
>
>             Jonathan,
>
>             I am not sure if I am looking in the right place and thanks for your patient with me. I opened the " intranet-error.log " log file (tail -f intranet-error.log) in the backend and see the result below. Could this be any helpful.
>
>             Thanks.
>
>             Bruck.-
>
>             *********************************
>
>             [Wed Dec 18 15:59:18.279781 2019] [cgi:error] [pid 19666] [client
>
>             172.22.3.115:59956] AH01215: [Wed Dec 18 15:59:18 2019] additem.pl:
>
>             Can't call method "branchname" on an undefined value at
>
>             /usr/share/koha/lib/C4/Biblio.pm line 1627.:
>
>             /usr/share/koha/intranet/cgi-bin/cataloguing/additem.pl, referer:
>
>             http://koha.wider.unu.edu:8080/cgi-bin/koha/catalogue/detail.pl?bibli
>
>             o
>
>             number=8418&searchid=scs_1576671122887
>
>             *********************************
>
>             -----Original Message-----
>
>             From: Jonathan Druart
>
>             <jonathan.druart at bugs.koha-community.org  <mailto:jonathan.druart at bugs.koha-community.org><mailto:jonathan.druart at bugs.  <mailto:jonathan.druart at bugs.koha-community.org>
>
>             k<mailto:jonathan.druart at bugs.koha-community.org>
>
>             oha-community.org>
>             <mailto:jonathan.druart at bugs.koha-community.org>>
>
>             Sent: Wednesday, December 18, 2019 3:15 PM
>
>             To: Tadesse, Bruck <bruck at wider.unu.edu  <mailto:bruck at wider.unu.edu><mailto:bruck at wider.unu.edu>  <mailto:bruck at wider.unu.edu>>
>
>             Cc:koha at lists.katipo.co.nz  <mailto:koha at lists.katipo.co.nz><mailto:koha at lists.katipo.co.nz>  <mailto:koha at lists.katipo.co.nz>
>
>             Subject: Re: [Koha] Software error: Can't call method "branchname" on an undefined value at /usr/share/koha/lib/C4/Biblio.pm line 1627.
>
>             Have a look at the Koha log file, you should see the value of $value in it.
>
>             Le mer. 18 déc. 2019 à 13:23, Tadesse, Bruck <bruck at wider.unu.edu  <mailto:bruck at wider.unu.edu><mailto:bruck at wider.unu.edu>  <mailto:bruck at wider.unu.edu>> a écrit :
>
>                 Jonathan,
>
>                 Thanks, the SQL query returns empty set. I have also added the debug statement just before the line 1627 and there is no change to the error message. Thinking it is a browser cache issue, I changed computer and browser, the debug statement didn’t bring any change to the error message.
>
>                 This is how it looks now in ...C4/biblio.pm
>
>                 #---- branch
>
>                 if ( $tagslib->{$tag}->{$subfield}->{'authorised_value'} eq
>
>                 "branches" ) { warn $value; return
>
>                 Koha::Libraries->find($value)->branchname;
>
>                 }
>
>                 Thanks,
>
>                 Bruck T.
>
>                 -----Original Message-----
>
>                 From: Jonathan Druart
>
>                 <jonathan.druart at bugs.koha-community.org  <mailto:jonathan.druart at bugs.koha-community.org><mailto:jonathan.druart at bugs  <mailto:jonathan.druart at bugs.koha-community.org>
>
>                 .koha-community.org>
>                 <mailto:jonathan.druart at bugs.koha-community.org>>
>
>                 Sent: Wednesday, December 18, 2019 1:22 PM
>
>                 To: Tadesse, Bruck <bruck at wider.unu.edu  <mailto:bruck at wider.unu.edu><mailto:bruck at wider.unu.edu>  <mailto:bruck at wider.unu.edu>>
>
>                 Cc:koha at lists.katipo.co.nz  <mailto:koha at lists.katipo.co.nz><mailto:koha at lists.katipo.co.nz>  <mailto:koha at lists.katipo.co.nz>
>
>                 Subject: Re: [Koha] Software error: Can't call method "branchname" on an undefined value at /usr/share/koha/lib/C4/Biblio.pm line 1627.
>
>                 Bruck,
>
>                 My understanding of the error is that you have a field that is mapped with the "authorised value" branches (that's not a real authorised value). But at least one of those field has a value that is not a branchcode defined in your system.
>
>                 The weird thing is that, by default, only item's fields are mapped with "branches", 952$a and 952$b Can you try this SQL query: select tagfield, tagsubfield from marc_subfield_structure where authorised_value="branches" and tagfield != 952; Does it return something?
>
>                 To know which value we are searching search, you could also add a
>
>                 debug statement warn $value; before
>
>                 1627 return Koha::Libraries->find($value)->branchname;
>
>                 Regards,
>
>                 Jonathan
>
>                 Le mer. 18 déc. 2019 à 11:37, Tadesse, Bruck <bruck at wider.unu.edu  <mailto:bruck at wider.unu.edu><mailto:bruck at wider.unu.edu>  <mailto:bruck at wider.unu.edu>> a écrit :
>
>                     Dear Karam,
>
>                     Thanks, Since the update didn’t result in solving the problem, I will revert back for now. I have taken a snapshot of the VM, so it easy to do that. I would still appreciate any advice that would help me resolve the underlying problem of updating the items.
>
>                     Thanks,
>
>                     Bruck T.
>
>                     From: Karam Qubsi
>
>                     <karamqubsi at gmail.com  <mailto:karamqubsi at gmail.com><mailto:karamqubsi at gmail.com>  <mailto:karamqubsi at gmail.com>>
>
>                     Sent: Wednesday, December 18, 2019 12:26 PM
>
>                     To: Tadesse, Bruck
>
>                     <bruck at wider.unu.edu  <mailto:bruck at wider.unu.edu><mailto:bruck at wider.unu.edu>  <mailto:bruck at wider.unu.edu>>
>
>                     Cc:koha at lists.katipo.co.nz  <mailto:koha at lists.katipo.co.nz><mailto:koha at lists.katipo.co.nz>  <mailto:koha at lists.katipo.co.nz>;
>
>                     Allonen, Lay Poh
>
>                     <allonen at wider.unu.edu  <mailto:allonen at wider.unu.edu><mailto:allonen at wider.unu.edu>  <mailto:allonen at wider.unu.edu>>
>
>                     Subject: Re: [Koha] Software error: Can't call method "branchname" on an undefined value at /usr/share/koha/lib/C4/Biblio.pm line 1627.
>
>                     Hello Bruck,
>
>                     This query (UPDATE items SET homebranch='LIB', holdingbranch='LIB') ) is very dangerous.
>
>                     This will set all (homebranch and holdingbranch ) in your items table to be LIB for all items!
>
>                     if that is not what you want, then try to retrieve a backup from ( /var/spool/koha ) or anywhere else you store your backups .
>
>                     Please note that LIB should be one of your branches custom code. so are you sure it is LIB in your Koha installation ?
>
>                     Regards.
>
>                     On Wed, Dec 18, 2019 at 5:27 PM Tadesse, Bruck <bruck at wider.unu.edu  <mailto:bruck at wider.unu.edu><mailto:bruck at wider.unu.edu<mailto:bruck at wider.unu.edu%3cmailto:bruck at wider.unu.edu>  <mailto:bruck at wider.unu.edu%3cmailto:bruck at wider.unu.edu>>> wrote:
>
>                     Hi All,
>
>                     I have just recently upgraded to 17.05 from 16.05 and when I try to edit items on Koha, it throws the following error "Can't call method "branchname" on an undefined value at /usr/share/koha/lib/C4/Biblio.pm line 1627". I search the archive online saw the advice to update the two fields<https://lists.katipo.co.nz/public/koha/2017-September/048966.html>  <https://lists.katipo.co.nz/public/koha/2017-September/048966.html>  (UPDATE items SET homebranch='LIB', holdingbranch='LIB'). I have done that and did the full reindex. But, that does not seem to have helped. Please advise.
>
>                     Many thanks,
>
>                     Bruck Tadesse
>
>                     _______________________________________________
>
>                     Koha mailing listhttp://koha-community.org
>
>                     Koha at lists.katipo.co.nz  <mailto:Koha at lists.katipo.co.nz><mailto:Koha at lists.katipo.co.nz<mailto:Koha  <mailto:Koha at lists.katipo.co.nz%3cmailto:Koha at lists.katipo.co.nz>
>
>                     @lists.katipo.co.nz%3cmailto:Koha at lists.katipo.co.nz>
>                     <mailto:Koha at lists.katipo.co.nz%3cmailto:Koha at lists.katipo.co.nz>>
>
>                     https://lists.katipo.co.nz/mailman/listinfo/koha
>
>                     --
>
>                     Karam Qubsi
>
>                     _______________________________________________
>
>                     Koha mailing listhttp://koha-community.org
>
>                     Koha at lists.katipo.co.nz  <mailto:Koha at lists.katipo.co.nz><mailto:Koha at lists.katipo.co.nz>  <mailto:Koha at lists.katipo.co.nz>
>
>                     https://lists.katipo.co.nz/mailman/listinfo/koha
>
>         _______________________________________________
>
>         Koha mailing listhttp://koha-community.org
>
>         Koha at lists.katipo.co.nz  <mailto:Koha at lists.katipo.co.nz><mailto:Koha at lists.katipo.co.nz>  <mailto:Koha at lists.katipo.co.nz>
>
>         https://lists.katipo.co.nz/mailman/listinfo/koha
>
>         _______________________________________________
>
>         Koha mailing listhttp://koha-community.org  Koha at lists.katipo.co.nz  <mailto:Koha at lists.katipo.co.nz>
>
>         https://lists.katipo.co.nz/mailman/listinfo/koha
>


More information about the Koha mailing list