From e2570e98d1a525d6da296e3b6e0e43963c70c577 Mon Sep 17 00:00:00 2001 From: Siebrand Mazeland Date: Mon, 11 Aug 2008 10:06:54 +0000 Subject: [PATCH] (bug 14929) Add two command line switches to removeUnusedAccounts.php: --ignore-touched=x : Ignore accounts touched within the lasts x days\n" ); --ignore-groups=x,y : Ignore accounts within these groups\n" ); Patch submitted by: Louperivois --- CREDITS | 1 + RELEASE-NOTES | 18 ++++++++++-------- maintenance/removeUnusedAccounts.inc | 6 +++--- maintenance/removeUnusedAccounts.php | 25 +++++++++++++++++++------ 4 files changed, 33 insertions(+), 17 deletions(-) diff --git a/CREDITS b/CREDITS index ceeca45530..be5bd147c9 100644 --- a/CREDITS +++ b/CREDITS @@ -23,6 +23,7 @@ following names for their contribution to the product. == Patch Contributors == * Daniel Arnold * Danny B. +* Louperivois * Max Semenik * RememberTheDot diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 773c5bff37..93af1d6bf5 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -42,7 +42,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN 'EditSectionLinkForOther' hook has been removed, but 'EditSectionLink' is run in all cases instead, so extensions using the old hooks should still work if they ran roughly the same code for both hooks (as is almost certain). -* Signature (~~~~) "cleaning", i.e. template removal, can be disabled with +* Signature (~~~~) "cleaning", i.e. template removal, can be disabled with $wgCleanSignatures=false * Extensions can use the SkinBuildSidebar hook to modify the content of the sidebar and add custom portlets to it @@ -53,10 +53,10 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * (bug 14377) Add a date selector to history pages * (bug 15007) New 'pagetitle-view-mainpage' message allows the HTML of the main page to be customized -* Added $wgDisableTitleConversion to disabling the conversion for all pages on +* Added $wgDisableTitleConversion to disabling the conversion for all pages on the wiki -* Added 'noconvertlink' toogle that can be set per user preferences, also - added 'convertlink=no|yes' on GET requests whether have the link titles +* Added 'noconvertlink' toogle that can be set per user preferences, also + added 'convertlink=no|yes' on GET requests whether have the link titles being converted or not * (bug 14921) Special:Contributions/: add user name to <title> Patch by Emufarmers @@ -64,6 +64,8 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * Introduced a new hook 'SkinAfterContent' that allows extensions to add text after the page content and article metadata. Updated all skins and skin templates to work with that hook. +* (bug 14929) removeUnusedAccounts.php now supports 'ignore-touched' and + 'ignore-groups'. Patch by Louperivois === Bug fixes in 1.14 === @@ -79,20 +81,20 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * (bug 11035) Special:Search should have descriptive <title> * Special pages are now not subject to special handling for "self-links" * (bug 15053) Syntactically incorrect redirects with another link in them - no longer redirect to the second link + no longer redirect to the second link * (bug 15049) Fix for CheckUser extension's log search: usernames containing a "-" were incorrectly turned into bogus IP range searches. Patch by Max Semenik. * (bug 15055) Talk page notifications no longer attempt to send mail when user's e-mail address is invalid or unconfirmed * (bug 12370) Add throttle on password attempts. Defaults to max 5 attempts in 5 minutes. -* (bug 15016) 'Templates used on this page' list in view source should be wrapped +* (bug 15016) 'Templates used on this page' list in view source should be wrapped in a div with class "templatesUsed" * (bug 14868) Setting $wgFeedDiffCutoff to 0 now disables generation of the diff entirely, not just the display of it. * (bug 6387) Introduced new setting $wgCategoryPrefixedDefaultSortkey which allows having the unprefixed page title as the default category sortkey -* (bug 15079) Add class="ns-talk" / "ns-subject" to <body>. Also added ns-special to +* (bug 15079) Add class="ns-talk" / "ns-subject" to <body>. Also added ns-special to special pages. * (bug 15052) Skins should add their name as a class in <body> * (bug 14165, bug 14294) Wikimedia specific configuration in convertGrammar() @@ -114,7 +116,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN between requests * (bug 15048) Added limit field for multivalue parameters to action=paraminfo output. -* When the limit on multivalue parameters is exceeded, a warning is issued +* When the limit on multivalue parameters is exceeded, a warning is issued === Languages updated in 1.14 === diff --git a/maintenance/removeUnusedAccounts.inc b/maintenance/removeUnusedAccounts.inc index a21dcc7a6e..02c07c1f95 100644 --- a/maintenance/removeUnusedAccounts.inc +++ b/maintenance/removeUnusedAccounts.inc @@ -38,9 +38,9 @@ function isInactiveAccount( $id, $master = false ) { */ function showHelp() { echo( "Delete unused user accounts from the database.\n\n" ); - echo( "Accounts touched within the last week will be ignored.\n\n" ); - echo( "Sysops and bureaucrats will be ignored.\n\n" ); echo( "USAGE: php removeUnusedAccounts.php [--delete]\n\n" ); - echo( " --delete : Delete accounts which are discovered to be inactive\n" ); + echo( " --delete : Delete accounts which are discovered to be inactive\n" ); + echo( " --ignore-touched=x : Ignore accounts touched within the lasts x days\n" ); + echo( " --ignore-groups=x,y : Ignore accounts within these groups\n" ); echo( "\n" ); } diff --git a/maintenance/removeUnusedAccounts.php b/maintenance/removeUnusedAccounts.php index 324f3c7b42..419955b06b 100644 --- a/maintenance/removeUnusedAccounts.php +++ b/maintenance/removeUnusedAccounts.php @@ -8,7 +8,6 @@ * @author Rob Church <robchur@gmail.com> */ - $options = array( 'help', 'delete' ); require_once( 'commandLine.inc' ); require_once( 'removeUnusedAccounts.inc' ); @@ -25,13 +24,27 @@ echo( "Checking for unused user accounts...\n" ); $del = array(); $dbr = wfGetDB( DB_SLAVE ); $res = $dbr->select( 'user', array( 'user_id', 'user_name', 'user_touched' ), '', $fname ); -$excludedGroups = array( 'sysop', 'bureaucrat' ); +if( isset( $options['ignore-groups'] ) ) { + $excludedGroups = explode( ',', $options['ignore-groups'] ); +} else { $excludedGroups = array(); } +$touchedSeconds = 0; +if( isset( $options['ignore-touched'] ) ) { + $touchedParamError = 0; + if( ctype_digit( $options['ignore-touched'] ) ) { + if( $options['ignore-touched'] <= 0 ) { + $touchedParamError = 1; + } + } else { $touchedParamError = 1; } + if( $touchedParamError == 1 ) { + die( "Please put a valid positive integer on the --ignore-touched parameter.\n" ); + } else { $touchedSeconds = 86400 * $options['ignore-touched']; } +} while( $row = $dbr->fetchObject( $res ) ) { - # Check the account, but ignore it if it's within the "sysop" or "bureaucrat" group. + # Check the account, but ignore it if it's within a $excludedGroups group or if it's touched within the $touchedSeconds seconds. $instance = User::newFromId( $row->user_id ); - if( count( array_intersect( $instance->getGroups(), $excludedGroups ) ) == 0 - && isInactiveAccount( $row->user_id, true ) - && wfTimestamp( TS_UNIX, $row->user_touched ) < wfTimestamp( TS_UNIX, time() - 604800 ) + if( count( array_intersect( $instance->getEffectiveGroups(), $excludedGroups ) ) == 0 + && isInactiveAccount( $row->user_id, true ) + && wfTimestamp( TS_UNIX, $row->user_touched ) < wfTimestamp( TS_UNIX, time() - $touchedSeconds ) ) { # Inactive; print out the name and flag it $del[] = $row->user_id; -- 2.20.1