Turns out that we rely heavily on the side effect that passing undef
to haspermission would always return true no matter what permissions
or lack of permissions you had.
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
sub haspermission {
my ( $userid, $flagsrequired ) = @_;
sub haspermission {
my ( $userid, $flagsrequired ) = @_;
- Koha::Exceptions::WrongParameter->throw('$flagsrequired should not be undef')
- unless defined($flagsrequired);
+ return 1 unless defined($flagsrequired); # This is horrifying but restores behaviour prior to bug 22031
+
+ #Koha::Exceptions::WrongParameter->throw('$flagsrequired should not be undef')
+ # unless defined($flagsrequired);
my $sth = C4::Context->dbh->prepare("SELECT flags FROM borrowers WHERE userid=?");
$sth->execute($userid);
my $sth = C4::Context->dbh->prepare("SELECT flags FROM borrowers WHERE userid=?");
$sth->execute($userid);
subtest 'undef top level tests' => sub {
subtest 'undef top level tests' => sub {
- throws_ok { my $r = haspermission( $borr1->{userid} ); }
- 'Koha::Exceptions::WrongParameter',
- 'Exception thrown when missing $requiredflags';
- throws_ok { my $r = haspermission( $borr1->{userid}, undef ); }
- 'Koha::Exceptions::WrongParameter', 'Exception thrown when explicit undef';
+ my $pass = haspermission( $borr2->{userid} );
+ ok($pass, "let through undef privs");
+
+ #throws_ok { my $r = haspermission( $borr1->{userid} ); }
+ #'Koha::Exceptions::WrongParameter',
+ # 'Exception thrown when missing $requiredflags';
+ #throws_ok { my $r = haspermission( $borr1->{userid}, undef ); }
+ #'Koha::Exceptions::WrongParameter', 'Exception thrown when explicit undef';
};
subtest 'scalar top level tests' => sub {
};
subtest 'scalar top level tests' => sub {