Bug 37844: Remove C4::Members::DeleteUnverifiedOpacRegistrations
This patch removes the subroutine C4::Members::DeleteUnverifiedOpacRegistrations and use the Koha::Objects->filter_by_last_update method that is used for the other flag in this script. Test plan: Confirm that --del-unv-selfreg works the same before and after this patch applied Signed-off-by: Sukhmandeep Benipal <sukhmandeep.benipal@inLibro.com> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
parent
3ed51f0514
commit
73f890ab2d
|
|
@ -46,7 +46,6 @@ BEGIN {
|
|||
|
||||
IssueSlip
|
||||
|
||||
DeleteUnverifiedOpacRegistrations
|
||||
DeleteExpiredOpacRegistrations
|
||||
);
|
||||
}
|
||||
|
|
@ -524,23 +523,6 @@ sub DeleteExpiredOpacRegistrations {
|
|||
return $cnt;
|
||||
}
|
||||
|
||||
=head2 DeleteUnverifiedOpacRegistrations
|
||||
|
||||
Delete all unverified self registrations in borrower_modifications,
|
||||
older than the specified number of days.
|
||||
|
||||
=cut
|
||||
|
||||
sub DeleteUnverifiedOpacRegistrations {
|
||||
my ( $days ) = @_;
|
||||
my $dbh = C4::Context->dbh;
|
||||
my $sql=qq|
|
||||
DELETE FROM borrower_modifications
|
||||
WHERE borrowernumber = 0 AND DATEDIFF( NOW(), timestamp ) > ?|;
|
||||
my $cnt=$dbh->do($sql, undef, ($days) );
|
||||
return $cnt eq '0E0'? 0: $cnt;
|
||||
}
|
||||
|
||||
END { } # module clean-up code here (global destructor)
|
||||
|
||||
1;
|
||||
|
|
|
|||
|
|
@ -522,11 +522,17 @@ if ($pExpSelfReg) {
|
|||
say "self-registered borrowers may be deleted";
|
||||
}
|
||||
}
|
||||
|
||||
if ($pUnvSelfReg) {
|
||||
if ($confirm) {
|
||||
DeleteUnverifiedSelfRegs($pUnvSelfReg);
|
||||
} elsif ($verbose) {
|
||||
say "unverified self-registrations may be deleted";
|
||||
my $opac_registrations =
|
||||
Koha::Patron::Modifications->search( { borrowernumber => 0 } )
|
||||
->filter_by_last_update( { days => $pUnvSelfReg } );
|
||||
my $count = $opac_registrations->count;
|
||||
$opac_registrations->delete if $confirm;
|
||||
if ($verbose) {
|
||||
say $confirm
|
||||
? sprintf( "Done with removing %d unverified self-registrations", $count )
|
||||
: sprintf( "%d unverified self-registrations would have been removed", $count );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -907,11 +913,6 @@ sub DeleteExpiredSelfRegs {
|
|||
print "Removed $cnt expired self-registered borrowers\n" if $verbose;
|
||||
}
|
||||
|
||||
sub DeleteUnverifiedSelfRegs {
|
||||
my $cnt = C4::Members::DeleteUnverifiedOpacRegistrations( $_[0] );
|
||||
print "Removed $cnt unverified self-registrations\n" if $verbose;
|
||||
}
|
||||
|
||||
sub DeleteSpecialHolidays {
|
||||
my ($days) = @_;
|
||||
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ use t::lib::Mocks;
|
|||
use t::lib::TestBuilder;
|
||||
|
||||
BEGIN {
|
||||
use_ok('C4::Members', qw( GetBorrowersToExpunge DeleteUnverifiedOpacRegistrations DeleteExpiredOpacRegistrations ));
|
||||
use_ok('C4::Members', qw( GetBorrowersToExpunge DeleteExpiredOpacRegistrations ));
|
||||
}
|
||||
|
||||
my $schema = Koha::Database->schema;
|
||||
|
|
@ -389,18 +389,7 @@ $borrower = Koha::Patrons->find( $borrowernumber )->unblessed;
|
|||
ok( $borrower->{userid}, 'A userid should have been generated correctly' );
|
||||
|
||||
subtest 'purgeSelfRegistration' => sub {
|
||||
plan tests => 8;
|
||||
|
||||
#purge unverified
|
||||
my $d=360;
|
||||
C4::Members::DeleteUnverifiedOpacRegistrations($d);
|
||||
foreach(1..3) {
|
||||
$dbh->do("INSERT INTO borrower_modifications (timestamp, borrowernumber, verification_token, changed_fields) VALUES ('2014-01-01 01:02:03',0,?,'firstname,surname')", undef, (scalar localtime)."_$_");
|
||||
}
|
||||
# Add a record with a borrowernumber which should not be deleted by DeleteUnverifiedOpacRegistrations
|
||||
# NOTE: We are using the borrowernumber from the last test outside this subtest
|
||||
$dbh->do( "INSERT INTO borrower_modifications (timestamp, borrowernumber, verification_token, changed_fields) VALUES ('2014-01-01 01:02:03', ?, '', 'firstname,surname' )", undef, $borrowernumber );
|
||||
is( C4::Members::DeleteUnverifiedOpacRegistrations($d), 3, 'Test for DeleteUnverifiedOpacRegistrations' );
|
||||
plan tests => 7;
|
||||
|
||||
#purge members in temporary category
|
||||
my $c= 'XYZ';
|
||||
|
|
|
|||
Loading…
Reference in New Issue