Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15473003
D20412.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
4 KB
Referenced Files
None
Subscribers
None
D20412.diff
View Options
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
Details
Attached
Mime Type
text/plain
Expires
Sun, Apr 6, 6:37 PM (1 d, 6 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7710521
Default Alt Text
D20412.diff (4 KB)
Attached To
Mode
D20412: Reindex dashboards and panels (allow migrations to queue a job to queue other indexing jobs)
Attached
Detach File
Event Timeline
Log In to Comment