示例#1
0
 public function execute()
 {
     if (!defined('WB_VERSION')) {
         $this->output("You need to have Wikibase enabled in order to use this maintenance script!\n\n");
         exit;
     }
     $force = $this->getOption('force', false);
     $pidLock = new PidLock('WBpruneChanges', wfWikiID());
     if (!$pidLock->getLock($force)) {
         $this->output(date('H:i:s') . " already running, exiting\n");
         exit(5);
     }
     $changePruner = new ChangePruner($this->mBatchSize, $this->getKeepSeconds(), $this->getGraceSeconds(), $this->getOption('ignore-dispatch', false));
     $changePruner->setMessageReporter($this->newMessageReporter());
     $changePruner->prune();
     $pidLock->removeLock();
     // delete lockfile on normal exit
 }
 /**
  * @dataProvider wikiIdProvider
  */
 public function testPidLock($wikiId)
 {
     $pidLock = new PidLock('PidLockTest', $wikiId);
     $this->assertTrue($pidLock->getLock(), 'Get an initial log');
     $this->assertFalse($pidLock->getLock(), 'Try to get the lock, although some already has it');
     $this->assertTrue($pidLock->getLock(true), 'Force getting the lock');
     $this->assertTrue($pidLock->removeLock());
     // Make sure that the given file has actually been removed.
     // unlink gives a warning if you use it a file that doesn't exist, suppress that
     \MediaWiki\suppressWarnings();
     $this->assertFalse($pidLock->removeLock());
     \MediaWiki\restoreWarnings();
 }