Пример #1
0
 public function testPrune()
 {
     $pruner = new ChangePruner(1, 1, 1, false);
     $dbw = wfGetDB(DB_MASTER);
     $dbw->delete('wb_changes', '*');
     $this->assertEquals(0, $dbw->selectRowCount('wb_changes'), 'sanity check: wb_changes table is empty');
     $this->addTestChanges();
     $this->assertEquals(2, $dbw->selectRowCount('wb_changes'), 'sanity check: 2 changes added to wb_changes');
     $pruner->setMessageReporter($this->newMessageReporter());
     $pruner->prune();
     $this->assertEquals(6, count($this->messages), 'pruner has reported 6 messages');
     $this->assertContains('pruning entries older than 2015-01-01T00:03:00Z', $this->messages[0]);
     $this->assertContains('1 rows pruned', $this->messages[1]);
     $this->assertContains('1 rows pruned', $this->messages[3]);
     $this->assertContains('0 rows pruned', $this->messages[5]);
     $this->assertEquals(0, $dbw->selectRowCount('wb_changes'), 'wb_changes table is empty');
 }
Пример #2
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
 }