We have several instances on one server. Some are using patron self registration, others do not. Now when cleanup_database.pl is run, we get a warning in the logs: Self-registrations cannot be removed, system preference PatronSelfRegistrationDefaultCategory is not set This is unnecessary, as for the libraries in question PatronSelfRegistration is OFF and PatronSelfRegistrationExpireTemporaryAccountsDelay is set to 0. The pref description says: NOTE: This system preference requires the misc/cronjobs/cleanup_database.pl cronjob. Ask your system administrator to schedule it. No patrons will be deleted if you set the pref to zero or make it empty. So we are telling the script, it's OK, we don't want any deleted, and still get the noisy warning. This is unnecessary. The warning should only be given when PatronSelfRegistrationExpireTemporaryAccountsDelay is not empty or 0 and the PatronSelfRegistrationDefaultCategory is empty at the same time. We might also want to check for PatronSelfRegistration.
We have the same since upgrading our clients from 24.05 to 25.05. Very annoying! We have the same cleanup cron for everyone on the server. We don't really want to start separating crons for the ones who have selfreg, vs those who don't. misc/cronjobs/cleanup_database.pl [...] --del-exp-selfreg --del-unv-selfreg 30 [...] -confirm This is an example of a client whose Self registration is not activated: MariaDB [***]> select variable, value from systempreferences where variable in ('PatronSelfRegistration', 'PatronSelfRegistrationDefaultCategory', 'PatronSelfRegistrationExpireTemporaryAccountsDelay'); +----------------------------------------------------+-------+ | variable | value | +----------------------------------------------------+-------+ | PatronSelfRegistration | 0 | | PatronSelfRegistrationDefaultCategory | | | PatronSelfRegistrationExpireTemporaryAccountsDelay | 0 | +----------------------------------------------------+-------+ 3 rows in set (0.000 sec) Message we get Self-registrations cannot be removed, system preference PatronSelfRegistrationDefaultCategory is not set
Probably due to the change in bug 37845
Created attachment 191869 [details] [review] Bug 40744: Ignore --del-exp-selfreg if pref is not set If PatronSelfRegistration we should ignore (i.e. do nothing) if --del-exp-selfreg is passed to cleanup_database.pl It prevents the script to warn that the pref is not set.
Would this patch work for you?
Thanks, I'll try to test as soon as I can!
Created attachment 191874 [details] [review] Bug 40744: Ignore --del-exp-selfreg if pref is not set Skip self-registration cleanup when PatronSelfRegistrationExpireTemporaryAccountsDelay is 0 or unset as well.
Created attachment 191875 [details] [review] BZ40744: Handle PatronSelfRegistration as well as PatronSelfRegistrationExpireTemporaryAccountsDelay
Created attachment 191876 [details] [review] BZ40744: Handle PatronSelfRegistration as well as PatronSelfRegistrationExpireTemporaryAccountsDelay
Created attachment 191877 [details] [review] BZ40744: Handle PatronSelfRegistration as well as PatronSelfRegistrationExpireTemporaryAccountsDelay fix merge conflict.
Comment on attachment 191877 [details] [review] BZ40744: Handle PatronSelfRegistration as well as PatronSelfRegistrationExpireTemporaryAccountsDelay Review of attachment 191877 [details] [review]: ----------------------------------------------------------------- Handle error messages from the cleanup_database.pl script, depending on the preference settings. to test BEFORE APPLYING PATCH: 1- From the main page on the staff interface, go to Administration. 2- On the system preferences search bar, enter 'PatronSelfRegistration'. 3- Set 'PatronSelfRegistration' value to "Don't allow". 4- On the system preferences search bar, enter 'PatronSelfRegistrationExpireTemporaryAccountsDelay'. 5- Set 'PatronSelfRegistrationExpireTemporaryAccountsDelay' value to '0'. 6- On command line, run cleanup_database.pl. Note: the following message will show up: 'Self-registrations cannot be removed, system preference PatronSelfRegistrationDefaultCategory is not set' 7- Apply patch. AFTER APPLYING PATCH: 8- Set 'PatronSelfRegistration' value to "Don't allow" and set 'PatronSelfRegistrationExpireTemporaryAccountsDelay' value to '0'. 9- Save and run cleanup_database.pl : No message should show up. 10- Set 'PatronSelfRegistration' value to "Allow" and set 'PatronSelfRegistrationExpireTemporaryAccountsDelay' value to '0'. 11- Save and run cleanup_database.pl : No message should show up. 12- Set 'PatronSelfRegistration' value to "Don't allow". and set 'PatronSelfRegistrationExpireTemporaryAccountsDelay' value to '1'. 13- Save and run cleanup_database.pl : No message should show up. 14- Set 'PatronSelfRegistration' value to "Allow". and set 'PatronSelfRegistrationExpireTemporaryAccountsDelay' value to '1'. 15- Save and run cleanup_database.pl Note: this message should show up: 'Self-registrations cannot be removed, system preference PatronSelfRegistrationDefaultCategory is not set' 16- Set 'PatronSelfRegistration' value to "Don't allow". and set 'PatronSelfRegistrationExpireTemporaryAccountsDelay' value to ''(leave empty). 17- Save and run cleanup_database.pl : No message should show up. 18- Set 'PatronSelfRegistration' value to "Allow". and set 'PatronSelfRegistrationExpireTemporaryAccountsDelay' value to ''(leave empty). 19- Save and run cleanup_database.pl : No message should show up. ** EXEMPLE OF THE COMMAND TO EXECUTE: make sure to enter the RIGHT PATH to the script file. perl /path/to/cleanup_database.pl --sessions --sessdays 1 --zebraqueue 1 --mail 365 --merged --import 90 --z3950 --logs 180 --searchhistory 30 --list-invites 7 --all-restrictions --del-exp-selfreg --del-unv-selfreg 30 --temp-uploads --temp-uploads-days 14 --oauth-tokens --transfers 30 --jobs-days 1 --jobs-type all --confirm
Comment on attachment 191877 [details] [review] BZ40744: Handle PatronSelfRegistration as well as PatronSelfRegistrationExpireTemporaryAccountsDelay >From d48323236ef6071f263981944b33a039cf84bdae Mon Sep 17 00:00:00 2001 >From: Ayoub Glizi-Vicioso <ayoub.glizi-vicioso@inLibro.com> >Date: Thu, 22 Jan 2026 11:11:49 -0500 >Subject: [PATCH] BZ40744: Handle PatronSelfRegistration as well as > PatronSelfRegistrationExpireTemporaryAccountsDelay > >Handle error messages from the cleanup_database.pl script, depending on the preference settings. > >to test > >BEFORE APPLYING PATCH: > >1- From the main page on the staff interface, go to Administration. >2- On the system preferences search bar, enter 'PatronSelfRegistration'. >3- Set 'PatronSelfRegistration' value to "Don't allow". >4- On the system preferences search bar, enter 'PatronSelfRegistrationExpireTemporaryAccountsDelay'. >5- Set 'PatronSelfRegistrationExpireTemporaryAccountsDelay' value to '0'. >6- On command line, run cleanup_database.pl. >Note: the following message will show up: >'Self-registrations cannot be removed, system preference PatronSelfRegistrationDefaultCategory is not set' > >7- Apply patch. > >AFTER APPLYING PATCH: > >8- Set 'PatronSelfRegistration' value to "Don't allow" and set 'PatronSelfRegistrationExpireTemporaryAccountsDelay' value to '0'. >9- Save and run cleanup_database.pl : No message should show up. > >10- Set 'PatronSelfRegistration' value to "Allow" and set 'PatronSelfRegistrationExpireTemporaryAccountsDelay' value to '0'. >11- Save and run cleanup_database.pl : No message should show up. > >12- Set 'PatronSelfRegistration' value to "Don't allow". and set 'PatronSelfRegistrationExpireTemporaryAccountsDelay' value to '1'. >13- Save and run cleanup_database.pl : No message should show up. > >14- Set 'PatronSelfRegistration' value to "Allow". and set 'PatronSelfRegistrationExpireTemporaryAccountsDelay' value to '1'. >15- Save and run cleanup_database.pl >Note: this message should show up: >'Self-registrations cannot be removed, system preference PatronSelfRegistrationDefaultCategory is not set' > >16- Set 'PatronSelfRegistration' value to "Don't allow". and set 'PatronSelfRegistrationExpireTemporaryAccountsDelay' value to ''(leave empty). >17- Save and run cleanup_database.pl : No message should show up. > >18- Set 'PatronSelfRegistration' value to "Allow". and set 'PatronSelfRegistrationExpireTemporaryAccountsDelay' value to ''(leave empty). >19- Save and run cleanup_database.pl : No message should show up. > > >** EXEMPLE OF THE COMMAND TO EXECUTE: make sure to enter the RIGHT PATH to the script file. > >perl /path/to/cleanup_database.pl --sessions --sessdays 1 --zebraqueue 1 --mail 365 --merged --import 90 --z3950 --logs 180 --searchhistory 30 --list-invites 7 --all-restrictions --del-exp-selfreg -->del-unv-selfreg 30 --temp-uploads --temp-uploads-days 14 --oauth-tokens --transfers 30 --jobs-days 1 --jobs-type all --confirm > >--- > misc/cronjobs/cleanup_database.pl | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > >diff --git a/misc/cronjobs/cleanup_database.pl b/misc/cronjobs/cleanup_database.pl >index 2299e59cc5..14956ead72 100755 >--- a/misc/cronjobs/cleanup_database.pl >+++ b/misc/cronjobs/cleanup_database.pl >@@ -524,7 +524,7 @@ if ($verbose) { > say $confirm ? sprintf( "Deleted %d patrons", $count ) : sprintf( "%d patrons would have been deleted", $count ); > } > >-if ( $pExpSelfReg && C4::Context->preference('PatronSelfRegistration') ) { >+if ( $pExpSelfReg && C4::Context->preference('PatronSelfRegistration') && C4::Context->preference('PatronSelfRegistrationExpireTemporaryAccountsDelay')) { > try { > my $opac_registrations = Koha::Patrons->search->filter_by_expired_opac_registrations->filter_by_safe_to_delete; > my $count = $opac_registrations->count; >-- >2.52.0
Created attachment 191886 [details] [review] Bug 40744: Ignore --del-exp-selfreg if pref is not set If PatronSelfRegistration we should ignore (i.e. do nothing) if --del-exp-selfreg is passed to cleanup_database.pl It prevents the script to warn that the pref is not set.
Created attachment 191887 [details] [review] Bug 40744: Handle PatronSelfRegistration as well as PatronSelfRegistrationExpireTemporaryAccountsDelay
Created attachment 191888 [details] [review] Bug 40744: Ignore --del-exp-selfreg if pref is not set Handle error messages from the cleanup_database.pl script, depending on the preference settings. to test BEFORE APPLYING PATCH: 1- From the main page on the staff interface, go to Administration. 2- On the system preferences search bar, enter 'PatronSelfRegistration'. 3- Set 'PatronSelfRegistration' value to "Don't allow". 4- On the system preferences search bar, enter 'PatronSelfRegistrationExpireTemporaryAccountsDelay'. 5- Set 'PatronSelfRegistrationExpireTemporaryAccountsDelay' value to '0'. 6- On command line, run cleanup_database.pl. Note: the following message will show up: 'Self-registrations cannot be removed, system preference PatronSelfRegistrationDefaultCategory is not set' 7- Apply patch. AFTER APPLYING PATCH: 8- Set 'PatronSelfRegistration' value to "Don't allow" and set 'PatronSelfRegistrationExpireTemporaryAccountsDelay' value to '0'. 9- Save and run cleanup_database.pl : No message should show up. 10- Set 'PatronSelfRegistration' value to "Allow" and set 'PatronSelfRegistrationExpireTemporaryAccountsDelay' value to '0'. 11- Save and run cleanup_database.pl : No message should show up. 12- Set 'PatronSelfRegistration' value to "Don't allow". and set 'PatronSelfRegistrationExpireTemporaryAccountsDelay' value to '1'. 13- Save and run cleanup_database.pl : No message should show up. 14- Set 'PatronSelfRegistration' value to "Allow". and set 'PatronSelfRegistrationExpireTemporaryAccountsDelay' value to '1'. 15- Save and run cleanup_database.pl Note: this message should show up: 'Self-registrations cannot be removed, system preference PatronSelfRegistrationDefaultCategory is not set' 16- Set 'PatronSelfRegistration' value to "Don't allow". and set 'PatronSelfRegistrationExpireTemporaryAccountsDelay' value to ''(leave empty). 17- Save and run cleanup_database.pl : No message should show up. 18- Set 'PatronSelfRegistration' value to "Allow". and set 'PatronSelfRegistrationExpireTemporaryAccountsDelay' value to ''(leave empty). 19- Save and run cleanup_database.pl : No message should show up. ** EXEMPLE OF THE COMMAND TO EXECUTE: make sure to enter the RIGHT PATH to the script file. perl /path/to/cleanup_database.pl --sessions --sessdays 1 --zebraqueue 1 --mail 365 --merged --import 90 --z3950 --logs 180 --searchhistory 30 --list-invites 7 --all-restrictions --del-exp-selfreg --del-unv-selfreg 30 --temp-uploads --temp-uploads-days 14 --oauth-tokens --transfers 30 --jobs-days 1 --jobs-type all --confirm
Created attachment 191889 [details] [review] Bug 40744: Handle PatronSelfRegistration as well as PatronSelfRegistrationExpireTemporaryAccountsDelay
Hi Ayoub, I see that you wrote the test plan in Bugzilla or when using git bz, but that way it's only here and not part of the patch file. Better to do it in the git commit step, so it's part of the file. See here: https://wiki.koha-community.org/wiki/Commit_messages If I understand correctly your patch is a follow-up to Joubu's?
But also: thanks for writing the test plan! (should have said that first!)
Created attachment 191933 [details] [review] Bug 40744: Ignore --del-exp-selfreg if pref is not set If PatronSelfRegistration we should ignore (i.e. do nothing) if --del-exp-selfreg is passed to cleanup_database.pl It prevents the script to warn that the pref is not set.
Created attachment 191934 [details] [review] Bug 40744: Handle PatronSelfRegistration as well as PatronSelfRegistrationExpireTemporaryAccountsDelay Test plan BEFORE APPLYING PATCH: 1- From the main page on the staff interface, go to Administration. 2- On the system preferences search bar, enter 'PatronSelfRegistration'. 3- Set 'PatronSelfRegistration' value to "Don't allow". 4- On the system preferences search bar, enter 'PatronSelfRegistrationExpireTemporaryAccountsDelay'. 5- Set 'PatronSelfRegistrationExpireTemporaryAccountsDelay' value to '0'. 6- On command line, run cleanup_database.pl. Note: the following message will show up: 'Self-registrations cannot be removed, system preference PatronSelfRegistrationDefaultCategory is not set' 7- Apply patch. AFTER APPLYING PATCH: 8- Set 'PatronSelfRegistration' value to "Don't allow" and set 'PatronSelfRegistrationExpireTemporaryAccountsDelay' value to '0'. 9- Save and run cleanup_database.pl : No message should show up. 10- Set 'PatronSelfRegistration' value to "Allow" and set 'PatronSelfRegistrationExpireTemporaryAccountsDelay' value to '0'. 11- Save and run cleanup_database.pl : No message should show up. 12- Set 'PatronSelfRegistration' value to "Don't allow". and set 'PatronSelfRegistrationExpireTemporaryAccountsDelay' value to '1'. 13- Save and run cleanup_database.pl : No message should show up. 14- Set 'PatronSelfRegistration' value to "Allow". and set 'PatronSelfRegistrationExpireTemporaryAccountsDelay' value to '1'. 15- Save and run cleanup_database.pl Note: this message should show up: 'Self-registrations cannot be removed, system preference PatronSelfRegistrationDefaultCategory is not set' 16- Set 'PatronSelfRegistration' value to "Don't allow". and set 'PatronSelfRegistrationExpireTemporaryAccountsDelay' value to ''(leave empty). 17- Save and run cleanup_database.pl : No message should show up. 18- Set 'PatronSelfRegistration' value to "Allow". and set 'PatronSelfRegistrationExpireTemporaryAccountsDelay' value to ''(leave empty). 19- Save and run cleanup_database.pl : No message should show up. ** EXEMPLE OF THE COMMAND TO EXECUTE: make sure to enter the RIGHT PATH to the script file. perl /path/to/cleanup_database.pl --sessions --sessdays 1 --zebraqueue 1 --mail 365 --merged --import 90 --z3950 --logs 180 --searchhistory 30 --list-invites 7 --all-restrictions --del-exp-selfreg --del-unv-selfreg 30 --temp-uploads --temp-uploads-days 14 --oauth-tokens --transfers 30 --jobs-days 1 --jobs-type all --confirm
(In reply to Katrin Fischer from comment #16) > Hi Ayoub, I see that you wrote the test plan in Bugzilla or when using git > bz, but that way it's only here and not part of the patch file. Better to do > it in the git commit step, so it's part of the file. See here: > https://wiki.koha-community.org/wiki/Commit_messages > > If I understand correctly your patch is a follow-up to Joubu's? Hi Katrin,thanks for the note. I’ve adjusted the commit and added the test plan directly to the last commit message.
Created attachment 192003 [details] [review] Bug 40744: Ignore --del-exp-selfreg if pref is not set If PatronSelfRegistration we should ignore (i.e. do nothing) if --del-exp-selfreg is passed to cleanup_database.pl It prevents the script to warn that the pref is not set. Signed-off-by: David Nind <david@davidnind.com>
Created attachment 192004 [details] [review] Bug 40744: Handle PatronSelfRegistration as well as PatronSelfRegistrationExpireTemporaryAccountsDelay Test plan BEFORE APPLYING PATCH: 1- From the main page on the staff interface, go to Administration. 2- On the system preferences search bar, enter 'PatronSelfRegistration'. 3- Set 'PatronSelfRegistration' value to "Don't allow". 4- On the system preferences search bar, enter 'PatronSelfRegistrationExpireTemporaryAccountsDelay'. 5- Set 'PatronSelfRegistrationExpireTemporaryAccountsDelay' value to '0'. 6- On command line, run cleanup_database.pl. Note: the following message will show up: 'Self-registrations cannot be removed, system preference PatronSelfRegistrationDefaultCategory is not set' 7- Apply patch. AFTER APPLYING PATCH: 8- Set 'PatronSelfRegistration' value to "Don't allow" and set 'PatronSelfRegistrationExpireTemporaryAccountsDelay' value to '0'. 9- Save and run cleanup_database.pl : No message should show up. 10- Set 'PatronSelfRegistration' value to "Allow" and set 'PatronSelfRegistrationExpireTemporaryAccountsDelay' value to '0'. 11- Save and run cleanup_database.pl : No message should show up. 12- Set 'PatronSelfRegistration' value to "Don't allow". and set 'PatronSelfRegistrationExpireTemporaryAccountsDelay' value to '1'. 13- Save and run cleanup_database.pl : No message should show up. 14- Set 'PatronSelfRegistration' value to "Allow". and set 'PatronSelfRegistrationExpireTemporaryAccountsDelay' value to '1'. 15- Save and run cleanup_database.pl Note: this message should show up: 'Self-registrations cannot be removed, system preference PatronSelfRegistrationDefaultCategory is not set' 16- Set 'PatronSelfRegistration' value to "Don't allow". and set 'PatronSelfRegistrationExpireTemporaryAccountsDelay' value to ''(leave empty). 17- Save and run cleanup_database.pl : No message should show up. 18- Set 'PatronSelfRegistration' value to "Allow". and set 'PatronSelfRegistrationExpireTemporaryAccountsDelay' value to ''(leave empty). 19- Save and run cleanup_database.pl : No message should show up. ** EXEMPLE OF THE COMMAND TO EXECUTE: make sure to enter the RIGHT PATH to the script file. perl /path/to/cleanup_database.pl --sessions --sessdays 1 --zebraqueue 1 --mail 365 --merged --import 90 --z3950 --logs 180 --searchhistory 30 --list-invites 7 --all-restrictions --del-exp-selfreg --del-unv-selfreg 30 --temp-uploads --temp-uploads-days 14 --oauth-tokens --transfers 30 --jobs-days 1 --jobs-type all --confirm Signed-off-by: David Nind <david@davidnind.com>
Testing notes (using KTD): 1. Note that the example cleanup_database.pl options to use are at the end of the test plan, from /kohadevbox/koha run: perl misc/cronjobs/cleanup_database.pl --sessions --sessdays 1 --zebraqueue 1 --mail 365 --merged --import 90 --z3950 --logs 180 --searchhistory 30 --list-invites 7 --all-restrictions --del-exp-selfreg --del-unv-selfreg 30 --temp-uploads --temp-uploads-days 14 --oauth-tokens --transfers 30 --jobs-days 1 --jobs-type all --confirm 2. Step 15: Had to clear the default value in PatronSelfRegistrationDefaultCategory (Self registration) for the message to show. Thanks for the test plan!