Bugzilla – Attachment 46425 Details for
Bug 15446
Koha::Object[s]->type should be renamed to _type to avoid conflict with column name
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 15446: Rename Koha::Object[s]->type with _type
Bug-15446-Rename-KohaObjects-type-with-type.patch (text/plain), 13.44 KB, created by
Kyle M Hall (khall)
on 2016-01-08 12:51:50 UTC
(
hide
)
Description:
Bug 15446: Rename Koha::Object[s]->type with _type
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2016-01-08 12:51:50 UTC
Size:
13.44 KB
patch
obsolete
>From f2eb057bca25633659399eae170d6786c5717013 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Wed, 30 Dec 2015 17:15:31 +0000 >Subject: [PATCH] Bug 15446: Rename Koha::Object[s]->type with _type >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >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> >--- > Koha/AudioAlert.pm | 2 +- > Koha/AudioAlerts.pm | 2 +- > Koha/AuthorisedValue.pm | 2 +- > Koha/AuthorisedValues.pm | 2 +- > Koha/Biblio.pm | 2 +- > Koha/Biblioitem.pm | 2 +- > Koha/Biblioitems.pm | 2 +- > Koha/Biblios.pm | 2 +- > Koha/Borrower.pm | 2 +- > Koha/Borrowers.pm | 2 +- > Koha/Branch.pm | 2 +- > Koha/Branches.pm | 2 +- > Koha/Cities.pm | 2 +- > Koha/City.pm | 2 +- > Koha/Config/SysPref.pm | 2 +- > Koha/Config/SysPrefs.pm | 2 +- > Koha/Hold.pm | 2 +- > Koha/Holds.pm | 2 +- > Koha/Item.pm | 2 +- > Koha/Items.pm | 2 +- > Koha/Localization.pm | 2 +- > Koha/Localizations.pm | 2 +- > Koha/Object.pm | 22 +++++++++++----------- > Koha/Objects.pm | 14 ++++++-------- > Koha/Patron/Categories.pm | 2 +- > Koha/Patron/Category.pm | 2 +- > Koha/Virtualshelf.pm | 2 +- > Koha/Virtualshelfcontent.pm | 2 +- > Koha/Virtualshelfcontents.pm | 2 +- > Koha/Virtualshelfshare.pm | 2 +- > Koha/Virtualshelfshares.pm | 2 +- > Koha/Virtualshelves.pm | 2 +- > 32 files changed, 47 insertions(+), 49 deletions(-) > >diff --git a/Koha/AudioAlert.pm b/Koha/AudioAlert.pm >index e6873f4..e23e46b 100644 >--- a/Koha/AudioAlert.pm >+++ b/Koha/AudioAlert.pm >@@ -66,7 +66,7 @@ sub move { > > =cut > >-sub type { >+sub _type { > return 'AudioAlert'; > } > >diff --git a/Koha/AudioAlerts.pm b/Koha/AudioAlerts.pm >index d21a982..be4f51a 100644 >--- a/Koha/AudioAlerts.pm >+++ b/Koha/AudioAlerts.pm >@@ -136,7 +136,7 @@ sub fix_precedences { > > =cut > >-sub type { >+sub _type { > return 'AudioAlert'; > } > >diff --git a/Koha/AuthorisedValue.pm b/Koha/AuthorisedValue.pm >index ec7abe5..71758a9 100644 >--- a/Koha/AuthorisedValue.pm >+++ b/Koha/AuthorisedValue.pm >@@ -164,7 +164,7 @@ sub _avb_resultset { > > =cut > >-sub type { >+sub _type { > return 'AuthorisedValue'; > } > >diff --git a/Koha/AuthorisedValues.pm b/Koha/AuthorisedValues.pm >index e690d8c..718b8f8 100644 >--- a/Koha/AuthorisedValues.pm >+++ b/Koha/AuthorisedValues.pm >@@ -79,7 +79,7 @@ sub categories { > > =cut > >-sub type { >+sub _type { > return 'AuthorisedValue'; > } > >diff --git a/Koha/Biblio.pm b/Koha/Biblio.pm >index 48c959d..97adf62 100644 >--- a/Koha/Biblio.pm >+++ b/Koha/Biblio.pm >@@ -58,7 +58,7 @@ sub subtitles { > > =cut > >-sub type { >+sub _type { > return 'Biblio'; > } > >diff --git a/Koha/Biblioitem.pm b/Koha/Biblioitem.pm >index b71cfd8..8d353c8 100644 >--- a/Koha/Biblioitem.pm >+++ b/Koha/Biblioitem.pm >@@ -37,7 +37,7 @@ Koha::Biblioitem - Koha Biblioitem Object class > > =cut > >-sub type { >+sub _type { > return 'Biblioitem'; > } > >diff --git a/Koha/Biblioitems.pm b/Koha/Biblioitems.pm >index c21c64d..c4d6144 100644 >--- a/Koha/Biblioitems.pm >+++ b/Koha/Biblioitems.pm >@@ -39,7 +39,7 @@ Koha::Biblioitem - Koha Biblioitem Object class > > =cut > >-sub type { >+sub _type { > return 'Biblioitem'; > } > >diff --git a/Koha/Biblios.pm b/Koha/Biblios.pm >index cba48ea..29f32fc 100644 >--- a/Koha/Biblios.pm >+++ b/Koha/Biblios.pm >@@ -41,7 +41,7 @@ Koha::Biblios - Koha Biblio object set class > > =cut > >-sub type { >+sub _type { > return 'Biblio'; > } > >diff --git a/Koha/Borrower.pm b/Koha/Borrower.pm >index 6604b8a..d058301 100644 >--- a/Koha/Borrower.pm >+++ b/Koha/Borrower.pm >@@ -51,7 +51,7 @@ sub guarantor { > > =cut > >-sub type { >+sub _type { > return 'Borrower'; > } > >diff --git a/Koha/Borrowers.pm b/Koha/Borrowers.pm >index 9fb01f0..f532d6f 100644 >--- a/Koha/Borrowers.pm >+++ b/Koha/Borrowers.pm >@@ -41,7 +41,7 @@ Koha::Borrower - Koha Borrower Object class > > =cut > >-sub type { >+sub _type { > return 'Borrower'; > } > >diff --git a/Koha/Branch.pm b/Koha/Branch.pm >index cd36c74..62b8689 100644 >--- a/Koha/Branch.pm >+++ b/Koha/Branch.pm >@@ -39,7 +39,7 @@ Koha::Branch - Koha Branch object class > > =cut > >-sub type { >+sub _type { > return 'Branch'; > } > >diff --git a/Koha/Branches.pm b/Koha/Branches.pm >index c1078a2..16637c8 100644 >--- a/Koha/Branches.pm >+++ b/Koha/Branches.pm >@@ -41,7 +41,7 @@ Koha::Branches - Koha Branch object set class > > =cut > >-sub type { >+sub _type { > return 'Branch'; > } > >diff --git a/Koha/Cities.pm b/Koha/Cities.pm >index 6e578b0..29b5f89 100644 >--- a/Koha/Cities.pm >+++ b/Koha/Cities.pm >@@ -39,7 +39,7 @@ Koha::Cities - Koha City Object set class > > =cut > >-sub type { >+sub _type { > return 'City'; > } > >diff --git a/Koha/City.pm b/Koha/City.pm >index 69f451e..b84b5c3 100644 >--- a/Koha/City.pm >+++ b/Koha/City.pm >@@ -37,7 +37,7 @@ Koha::City - Koha City Object class > > =cut > >-sub type { >+sub _type { > return 'City'; > } > >diff --git a/Koha/Config/SysPref.pm b/Koha/Config/SysPref.pm >index e18c222..e1850b5 100644 >--- a/Koha/Config/SysPref.pm >+++ b/Koha/Config/SysPref.pm >@@ -39,7 +39,7 @@ Koha::Config::SysPref - Koha System Preference Object class > > =cut > >-sub type { >+sub _type { > return 'Systempreference'; > } > >diff --git a/Koha/Config/SysPrefs.pm b/Koha/Config/SysPrefs.pm >index 552d0c7..dbf43ab 100644 >--- a/Koha/Config/SysPrefs.pm >+++ b/Koha/Config/SysPrefs.pm >@@ -41,7 +41,7 @@ Koha::Config::SysPrefs - Koha System Preference object set class > > =cut > >-sub type { >+sub _type { > return 'Systempreference'; > } > >diff --git a/Koha/Hold.pm b/Koha/Hold.pm >index 518d0ae..b6e8fd2 100644 >--- a/Koha/Hold.pm >+++ b/Koha/Hold.pm >@@ -198,7 +198,7 @@ sub borrower { > > =cut > >-sub type { >+sub _type { > return 'Reserve'; > } > >diff --git a/Koha/Holds.pm b/Koha/Holds.pm >index 41ab3f6..d1d8b29 100644 >--- a/Koha/Holds.pm >+++ b/Koha/Holds.pm >@@ -53,7 +53,7 @@ sub waiting { > > =cut > >-sub type { >+sub _type { > return 'Reserve'; > } > >diff --git a/Koha/Item.pm b/Koha/Item.pm >index e8543e1..0c817b4 100644 >--- a/Koha/Item.pm >+++ b/Koha/Item.pm >@@ -111,7 +111,7 @@ sub last_returned_by { > > =cut > >-sub type { >+sub _type { > return 'Item'; > } > >diff --git a/Koha/Items.pm b/Koha/Items.pm >index 072113f..7b86c5a 100644 >--- a/Koha/Items.pm >+++ b/Koha/Items.pm >@@ -41,7 +41,7 @@ Koha::Items - Koha Item object set class > > =cut > >-sub type { >+sub _type { > return 'Item'; > } > >diff --git a/Koha/Localization.pm b/Koha/Localization.pm >index 013db3a..32bbeaf 100644 >--- a/Koha/Localization.pm >+++ b/Koha/Localization.pm >@@ -21,7 +21,7 @@ use Koha::Database; > > use base qw(Koha::Object); > >-sub type { >+sub _type { > return 'Localization'; > } > >diff --git a/Koha/Localizations.pm b/Koha/Localizations.pm >index bcbd8c2..deed6b8 100644 >--- a/Koha/Localizations.pm >+++ b/Koha/Localizations.pm >@@ -23,7 +23,7 @@ use Koha::Localization; > > use base qw(Koha::Objects); > >-sub type { >+sub _type { > return 'Localization'; > } > >diff --git a/Koha/Object.pm b/Koha/Object.pm >index 34776a1..9d23fb4 100644 >--- a/Koha/Object.pm >+++ b/Koha/Object.pm >@@ -57,12 +57,12 @@ sub new { > > if ($attributes) { > $self->{_result} = >- Koha::Database->new()->schema()->resultset( $class->type() ) >+ Koha::Database->new()->schema()->resultset( $class->_type() ) > ->new($attributes); > } > >- croak("No type found! Koha::Object must be subclassed!") >- unless $class->type(); >+ croak("No _type found! Koha::Object must be subclassed!") >+ unless $class->_type(); > > bless( $self, $class ); > >@@ -81,11 +81,11 @@ sub _new_from_dbic { > # DBIC result row > $self->{_result} = $dbic_row; > >- croak("No type found! Koha::Object must be subclassed!") >- unless $class->type(); >+ croak("No _type found! Koha::Object must be subclassed!") >+ unless $class->_type(); > >- croak( "DBIC result type " . ref( $self->{_result} ) . " isn't of the type " . $class->type() ) >- unless ref( $self->{_result} ) eq "Koha::Schema::Result::" . $class->type(); >+ croak( "DBIC result _type " . ref( $self->{_result} ) . " isn't of the _type " . $class->_type() ) >+ unless ref( $self->{_result} ) eq "Koha::Schema::Result::" . $class->_type(); > > bless( $self, $class ); > >@@ -230,7 +230,7 @@ sub _result { > > # If we don't have a dbic row at this point, we need to create an empty one > $self->{_result} ||= >- Koha::Database->new()->schema()->resultset( $self->type() )->new({}); >+ Koha::Database->new()->schema()->resultset( $self->_type() )->new({}); > > return $self->{_result}; > } >@@ -279,14 +279,14 @@ sub AUTOLOAD { > return; > } > >-=head3 type >+=head3 _type > > This method must be defined in the child class. The value is the name of the DBIC resultset. >-For example, for borrowers, the type method will return "Borrower". >+For example, for borrowers, the _type method will return "Borrower". > > =cut > >-sub type { } >+sub _type { } > > sub DESTROY { } > >diff --git a/Koha/Objects.pm b/Koha/Objects.pm >index 27406cf..4df3595 100644 >--- a/Koha/Objects.pm >+++ b/Koha/Objects.pm >@@ -23,8 +23,6 @@ use Carp; > > use Koha::Database; > >-our $type; >- > =head1 NAME > > Koha::Objects - Koha Object set base class >@@ -229,24 +227,24 @@ sub _resultset { > > if ( ref($self) ) { > $self->{_resultset} ||= >- Koha::Database->new()->schema()->resultset( $self->type() ); >+ Koha::Database->new()->schema()->resultset( $self->_type() ); > > return $self->{_resultset}; > } > else { >- return Koha::Database->new()->schema()->resultset( $self->type() ); >+ return Koha::Database->new()->schema()->resultset( $self->_type() ); > } > } > >-=head3 type >+=head3 _type > >-The type method must be set for all child classes. >+The _type method must be set for all child classes. > The value returned by it should be the DBIC resultset name. >-For example, for holds, type should return 'Reserve'. >+For example, for holds, _type should return 'Reserve'. > > =cut > >-sub type { } >+sub _type { } > > =head3 object_class > >diff --git a/Koha/Patron/Categories.pm b/Koha/Patron/Categories.pm >index f220028..482da86 100644 >--- a/Koha/Patron/Categories.pm >+++ b/Koha/Patron/Categories.pm >@@ -39,7 +39,7 @@ Koha::Patron::Categories - Koha Patron Category Object set class > > =cut > >-sub type { >+sub _type { > return 'Category'; > } > >diff --git a/Koha/Patron/Category.pm b/Koha/Patron/Category.pm >index 1a81bc3..7b17c8c 100644 >--- a/Koha/Patron/Category.pm >+++ b/Koha/Patron/Category.pm >@@ -181,7 +181,7 @@ sub _catb_resultset { > > =cut > >-sub type { >+sub _type { > return 'Category'; > } > >diff --git a/Koha/Virtualshelf.pm b/Koha/Virtualshelf.pm >index 7ce2738..4049e56 100644 >--- a/Koha/Virtualshelf.pm >+++ b/Koha/Virtualshelf.pm >@@ -273,7 +273,7 @@ sub can_biblios_be_removed { > return 0; > } > >-sub type { >+sub _type { > return 'Virtualshelve'; > } > >diff --git a/Koha/Virtualshelfcontent.pm b/Koha/Virtualshelfcontent.pm >index d7fc0c7..999cc51 100644 >--- a/Koha/Virtualshelfcontent.pm >+++ b/Koha/Virtualshelfcontent.pm >@@ -38,7 +38,7 @@ Koha::Virtualshelfcontent - Koha Virtualshelfcontent Object class > > =cut > >-sub type { >+sub _type { > return 'Virtualshelfcontent'; > } > >diff --git a/Koha/Virtualshelfcontents.pm b/Koha/Virtualshelfcontents.pm >index 2a6b777..684ad9d 100644 >--- a/Koha/Virtualshelfcontents.pm >+++ b/Koha/Virtualshelfcontents.pm >@@ -39,7 +39,7 @@ Koha::Virtualshelfcontents - Koha Virtualshelfcontents Object class > > =cut > >-sub type { >+sub _type { > return 'Virtualshelfcontent'; > } > >diff --git a/Koha/Virtualshelfshare.pm b/Koha/Virtualshelfshare.pm >index d1a7ffa..09e383f 100644 >--- a/Koha/Virtualshelfshare.pm >+++ b/Koha/Virtualshelfshare.pm >@@ -67,7 +67,7 @@ sub has_expired { > return $has_expired == 1 ? 1 : 0 > } > >-sub type { >+sub _type { > return 'Virtualshelfshare'; > } > >diff --git a/Koha/Virtualshelfshares.pm b/Koha/Virtualshelfshares.pm >index e49e335..370dcbb 100644 >--- a/Koha/Virtualshelfshares.pm >+++ b/Koha/Virtualshelfshares.pm >@@ -39,7 +39,7 @@ Koha::Virtualshelfshares - Koha Virtualshelfshares Object class > > =cut > >-sub type { >+sub _type { > return 'Virtualshelfshare'; > } > >diff --git a/Koha/Virtualshelves.pm b/Koha/Virtualshelves.pm >index 34b1003..0c757ce 100644 >--- a/Koha/Virtualshelves.pm >+++ b/Koha/Virtualshelves.pm >@@ -119,7 +119,7 @@ sub get_some_shelves { > ); > } > >-sub type { >+sub _type { > return 'Virtualshelve'; > } > >-- >2.1.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 15446
:
46095
|
46096
|
46097
|
46104
|
46105
|
46106
|
46107
|
46268
|
46424
|
46425
|
46426
|
46427
|
48005
|
48006
|
48007
|
48008
|
48019