Correct a parameter order swap in "diffusion.historyquery" for Mercurial
[phabricator.git] / src / applications / search / worker / PhabricatorRebuildIndexesWorker.php
blob7d5cc64b0b71331bbe31c9099b647285ee9b05bb
1 <?php
3 final class PhabricatorRebuildIndexesWorker extends PhabricatorWorker {
5 public static function rebuildObjectsWithQuery($query_class) {
6 parent::scheduleTask(
7 __CLASS__,
8 array(
9 'queryClass' => $query_class,
11 array(
12 'priority' => parent::PRIORITY_INDEX,
13 ));
16 protected function doWork() {
17 $viewer = PhabricatorUser::getOmnipotentUser();
19 $data = $this->getTaskData();
20 $query_class = idx($data, 'queryClass');
22 try {
23 $query = newv($query_class, array());
24 } catch (Exception $ex) {
25 throw new PhabricatorWorkerPermanentFailureException(
26 pht(
27 'Unable to instantiate query class "%s": %s',
28 $query_class,
29 $ex->getMessage()));
32 $query->setViewer($viewer);
34 $iterator = new PhabricatorQueryIterator($query);
35 foreach ($iterator as $object) {
36 PhabricatorSearchWorker::queueDocumentForIndexing(
37 $object->getPHID(),
38 array(
39 'force' => true,
40 ));