Page MenuHomePhabricator

D20412.id48755.diff
No OneTemporary

D20412.id48755.diff

diff --git a/resources/sql/autopatches/20190412.dashboard.13.rebuild.php b/resources/sql/autopatches/20190412.dashboard.13.rebuild.php
new file mode 100644
--- /dev/null
+++ b/resources/sql/autopatches/20190412.dashboard.13.rebuild.php
@@ -0,0 +1,7 @@
+<?php
+
+PhabricatorRebuildIndexesWorker::rebuildObjectsWithQuery(
+ 'PhabricatorDashboardQuery');
+
+PhabricatorRebuildIndexesWorker::rebuildObjectsWithQuery(
+ 'PhabricatorDashboardPanelQuery');
diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -4294,6 +4294,7 @@
'PhabricatorQueryOrderVector' => 'infrastructure/query/order/PhabricatorQueryOrderVector.php',
'PhabricatorQuickSearchEngineExtension' => 'applications/search/engineextension/PhabricatorQuickSearchEngineExtension.php',
'PhabricatorRateLimitRequestExceptionHandler' => 'aphront/handler/PhabricatorRateLimitRequestExceptionHandler.php',
+ 'PhabricatorRebuildIndexesWorker' => 'applications/search/worker/PhabricatorRebuildIndexesWorker.php',
'PhabricatorRecaptchaConfigOptions' => 'applications/config/option/PhabricatorRecaptchaConfigOptions.php',
'PhabricatorRedirectController' => 'applications/base/controller/PhabricatorRedirectController.php',
'PhabricatorRefreshCSRFController' => 'applications/auth/controller/PhabricatorRefreshCSRFController.php',
@@ -10503,6 +10504,7 @@
),
'PhabricatorQuickSearchEngineExtension' => 'PhabricatorDatasourceEngineExtension',
'PhabricatorRateLimitRequestExceptionHandler' => 'PhabricatorRequestExceptionHandler',
+ 'PhabricatorRebuildIndexesWorker' => 'PhabricatorWorker',
'PhabricatorRecaptchaConfigOptions' => 'PhabricatorApplicationConfigOptions',
'PhabricatorRedirectController' => 'PhabricatorController',
'PhabricatorRefreshCSRFController' => 'PhabricatorAuthController',
diff --git a/src/applications/search/worker/PhabricatorRebuildIndexesWorker.php b/src/applications/search/worker/PhabricatorRebuildIndexesWorker.php
new file mode 100644
--- /dev/null
+++ b/src/applications/search/worker/PhabricatorRebuildIndexesWorker.php
@@ -0,0 +1,44 @@
+<?php
+
+final class PhabricatorRebuildIndexesWorker extends PhabricatorWorker {
+
+ public static function rebuildObjectsWithQuery($query_class) {
+ parent::scheduleTask(
+ __CLASS__,
+ array(
+ 'queryClass' => $query_class,
+ ),
+ array(
+ 'priority' => parent::PRIORITY_INDEX,
+ ));
+ }
+
+ protected function doWork() {
+ $viewer = PhabricatorUser::getOmnipotentUser();
+
+ $data = $this->getTaskData();
+ $query_class = idx($data, 'queryClass');
+
+ try {
+ $query = newv($query_class, array());
+ } catch (Exception $ex) {
+ throw new PhabricatorWorkerPermanentFailureException(
+ pht(
+ 'Unable to instantiate query class "%s": %s',
+ $query_class,
+ $ex->getMessage()));
+ }
+
+ $query->setViewer($viewer);
+
+ $iterator = new PhabricatorQueryIterator($query);
+ foreach ($iterator as $object) {
+ PhabricatorSearchWorker::queueDocumentForIndexing(
+ $object->getPHID(),
+ array(
+ 'force' => true,
+ ));
+ }
+ }
+
+}
diff --git a/src/infrastructure/daemon/workers/__tests__/PhabricatorWorkerTestCase.php b/src/infrastructure/daemon/workers/__tests__/PhabricatorWorkerTestCase.php
--- a/src/infrastructure/daemon/workers/__tests__/PhabricatorWorkerTestCase.php
+++ b/src/infrastructure/daemon/workers/__tests__/PhabricatorWorkerTestCase.php
@@ -8,6 +8,20 @@
);
}
+ protected function willRunOneTest($test) {
+ parent::willRunOneTest($test);
+
+ // Before we run these test cases, clear the queue. After D20412, we may
+ // have queued tasks from migrations.
+ $task_table = new PhabricatorWorkerActiveTask();
+ $conn = $task_table->establishConnection('w');
+
+ queryfx(
+ $conn,
+ 'TRUNCATE %R',
+ $task_table);
+ }
+
public function testLeaseTask() {
$task = $this->scheduleTask();
$this->expectNextLease($task, pht('Leasing should work.'));

File Metadata

Mime Type
text/plain
Expires
Sat, May 18, 3:00 AM (3 w, 6 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6291914
Default Alt Text
D20412.id48755.diff (4 KB)

Event Timeline