Bug 8849 - Error log generated when not a demo system
Summary: Error log generated when not a demo system
Alias: None
Product: Koha
Classification: Unclassified
Component: System Administration (show other bugs)
Version: 3.8
Hardware: All All
: P5 - low trivial (vote)
Assignee: Mark Tompsett
QA Contact: Paul Poulain
Depends on:
Reported: 2012-10-01 07:42 UTC by Mark Tompsett
Modified: 2013-05-23 06:24 UTC (History)
5 users (show)

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

Fix error logging triggered by adding/editing/deleting tags on framework (2.17 KB, patch)
2012-10-01 09:18 UTC, Mark Tompsett
Details | Diff | Splinter Review
Bug 8739 follow-up fixing perlcritic error (1.23 KB, patch)
2012-10-04 08:43 UTC, Frédéric Demians
Details | Diff | Splinter Review
Bug 8849 - Error log generated when not a demo system (2.23 KB, patch)
2012-10-05 13:29 UTC, Kyle M Hall
Details | Diff | Splinter Review
0001-SIGNED-OFF-Bug-8849-Error-log-generated-when-not-a-demo.patch (2.19 KB, patch)
2012-10-05 16:34 UTC, wajasu
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Mark Tompsett 2012-10-01 07:42:27 UTC
As a result of:
[Mon Oct 01 15:28:59 2012] [error] [client] [Mon Oct  1 15:28:59 2012] marctagstructure.pl: Use of uninitialized value in numeric eq (==) at /usr/share/koha/intranet/cgi-bin/admin/marctagstructure.pl line 152.
in Koha 3.8.5 this patch was generated.

The line reads
     unless (C4::Context->config('demo') == 1) {
which produces an error long entry while tweaking frameworks. It should read:
     unless (defined(C4::Context->config('demo')) && C4::Context->config('demo') == 1) {
-- though this will still generate an error if the value isn't numeric. I'm going to assume that whoever does use it, will use it correctly.

My understanding is that this value must be set to 1 in koha-conf.xml to prevent writing out MARC Framework changes (adds or modifies). However, since 'demo' is not defined in the default koha-conf.xml, this generates an error.

This feature is not documented anywhere, as far as I know. Though 'demo' code does seem to exist in a couple places in Koha.

Patch to follow.
Comment 1 Mark Tompsett 2012-10-01 08:25:49 UTC
It would seem that admin/auth_tag_structure.pl, admin/marc_subfields_structure.pl, admin/marctagstructure.pl, and admin/auth_subfields_structure.pl all need their condition revised.

However, since I only found marctagstructure.pl in the error logs and since I can reproduce it, only marctagstructure.pl will be fixed. However, not with a ==1 or eq 1, but by removing the operator portion completely as is elsewhere.

This is a grep from 3.8.x:
$ grep "'demo'" `find .`
./admin/auth_tag_structure.pl:    unless (C4::Context->config('demo') eq 1) {
./admin/auth_tag_structure.pl:  unless (C4::Context->config('demo') eq 1) {
./admin/marc_subfields_structure.pl:            unless ( C4::Context->config('de                                                                                        mo') eq 1 ) {
./admin/marc_subfields_structure.pl:    unless ( C4::Context->config('demo') eq                                                                                         1 ) {
./admin/preferences.pl:    unless ( C4::Context->config( 'demo' ) ) {
./admin/marctagstructure.pl:    unless (C4::Context->config('demo') == 1) {
./admin/marctagstructure.pl:    unless (C4::Context->config('demo') == 1) {
./admin/auth_subfields_structure.pl:                    unless (C4::Context->con                                                                                        fig('demo') eq 1) {
./admin/auth_subfields_structure.pl:    unless (C4::Context->config('demo') eq 1                                                                                        ) {
./admin/systempreferences.pl:        unless ( C4::Context->config('demo') ) {
./admin/systempreferences.pl:        unless ( C4::Context->config('demo') ) {
./admin/systempreferences.pl:        unless ( C4::Context->config('demo') ) {
./admin/systempreferences.pl:        unless ( C4::Context->config('demo') ) {
./C4/Auth.pm:    if (   $userid && $userid eq 'demo'
./C4/Auth.pm:        && "$password" eq 'demo'
./C4/Auth.pm:        && C4::Context->config('demo') )
./C4/Auth.pm:    elsif ( $userid eq 'demo' && C4::Context->config('demo') ) {
./debian/scripts/koha-run-backups:# - dump all sites, except one called 'demo'
./svc/config/systempreferences:    unless ( C4::Context->config('demo') ) {
./svc/config/systempreferences:    unless ( C4::Context->config( 'demo' ) ) {
./installer/InstallAuth.pm:        && $userid     eq 'demo'
./installer/InstallAuth.pm:        && "$password" eq 'demo'
./installer/InstallAuth.pm:        && C4::Context->config('demo') )
Comment 2 Mark Tompsett 2012-10-01 09:18:11 UTC Comment hidden (obsolete)
Comment 3 Mark Tompsett 2012-10-01 09:27:31 UTC
This bug applies to master, 3.8.x, and 3.6.x versions of koha. Patch was generated from master. Applied to all three. Let me know if there's a problem.
Comment 4 Frédéric Demians 2012-10-04 08:43:18 UTC Comment hidden (obsolete)
Comment 5 Kyle M Hall 2012-10-05 13:29:58 UTC Comment hidden (obsolete)
Comment 6 Mark Tompsett 2012-10-05 14:24:17 UTC
Comment on attachment 12674 [details] [review]
Bug 8739 follow-up fixing perlcritic error

Fixes perl-critic errors unrelated to this bug, but found while QA-ing this bug, but this patch still needs sign off. Not sure how it got obsoleted in the first place. Making this not obsoleted.
Comment 7 Mark Tompsett 2012-10-05 14:46:20 UTC
Comment on attachment 12674 [details] [review]
Bug 8739 follow-up fixing perlcritic error

moved obsolete attachment to bug 7595 as per wajasu's suggestion.
Comment 8 wajasu 2012-10-05 16:34:34 UTC
Created attachment 12718 [details] [review]

When testing as comment #2 enumerates, I just tailed the log, and saved the interaction.  Then I did the same after the patch.

I compared the two visually, and saw the error messages pertaining to the ==  error were gone.  The editor functioned editing/saving just fine.

Yes there is other uninitialized error noise from other places(in master only).

I applied it to master, origin/3.8.x  and origin/3.6.x as well, and they applied cleanly, and all passed testing.


Comment 9 wajasu 2012-10-05 16:37:19 UTC
Though targeted at 3.8, so don't lose track that it should also be applied to master.
Comment 10 Paul Poulain 2012-10-24 16:10:00 UTC
QA comment:
 * tiny patch
 * koha-qa.pl OK, except for a problem that was here before the patch (a tab)

passed QA
Comment 11 Paul Poulain 2012-10-24 16:13:15 UTC
FYI : the "demo" mode has been introduced a long time ago -by me IIRC-
If set to 1, there user ca log-in with demo/demo, whatever the database, and can't modify sysprefs & some other setups (not sure I remember exactly which ones)

I agree it's deeply deprecated and could be completely removed from Koha

In the meantime, patch pushed
Comment 12 Chris Cormack 2012-10-24 20:20:05 UTC
Pushed to 3.8.x, will be in 3.8.7