Merge "Upgrade wikimedia/remex-html to 2.0.1" into REL1_31
[lhc/web/wiklou.git] / maintenance / purgeExpiredUserrights.php
1 <?php
2 /**
3 * Remove expired userrights from user_groups table and move them to former_user_groups
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 *
18 * @copyright GPLv2 http://www.gnu.org/copyleft/gpl.html
19 * @author Eddie Greiner-Petter <wikimedia.org at eddie-sh.de>
20 * @ingroup Maintenance
21 */
22
23 require_once __DIR__ . '/Maintenance.php';
24
25 /*
26 * Maintenance script to move expired userrights to user_former_groups
27 *
28 * @since 1.31
29 */
30
31 class PurgeExpiredUserrights extends Maintenance {
32 public function __construct() {
33 parent::__construct();
34 $this->addDescription( 'Move expired userrights from user_groups to former_user_groups table.' );
35 }
36
37 public function execute() {
38 $this->output( "Purging expired user rights...\n" );
39 $res = UserGroupMembership::purgeExpired();
40 if ( $res === false ) {
41 $this->output( "Purging failed.\n" );
42 } else {
43 $this->output( "$res rows purged.\n" );
44 }
45 }
46 }
47
48 $maintClass = PurgeExpiredUserrights::class;
49 require_once RUN_MAINTENANCE_IF_MAIN;