2017-10-04 19:55:59 +00:00
|
|
|
<?php
|
|
|
|
|
/**
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
2022-09-22 21:21:19 +00:00
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
* http://www.gnu.org/copyleft/gpl.html
|
2017-10-04 19:55:59 +00:00
|
|
|
*
|
2022-09-22 21:21:19 +00:00
|
|
|
* @file
|
2017-10-04 19:55:59 +00:00
|
|
|
*/
|
|
|
|
|
|
2024-08-27 12:00:25 +00:00
|
|
|
// @codeCoverageIgnoreStart
|
2017-10-04 19:55:59 +00:00
|
|
|
require_once __DIR__ . '/Maintenance.php';
|
2024-08-27 12:00:25 +00:00
|
|
|
// @codeCoverageIgnoreEnd
|
2017-10-04 19:55:59 +00:00
|
|
|
|
2017-10-06 19:35:29 +00:00
|
|
|
/*
|
2022-09-22 21:21:19 +00:00
|
|
|
* Remove expired userrights from user_groups table and move them to former_user_groups.
|
|
|
|
|
*
|
|
|
|
|
* By default, this does not need to be run. The UserGroupManager service naturally
|
|
|
|
|
* takes care of detecting expired rows when it is written to (e.g. from SpecialUserrights)
|
|
|
|
|
* and queues UserGroupExpiryJob to purge expired rows.
|
|
|
|
|
*
|
|
|
|
|
* Large wiki farms may experience stale rows if their users manage local groups
|
|
|
|
|
* via a central wiki. In that case, UserGroupExpiryJob may run rarely or never
|
|
|
|
|
* from local wikis, in which case this script can help to periodically clean up
|
|
|
|
|
* expired rows.
|
2017-10-06 19:35:29 +00:00
|
|
|
*
|
|
|
|
|
* @since 1.31
|
2022-09-22 21:21:19 +00:00
|
|
|
* @ingroup Maintenance
|
|
|
|
|
* @author Eddie Greiner-Petter <wikimedia.org at eddie-sh.de>
|
2017-10-06 19:35:29 +00:00
|
|
|
*/
|
2017-10-04 19:55:59 +00:00
|
|
|
class PurgeExpiredUserrights extends Maintenance {
|
|
|
|
|
public function __construct() {
|
|
|
|
|
parent::__construct();
|
|
|
|
|
$this->addDescription( 'Move expired userrights from user_groups to former_user_groups table.' );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function execute() {
|
|
|
|
|
$this->output( "Purging expired user rights...\n" );
|
2023-08-31 09:21:12 +00:00
|
|
|
$res = $this->getServiceContainer()->getUserGroupManager()->purgeExpired();
|
2018-03-03 15:26:39 +00:00
|
|
|
if ( $res === false ) {
|
|
|
|
|
$this->output( "Purging failed.\n" );
|
|
|
|
|
} else {
|
|
|
|
|
$this->output( "$res rows purged.\n" );
|
|
|
|
|
}
|
2017-10-04 19:55:59 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-27 12:00:25 +00:00
|
|
|
// @codeCoverageIgnoreStart
|
2018-01-13 00:02:09 +00:00
|
|
|
$maintClass = PurgeExpiredUserrights::class;
|
2017-10-04 19:55:59 +00:00
|
|
|
require_once RUN_MAINTENANCE_IF_MAIN;
|
2024-08-27 12:00:25 +00:00
|
|
|
// @codeCoverageIgnoreEnd
|