protected function setUp()
 {
     parent::setUp();
     $this->messageReporterFactory = MessageReporterFactory::getInstance();
     $this->tableBuilder = TableBuilder::factory($this->getStore()->getConnection(DB_MASTER));
     $this->stringValidator = $this->testEnvironment->getUtilityFactory()->newValidatorFactory()->newStringValidator();
 }
Ejemplo n.º 2
0
 /**
  * @since 1.9.2
  *
  * @param Store $store
  * @param TitleCreator $titleCreator
  */
 public function __construct(Store $store, TitleCreator $titleCreator)
 {
     $this->store = $store;
     $this->titleCreator = $titleCreator;
     $this->reporter = MessageReporterFactory::getInstance()->newNullMessageReporter();
     $this->distinctEntityDataRebuilder = new DistinctEntityDataRebuilder($store, $titleCreator);
     $this->exceptionFileLogger = new ExceptionFileLogger('rebuilddata');
 }
 /**
  * @since 2.2
  *
  * @param Store $store
  * @param Callable|null $reporterCallback
  *
  * @return PropertyStatisticsRebuilder
  */
 public function newPropertyStatisticsRebuilder(Store $store, $reporterCallback = null)
 {
     $messageReporter = MessageReporterFactory::getInstance()->newObservableMessageReporter();
     $messageReporter->registerReporterCallback($reporterCallback);
     $propertyStatisticsTable = new PropertyStatisticsTable($store->getConnection('mw.db'), SQLStore::PROPERTY_STATISTICS_TABLE);
     $propertyStatisticsRebuilder = new PropertyStatisticsRebuilder($store, $propertyStatisticsTable);
     $propertyStatisticsRebuilder->setMessageReporter($messageReporter);
     return $propertyStatisticsRebuilder;
 }
 /**
  * @see Maintenance::execute
  */
 public function execute()
 {
     if (!defined('SMW_VERSION') || !$GLOBALS['smwgSemanticsEnabled']) {
         $this->output("You need to have SMW enabled in order to use this maintenance script!\n\n");
         exit;
     }
     $applicationFactory = ApplicationFactory::getInstance();
     $maintenanceFactory = $applicationFactory->newMaintenanceFactory();
     $fulltextSearchTableFactory = new FulltextSearchTableFactory();
     // Only the SQLStore is supported
     $searchTableRebuilder = $fulltextSearchTableFactory->newSearchTableRebuilder($applicationFactory->getStore('\\SMW\\SQLStore\\SQLStore'));
     $searchTableRebuilder->reportVerbose($this->hasOption('v'));
     $this->reportMessage("\nThe script rebuilds the search index from property tables that\n" . "support a fulltext search. Any change of the index rules (altered\n" . "stopwords, new stemmer etc.) and/or a newly added or altered table\n" . "requires to run this script again to ensure that the index complies\n" . "with the rules set forth by the DB or Sanitizer.\n\n");
     $searchTable = $searchTableRebuilder->getSearchTable();
     $textSanitizer = $fulltextSearchTableFactory->newTextSanitizer();
     foreach ($textSanitizer->getVersions() as $key => $value) {
         $this->reportMessage("\r" . sprintf("%-35s%s", "- {$key}", $value) . "\n");
     }
     $this->reportMessage("\nThe following properties are exempted from the fulltext search index.\n");
     $exemptionList = '';
     foreach ($searchTable->getPropertyExemptionList() as $prop) {
         $exemptionList .= ($exemptionList === '' ? '' : ', ') . $prop;
         if (strlen($exemptionList) > 60) {
             $this->reportMessage("\n- " . $exemptionList);
             $exemptionList = '';
         }
     }
     $this->reportMessage("\n- " . $exemptionList . "\n\n");
     $this->reportMessage("The entire index table is going to be purged first and \n" . "it may take a moment before the rebuild is completed due to\n" . "dependencies on table content and selected options.\n");
     if (!$this->hasOption('quick')) {
         $this->reportMessage("\n" . 'Abort the rebuild with control-c in the next five seconds ...  ');
         wfCountDown(5);
     }
     $maintenanceHelper = $maintenanceFactory->newMaintenanceHelper();
     $maintenanceHelper->initRuntimeValues();
     // 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 = MessageReporterFactory::getInstance()->newObservableMessageReporter();
     $reporter->registerReporterCallback(array($this, 'reportMessage'));
     $searchTableRebuilder->setMessageReporter($reporter);
     $result = $searchTableRebuilder->run();
     if ($result && $this->hasOption('report-runtime')) {
         $this->reportMessage("\n" . $maintenanceHelper->transformRuntimeValuesForOutput() . "\n");
     }
     if ($this->hasOption('with-maintenance-log')) {
         $maintenanceLogger = $maintenanceFactory->newMaintenanceLogger('RebuildFulltextSearchTableLogger');
         $maintenanceLogger->log($maintenanceHelper->transformRuntimeValuesForOutput());
     }
     $maintenanceHelper->reset();
     return $result;
 }
 /**
  * @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;
     }
     $applicationFactory = ApplicationFactory::getInstance();
     $maintenanceFactory = $applicationFactory->newMaintenanceFactory();
     $store = $applicationFactory->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 = MessageReporterFactory::getInstance()->newObservableMessageReporter();
     $reporter->registerReporterCallback(array($this, 'reportMessage'));
     $statisticsRebuilder = $maintenanceFactory->newPropertyStatisticsRebuilder($store, $statsTable);
     $statisticsRebuilder->setMessageReporter($reporter);
     $statisticsRebuilder->rebuild();
 }
 /**
  * @since 2.5
  *
  * @param WebRequest $webRequest
  *
  * @return callable
  */
 public function doUpdate(WebRequest $webRequest)
 {
     if (!$this->enabledSetupStore) {
         return;
     }
     $messageReporter = MessageReporterFactory::getInstance()->newObservableMessageReporter();
     $messageReporter->registerReporterCallback(array($this, 'reportMessage'));
     $this->outputFormatter->setPageTitle($this->getMessage('smw_smwadmin_db'));
     $this->outputFormatter->addParentLink();
     $this->store->getOptions()->set(Installer::OPT_MESSAGEREPORTER, $messageReporter);
     $this->outputFormatter->addHTML(Html::rawElement('p', array(), $this->getMessage('smw_smwadmin_permissionswarn')));
     $this->outputFormatter->addHTML('<pre>');
     // Output is generated by the injected 'installer.messagereporter'
     $result = $this->store->setup();
     $this->outputFormatter->addHTML('</pre>');
     if ($result === true && $webRequest->getText('udsure') == 'yes') {
         $this->outputFormatter->addWikiText('<p><b>' . $this->getMessage('smw_smwadmin_setupsuccess') . "</b></p>");
     }
 }
 public function testNewObservableMessageReporter()
 {
     $instance = new MessageReporterFactory();
     $this->assertInstanceOf('\\Onoi\\MessageReporter\\ObservableMessageReporter', $instance->newObservableMessageReporter());
 }
 protected function setUp()
 {
     parent::setUp();
     $this->spyMessageReporter = MessageReporterFactory::getInstance()->newSpyMessageReporter();
 }
Ejemplo n.º 9
0
 /**
  * @since 1.9.2
  *
  * @param Store $store
  * @param TitleCreator $titleCreator
  */
 public function __construct(Store $store, TitleCreator $titleCreator)
 {
     $this->store = $store;
     $this->titleCreator = $titleCreator;
     $this->reporter = MessageReporterFactory::getInstance()->newNullMessageReporter();
 }
 /**
  * @since 2.5
  *
  * @param SearchTableUpdater $searchTableUpdater
  * @param Database $connection
  */
 public function __construct(Database $connection, SearchTableUpdater $searchTableUpdater)
 {
     $this->connection = $connection;
     $this->searchTableUpdater = $searchTableUpdater;
     $this->messageReporter = MessageReporterFactory::getInstance()->newNullMessageReporter();
 }
 /**
  * @since 1.9.2
  *
  * @param Store $store
  * @param Settings $settings
  */
 public function __construct(Store $store, Settings $settings)
 {
     $this->store = $store;
     $this->settings = $settings;
     $this->reporter = MessageReporterFactory::getInstance()->newNullMessageReporter();
 }
Ejemplo n.º 12
0
 /**
  * @since 2.5
  *
  * @return Installer
  */
 public function newInstaller()
 {
     $messageReporter = MessageReporterFactory::getInstance()->newNullMessageReporter();
     $options = $this->store->getOptions();
     $tableBuilder = TableBuilder::factory($this->store->getConnection(DB_MASTER));
     $tableBuilder->setMessageReporter($messageReporter);
     $tableIntegrityExaminer = new TableIntegrityExaminer($this->store);
     $tableSchemaManager = new TableSchemaManager($this->store);
     $installer = new Installer($tableSchemaManager, $tableBuilder, $tableIntegrityExaminer);
     if ($options->has(Installer::OPT_MESSAGEREPORTER)) {
         $installer->setMessageReporter($options->get(Installer::OPT_MESSAGEREPORTER));
     }
     $installer->isFromExtensionSchemaUpdate($options->has('isFromExtensionSchemaUpdate') ? $options->get('isFromExtensionSchemaUpdate') : false);
     return $installer;
 }
Ejemplo n.º 13
0
 private function newMessageReporter($verbose = true)
 {
     if (!$verbose) {
         $messageReporter = MessageReporterFactory::getInstance()->newNullMessageReporter();
     } else {
         $messageReporter = MessageReporterFactory::getInstance()->newObservableMessageReporter();
         $messageReporter->registerReporterCallback(array($this, 'reportMessage'));
     }
     return $this->messageReporter !== null ? $this->messageReporter : $messageReporter;
 }
Ejemplo n.º 14
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;
     }
     $maintenanceFactory = ApplicationFactory::getInstance()->newMaintenanceFactory();
     $maintenanceHelper = $maintenanceFactory->newMaintenanceHelper();
     $maintenanceHelper->initRuntimeValues();
     if ($this->hasOption('no-cache')) {
         $maintenanceHelper->setGlobalToValue('wgMainCacheType', CACHE_NONE);
         $maintenanceHelper->setGlobalToValue('smwgValueLookupCacheType', CACHE_NONE);
     }
     if ($this->hasOption('debug')) {
         $maintenanceHelper->setGlobalToValue('wgShowExceptionDetails', true);
         $maintenanceHelper->setGlobalToValue('wgShowSQLErrors', true);
         $maintenanceHelper->setGlobalToValue('wgShowDBErrorBacktrace', true);
     }
     $reporter = MessageReporterFactory::getInstance()->newObservableMessageReporter();
     $reporter->registerReporterCallback(array($this, 'reportMessage'));
     $store = StoreFactory::getStore($this->hasOption('b') ? $this->getOption('b') : null);
     $store->setUpdateJobsEnabledState(false);
     $dataRebuilder = $maintenanceFactory->newDataRebuilder($store);
     $dataRebuilder->setMessageReporter($reporter);
     $dataRebuilder->setOptions(new Options($this->mOptions));
     $result = $this->checkForRebuildState($dataRebuilder->rebuild());
     if ($result && $this->hasOption('report-runtime')) {
         $this->reportMessage("\n" . $maintenanceHelper->transformRuntimeValuesForOutput() . "\n");
     }
     $maintenanceHelper->reset();
     return $result;
 }
 /**
  * @since 1.9
  *
  * @param Store $store
  * @param PropertyStatisticsStore $propertyStatisticsStore
  */
 public function __construct(Store $store, PropertyStatisticsStore $propertyStatisticsStore)
 {
     $this->store = $store;
     $this->propertyStatisticsStore = $propertyStatisticsStore;
     $this->reporter = MessageReporterFactory::getInstance()->newNullMessageReporter();
 }
 /**
  * @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();
     $maintenanceFactory = $applicationFactory->newMaintenanceFactory();
     $maintenanceHelper = $maintenanceFactory->newMaintenanceHelper();
     $maintenanceHelper->initRuntimeValues();
     if ($this->hasOption('debug')) {
         $maintenanceHelper->setGlobalToValue('wgShowExceptionDetails', true);
         $maintenanceHelper->setGlobalToValue('wgShowSQLErrors', true);
         $maintenanceHelper->setGlobalToValue('wgShowDBErrorBacktrace', true);
     }
     $reporter = MessageReporterFactory::getInstance()->newObservableMessageReporter();
     $reporter->registerReporterCallback(array($this, 'reportMessage'));
     $conceptCacheRebuilder = $maintenanceFactory->newConceptCacheRebuilder($applicationFactory->getStore());
     $conceptCacheRebuilder->setMessageReporter($reporter);
     $conceptCacheRebuilder->setParameters($this->mOptions);
     $result = $this->checkForRebuildState($conceptCacheRebuilder->rebuild());
     if ($result && $this->hasOption('report-runtime')) {
         $this->reportMessage("\n" . $maintenanceHelper->transformRuntimeValuesForOutput() . "\n");
     }
     $maintenanceHelper->reset();
     return $result;
 }
 public function testCanConstructSpyMessageReporter()
 {
     $instance = new MessageReporterFactory();
     $this->assertInstanceOf('\\Onoi\\MessageReporter\\SpyMessageReporter', $instance->newSpyMessageReporter());
 }