/**
  * @see Maintenance::execute
  */
 public function execute()
 {
     if (!defined('SMW_VERSION')) {
         $this->output("You need to have SMW enabled in order to use this maintenance script!\n\n");
         exit;
     }
     $store = StoreFactory::getStore();
     $statsTable = new PropertyStatisticsTable($store->getConnection('mw.db'), \SMWSQLStore3::PROPERTY_STATISTICS_TABLE);
     // Need to instantiate an extra object here since we cannot make this class itself
     // into a MessageReporter since the maintenance script does not load the interface in time.
     $reporter = new ObservableMessageReporter();
     $reporter->registerReporterCallback(array($this, 'reportMessage'));
     $statisticsRebuilder = new SimplePropertyStatisticsRebuilder($store, $reporter);
     $statisticsRebuilder->rebuild($statsTable);
 }
 /**
  * @dataProvider reportMessageProvider
  *
  * @param string $message
  */
 public function testReporterInvocation($message)
 {
     $callCount = 0;
     $asserter = array($this, 'assertEquals');
     $callback0 = function ($actual) use($message, &$callCount, $asserter) {
         $callCount += 1;
         call_user_func($asserter, $message, $actual);
     };
     $callback1 = function ($actual) use($message, &$callCount, $asserter) {
         $callCount += 1;
         call_user_func($asserter, $message, $actual);
     };
     $reporter0 = new ObservableMessageReporter();
     $reporter0->registerReporterCallback($callback0);
     $reporter1 = new ObservableMessageReporter();
     $reporter1->registerReporterCallback($callback1);
     $reporter = new ObservableMessageReporter();
     $reporter->registerMessageReporter($reporter0);
     $reporter->registerMessageReporter($reporter1);
     $reporter->reportMessage($message);
     $this->assertEquals(2, $callCount);
     $reporter->reportMessage($message);
     $this->assertEquals(4, $callCount);
 }
Esempio n. 3
0
 /**
  * @see Maintenance::execute
  */
 public function execute()
 {
     $start = microtime(true);
     $memoryBefore = memory_get_peak_usage(false);
     if (!defined('SMW_VERSION')) {
         $this->reportMessage("You need to have SMW enabled in order to run the maintenance script!\n\n");
         return false;
     }
     $reporter = new ObservableMessageReporter();
     $reporter->registerReporterCallback(array($this, 'reportMessage'));
     $store = StoreFactory::getStore($this->hasOption('b') ? $this->getOption('b') : null);
     $store->setUpdateJobsEnabledState(false);
     $dataRebuilder = new DataRebuilder($store);
     $dataRebuilder->setMessageReporter($reporter);
     $dataRebuilder->setParameters($this->mOptions);
     if ($dataRebuilder->rebuild()) {
         $this->doReportRuntimeEnvironment($memoryBefore, memory_get_peak_usage(false), microtime(true) - $start);
         return true;
     }
     $this->reportMessage($this->mDescription . "\n\n" . 'Use option --help for usage details.' . "\n");
     return false;
 }
Esempio n. 4
0
 /**
  * @see Maintenance::execute
  */
 public function execute()
 {
     if (!defined('SMW_VERSION')) {
         $this->reportMessage("You need to have SMW enabled in order to run the maintenance script!\n\n");
         return false;
     }
     $applicationFactory = ApplicationFactory::getInstance();
     $reporter = new ObservableMessageReporter();
     $reporter->registerReporterCallback(array($this, 'reportMessage'));
     $conceptCacheRebuilder = new ConceptCacheRebuilder($applicationFactory->getStore(), $applicationFactory->getSettings());
     $conceptCacheRebuilder->setMessageReporter($reporter);
     $conceptCacheRebuilder->setParameters($this->mOptions);
     if ($conceptCacheRebuilder->rebuild()) {
         return true;
     }
     $this->reportMessage($this->mDescription . "\n\n" . 'Use option --help for usage details.' . "\n");
     return false;
 }