| 1 | <?php |
| 2 | |
| 3 | namespace LoginNotify\Maintenance; |
| 4 | |
| 5 | use LoginNotify\LoginNotify; |
| 6 | use MediaWiki\Maintenance\Maintenance; |
| 7 | |
| 8 | $IP = getenv( 'MW_INSTALL_PATH' ); |
| 9 | if ( $IP === false ) { |
| 10 | $IP = __DIR__ . '/../../..'; |
| 11 | } |
| 12 | |
| 13 | require_once "$IP/maintenance/Maintenance.php"; |
| 14 | |
| 15 | class PurgeSeen extends Maintenance { |
| 16 | public function __construct() { |
| 17 | parent::__construct(); |
| 18 | $this->addDescription( 'Purge expired user IP address information stored by LoginNotify' ); |
| 19 | } |
| 20 | |
| 21 | public function execute() { |
| 22 | $loginNotify = LoginNotify::getInstance(); |
| 23 | $minId = $loginNotify->getMinExpiredId(); |
| 24 | for ( ; $minId !== null; $this->waitForReplication() ) { |
| 25 | $minId = $loginNotify->purgeSeen( $minId ); |
| 26 | } |
| 27 | } |
| 28 | } |
| 29 | |
| 30 | $maintClass = PurgeSeen::class; |
| 31 | require_once RUN_MAINTENANCE_IF_MAIN; |