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>
Signed-off-by: Jesse Weaver <jweaver@bywatersolutions.com>
(cherry picked from commit de3289506d)
Signed-off-by: Julian Maurice <julian.maurice@biblibre.com>
Conflicts:
Koha/Branch.pm
Koha/Branches.pm
This commit is contained in:
parent
0483a13d26
commit
7847081c52
|
|
@ -66,7 +66,7 @@ sub move {
|
|||
|
||||
=cut
|
||||
|
||||
sub type {
|
||||
sub _type {
|
||||
return 'AudioAlert';
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -136,7 +136,7 @@ sub fix_precedences {
|
|||
|
||||
=cut
|
||||
|
||||
sub type {
|
||||
sub _type {
|
||||
return 'AudioAlert';
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -164,7 +164,7 @@ sub _avb_resultset {
|
|||
|
||||
=cut
|
||||
|
||||
sub type {
|
||||
sub _type {
|
||||
return 'AuthorisedValue';
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ sub categories {
|
|||
|
||||
=cut
|
||||
|
||||
sub type {
|
||||
sub _type {
|
||||
return 'AuthorisedValue';
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ Koha::Biblio - Koha Biblio Object class
|
|||
|
||||
=cut
|
||||
|
||||
sub type {
|
||||
sub _type {
|
||||
return 'Biblio';
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ Koha::Biblioitem - Koha Biblioitem Object class
|
|||
|
||||
=cut
|
||||
|
||||
sub type {
|
||||
sub _type {
|
||||
return 'Biblioitem';
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ Koha::Biblioitem - Koha Biblioitem Object class
|
|||
|
||||
=cut
|
||||
|
||||
sub type {
|
||||
sub _type {
|
||||
return 'Biblioitem';
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ Koha::Biblios - Koha Biblio object set class
|
|||
|
||||
=cut
|
||||
|
||||
sub type {
|
||||
sub _type {
|
||||
return 'Biblio';
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ Koha::Borrower - Koha Borrower Object class
|
|||
|
||||
=cut
|
||||
|
||||
sub type {
|
||||
sub _type {
|
||||
return 'Borrower';
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ Koha::Borrower - Koha Borrower Object class
|
|||
|
||||
=cut
|
||||
|
||||
sub type {
|
||||
sub _type {
|
||||
return 'Borrower';
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ Koha::Branch - Koha Branch object class
|
|||
|
||||
=cut
|
||||
|
||||
sub type {
|
||||
sub _type {
|
||||
return 'Branch';
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ Koha::Branches - Koha Branch object set class
|
|||
|
||||
=cut
|
||||
|
||||
sub type {
|
||||
sub _type {
|
||||
return 'Branch';
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ Koha::Cities - Koha City Object set class
|
|||
|
||||
=cut
|
||||
|
||||
sub type {
|
||||
sub _type {
|
||||
return 'City';
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ Koha::City - Koha City Object class
|
|||
|
||||
=cut
|
||||
|
||||
sub type {
|
||||
sub _type {
|
||||
return 'City';
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ Koha::Config::SysPref - Koha System Preference Object class
|
|||
|
||||
=cut
|
||||
|
||||
sub type {
|
||||
sub _type {
|
||||
return 'Systempreference';
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ Koha::Config::SysPrefs - Koha System Preference object set class
|
|||
|
||||
=cut
|
||||
|
||||
sub type {
|
||||
sub _type {
|
||||
return 'Systempreference';
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -122,7 +122,7 @@ sub branch {
|
|||
|
||||
=cut
|
||||
|
||||
sub type {
|
||||
sub _type {
|
||||
return 'Reserve';
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ sub waiting {
|
|||
|
||||
=cut
|
||||
|
||||
sub type {
|
||||
sub _type {
|
||||
return 'Reserve';
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ sub holding_branch {
|
|||
|
||||
=cut
|
||||
|
||||
sub type {
|
||||
sub _type {
|
||||
return 'Item';
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ Koha::Items - Koha Item object set class
|
|||
|
||||
=cut
|
||||
|
||||
sub type {
|
||||
sub _type {
|
||||
return 'Item';
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ use Koha::Database;
|
|||
|
||||
use base qw(Koha::Object);
|
||||
|
||||
sub type {
|
||||
sub _type {
|
||||
return 'Localization';
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ use Koha::Localization;
|
|||
|
||||
use base qw(Koha::Objects);
|
||||
|
||||
sub type {
|
||||
sub _type {
|
||||
return 'Localization';
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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 { }
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ Koha::Patron::Categories - Koha Patron Category Object set class
|
|||
|
||||
=cut
|
||||
|
||||
sub type {
|
||||
sub _type {
|
||||
return 'Category';
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -181,7 +181,7 @@ sub _catb_resultset {
|
|||
|
||||
=cut
|
||||
|
||||
sub type {
|
||||
sub _type {
|
||||
return 'Category';
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -273,7 +273,7 @@ sub can_biblios_be_removed {
|
|||
return 0;
|
||||
}
|
||||
|
||||
sub type {
|
||||
sub _type {
|
||||
return 'Virtualshelve';
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ Koha::Virtualshelfcontent - Koha Virtualshelfcontent Object class
|
|||
|
||||
=cut
|
||||
|
||||
sub type {
|
||||
sub _type {
|
||||
return 'Virtualshelfcontent';
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ Koha::Virtualshelfcontents - Koha Virtualshelfcontents Object class
|
|||
|
||||
=cut
|
||||
|
||||
sub type {
|
||||
sub _type {
|
||||
return 'Virtualshelfcontent';
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ sub has_expired {
|
|||
return $has_expired == 1 ? 1 : 0
|
||||
}
|
||||
|
||||
sub type {
|
||||
sub _type {
|
||||
return 'Virtualshelfshare';
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ Koha::Virtualshelfshares - Koha Virtualshelfshares Object class
|
|||
|
||||
=cut
|
||||
|
||||
sub type {
|
||||
sub _type {
|
||||
return 'Virtualshelfshare';
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -119,7 +119,7 @@ sub get_some_shelves {
|
|||
);
|
||||
}
|
||||
|
||||
sub type {
|
||||
sub _type {
|
||||
return 'Virtualshelve';
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue