[Bug 15446] New: Koha::Object[s]->type should be renamed to _type to avoid conflict with column name
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15446 Bug ID: 15446 Summary: Koha::Object[s]->type should be renamed to _type to avoid conflict with column name Change sponsored?: --- Product: Koha Version: master Hardware: All OS: All Status: ASSIGNED Severity: major Priority: P5 - low Component: Architecture, internals, and plumbing Assignee: jonathan.druart@bugs.koha-community.org Reporter: jonathan.druart@bugs.koha-community.org QA Contact: testopia@bugs.koha-community.org Depends on: 13967 In a few case (at least systempreferences and export_format (csv profiles), the type method of Koha::Object and Koha::Objects can be in conflict with the column names. Indeed systempreferences.type exists and so the method will return 'Systempreference' (the name of the module) instead of the value of the row in DB. I have found at least 1 place where it can cause issue: In C4::Context->set_preference: 601 my $syspref = Koha::Config::SysPrefs->find( $var ); 602 my $type = $syspref ? $syspref->type() : undef; 603 604 $value = 0 if ( $type && $type eq 'YesNo' && $value eq '' ); type will always be 'Systempreference' and the YesNo pref will be set to an empty string '' instead of 0. Referenced Bugs: http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=13967 [Bug 13967] Add package for System preferences -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15446 Jonathan Druart <jonathan.druart@bugs.koha-community.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|ASSIGNED |Needs Signoff -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15446 --- Comment #1 from Jonathan Druart <jonathan.druart@bugs.koha-community.org> --- Created attachment 46095 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=46095&action=edit Bug 15446: Add tests -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15446 --- Comment #2 from Jonathan Druart <jonathan.druart@bugs.koha-community.org> --- Created attachment 46096 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=46096&action=edit Bug 15446: Rename Koha::Object[s]->type with _type In a few case (at least systempreferences and export_format (csv profiles), the type method of Koha::Object and Koha::Objects can be in conflict with the column names. Indeed systempreferences.type exists and so the method will return 'Systempreference' (the name of the module) instead of the value of the row in DB. I have found at least 1 place where it can cause issue: In C4::Context->set_preference: 601 my $syspref = Koha::Config::SysPrefs->find( $var ); 602 my $type = $syspref ? $syspref->type() : undef; 603 604 $value = 0 if ( $type && $type eq 'YesNo' && $value eq '' ); type will always be 'Systempreference' and the YesNo pref will be set to an empty string '' instead of 0. I am not sure about the consequences of this, but it is preferable to fix it ASAP. To reproduce: 0/ Do not apply this patch 1/ Edit a YesNo prefs, AutoEmailOpacUser for instance 2/ Set it to "Don't sent" 3/ Check the value in DB, it should be set to an empty string, instead of 0 4/ Apply this patch and try again. Now the value should be 0 -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15446 --- Comment #3 from Jonathan Druart <jonathan.druart@bugs.koha-community.org> --- Created attachment 46097 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=46097&action=edit Bug 15446: Update systempreferences rows where type=YesNo and value='' -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15446 Jonathan Druart <jonathan.druart@bugs.koha-community.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Depends on| |13019 Referenced Bugs: http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=13019 [Bug 13019] Add base classes on which to build Koha objects -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15446 Jonathan Druart <jonathan.druart@bugs.koha-community.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Blocks| |15451 Referenced Bugs: http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15451 [Bug 15451] Move the CSV related code to Koha::CsvProfile[s] -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15446 Marc Véron <veron@veron.ch> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #46095|0 |1 is obsolete| | --- Comment #4 from Marc Véron <veron@veron.ch> --- Created attachment 46104 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=46104&action=edit Bug 15446: Add tests Signed-off-by: Marc Véron <veron@veron.ch> -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15446 Marc Véron <veron@veron.ch> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #46096|0 |1 is obsolete| | --- Comment #5 from Marc Véron <veron@veron.ch> --- Created attachment 46105 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=46105&action=edit Bug 15446: Rename Koha::Object[s]->type with _type In a few case (at least systempreferences and export_format (csv profiles), the type method of Koha::Object and Koha::Objects can be in conflict with the column names. Indeed systempreferences.type exists and so the method will return 'Systempreference' (the name of the module) instead of the value of the row in DB. I have found at least 1 place where it can cause issue: In C4::Context->set_preference: 601 my $syspref = Koha::Config::SysPrefs->find( $var ); 602 my $type = $syspref ? $syspref->type() : undef; 603 604 $value = 0 if ( $type && $type eq 'YesNo' && $value eq '' ); type will always be 'Systempreference' and the YesNo pref will be set to an empty string '' instead of 0. I am not sure about the consequences of this, but it is preferable to fix it ASAP. To reproduce: 0/ Do not apply this patch 1/ Edit a YesNo prefs, AutoEmailOpacUser for instance 2/ Set it to "Don't sent" 3/ Check the value in DB, it should be set to an empty string, instead of 0 4/ Apply this patch and try again. Now the value should be 0 Followed test plan, value is now 0 as expected. Signed-off-by: Marc Véron <veron@veron.ch> -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15446 Marc Véron <veron@veron.ch> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #46097|0 |1 is obsolete| | --- Comment #6 from Marc Véron <veron@veron.ch> --- Created attachment 46106 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=46106&action=edit Bug 15446: Update systempreferences rows where type=YesNo and value='' Signed-off-by: Marc Véron <veron@veron.ch> -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15446 Marc Véron <veron@veron.ch> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |veron@veron.ch --- Comment #7 from Marc Véron <veron@veron.ch> --- Oh, I was to fast with the 3rd patch, the update statement has a typo: UPDATE systempreferences SET value="0" where type="YesNo" and value=";" -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15446 Marc Véron <veron@veron.ch> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #46106|0 |1 is obsolete| | --- Comment #8 from Marc Véron <veron@veron.ch> --- Created attachment 46107 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=46107&action=edit Bug 15446: Update systempreferences rows where type=YesNo and value='' Signed-off-by: Marc Véron <veron@veron.ch> Amended to fix typo in sql statement. -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15446 --- Comment #9 from Marc Véron <veron@veron.ch> --- ...and tested, update works fine now. -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15446 Marc Véron <veron@veron.ch> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Needs Signoff |Signed Off -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15446 Marc Véron <veron@veron.ch> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Signed Off |Needs Signoff --- Comment #10 from Marc Véron <veron@veron.ch> --- Oh, I get a software error with checkong out. Not sure if it is related to this bug, but setting back to NSO. Will go to a previous VM to test again. -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15446 --- Comment #11 from Jonathan Druart <jonathan.druart@bugs.koha-community.org> --- (In reply to Marc Véron from comment #10)
Oh, I get a software error with checkong out. Not sure if it is related to this bug, but setting back to NSO.
Will go to a previous VM to test again.
See third patch on bug 15344 for a fix. -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15446 Marc Véron <veron@veron.ch> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Needs Signoff |Signed Off --- Comment #12 from Marc Véron <veron@veron.ch> --- Switching back to signed off again, the issue from comment #10 was not related to this bug. -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15446 --- Comment #13 from Jonathan Druart <jonathan.druart@bugs.koha-community.org> --- Created attachment 46268 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=46268&action=edit Bug 15446: (follow-up) Rename Koha::Object[s]->type with _type Some occurrences have been pushed in the meantime. -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15446 Kyle M Hall <kyle@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Signed Off |Passed QA -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15446 Kyle M Hall <kyle@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #46104|0 |1 is obsolete| | Attachment #46105|0 |1 is obsolete| | Attachment #46107|0 |1 is obsolete| | Attachment #46268|0 |1 is obsolete| | --- Comment #14 from Kyle M Hall <kyle@bywatersolutions.com> --- Created attachment 46424 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=46424&action=edit Bug 15446: Add tests Signed-off-by: Marc Véron <veron@veron.ch> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15446 --- Comment #15 from Kyle M Hall <kyle@bywatersolutions.com> --- Created attachment 46425 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=46425&action=edit Bug 15446: Rename Koha::Object[s]->type with _type In a few case (at least systempreferences and export_format (csv profiles), the type method of Koha::Object and Koha::Objects can be in conflict with the column names. Indeed systempreferences.type exists and so the method will return 'Systempreference' (the name of the module) instead of the value of the row in DB. I have found at least 1 place where it can cause issue: In C4::Context->set_preference: 601 my $syspref = Koha::Config::SysPrefs->find( $var ); 602 my $type = $syspref ? $syspref->type() : undef; 603 604 $value = 0 if ( $type && $type eq 'YesNo' && $value eq '' ); type will always be 'Systempreference' and the YesNo pref will be set to an empty string '' instead of 0. I am not sure about the consequences of this, but it is preferable to fix it ASAP. To reproduce: 0/ Do not apply this patch 1/ Edit a YesNo prefs, AutoEmailOpacUser for instance 2/ Set it to "Don't sent" 3/ Check the value in DB, it should be set to an empty string, instead of 0 4/ Apply this patch and try again. Now the value should be 0 Followed test plan, value is now 0 as expected. Signed-off-by: Marc Véron <veron@veron.ch> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15446 --- Comment #16 from Kyle M Hall <kyle@bywatersolutions.com> --- Created attachment 46426 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=46426&action=edit Bug 15446: Update systempreferences rows where type=YesNo and value='' Signed-off-by: Marc Véron <veron@veron.ch> Amended to fix typo in sql statement. Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15446 --- Comment #17 from Kyle M Hall <kyle@bywatersolutions.com> --- Created attachment 46427 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=46427&action=edit Bug 15446: (follow-up) Rename Koha::Object[s]->type with _type Some occurrences have been pushed in the meantime. Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15446 --- Comment #18 from Jonathan Druart <jonathan.druart@bugs.koha-community.org> --- I have added a new rule to the qa tools: commit 75bf0eead3fab5b1918f4d2f2fc6c1bc66f2dc76 type subroutine should be _type See bug 15446 -- You are receiving this mail because: You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org