Bug 11781 - Error after setting IndependentBranches to 0
Summary: Error after setting IndependentBranches to 0
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: System Administration (show other bugs)
Version: 3.14
Hardware: All All
: P5 - low normal (vote)
Assignee: Bugs List
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-02-18 14:21 UTC by Homer
Modified: 2017-06-14 22:11 UTC (History)
2 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Homer 2014-02-18 14:21:12 UTC
The sequence below has happened twice so now i think it may be a bug, not a personal failure.

Environment
3.14.03.000
OS version ('uname -a'): 	Linux ID13723.example.com 3.8.0-29-generic #42~precise1-Ubuntu SMP Wed Aug 14 16:19:23 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
Perl interpreter: 	/usr/bin/perl
Perl version: 	5.014002
Perl @INC: 	/usr/share/koha/lib
/etc/perl
/usr/local/lib/perl/5.14.2
/usr/local/share/perl/5.14.2
/usr/lib/perl5
/usr/share/perl5
/usr/lib/perl/5.14
/usr/share/perl/5.14
/usr/local/lib/site_perl
.
MySQL version: 	mysql Ver 14.14 Distrib 5.5.35, for debian-linux-gnu (x86_64) using readline 6.2
Apache version: 	Server version: Apache/2.2.22 (Ubuntu)
Zebra version: 	Zebra 2.0.44

What happens

I set IndependentBranches to "prevent" using the admin interface. Immediately after setting the preference, everything works fine. In fact i work on koha configuration for the rest of the day, log off and back on several times and everything is fine. However, the next day (perhaps because the crons have run overnight) when i try to access the intranet, i get this error.

Software error:
Can't use an undefined value as a HASH reference at /usr/share/koha/intranet/cgi-bin/mainpage.pl line 53.
For help, please send mail to the webmaster ([no address given]), giving this error message and the time and date of the error. 

-----------

my $branch =
  C4::Context->preference("IndependentBranches")
  && !$flags->{'superlibrarian'}
  ? C4::Context->userenv()->{'branch'}
  : undef;

-----------


I log into the server and do the following

mysql> select * from systempreferences where variable="IndependentBranches";
+---------------------+-------+---------+---------------------------------------------+-------+
| variable            | value | options | explanation                                 | type  |
+---------------------+-------+---------+---------------------------------------------+-------+
| IndependentBranches | 1     | NULL    | If ON, increases security between libraries | YesNo |
+---------------------+-------+---------+---------------------------------------------+-------+
1 row in set (0.00 sec)

mysql> update systempreferences set value=0 where variable="IndependentBranches";
Query OK, 1 row affected (0.04 sec)
Rows matched: 1  Changed: 1  Warnings: 0


This fixes it, and lets me enter the intranet but strangely i enter logged in as an OPAC user (who does not have permission to enter the intranet area). I only have one OPAC user created by the way, and obviously was not previously logged in as that user in the intranet but i may have been logged in as that user in the OPAC. If i log out and try to sign in as that same OPAC user again, it correctly gives me the message that i do not have permission to access that page.
Comment 1 Homer 2014-02-21 21:34:30 UTC
Please ignore the last paragraph of the description. That is a separate bug.
Comment 2 Homer 2014-02-22 08:44:14 UTC
The easiest way to reproduce this quickly is to simply run this statement in mysql:

update systempreferences set value=0 where variable="IndependentBranches";

and reload the intranet page in the browser.

I'm not sure why changing the parameter through the intranet interface doesn't cause the problem immediately - maybe something is cached in the browser.
Comment 3 Owen Leonard 2016-06-24 12:10:05 UTC
(In reply to Homer from comment #2)
> The easiest way to reproduce this quickly is to simply run this statement in
> mysql:
> update systempreferences set value=0 where variable="IndependentBranches";
> and reload the intranet page in the browser.

I cannot reproduce the problem in master by following these steps.