/** * Load all the tasks that have been recently closed. */ private function loadRecentlyClosedTasks() { list($ignored, $window_epoch) = $this->getWindow(); $table = new ManiphestTask(); $xtable = new ManiphestTransaction(); $conn_r = $table->establishConnection('r'); $tasks = queryfx_all($conn_r, 'SELECT t.* FROM %T t JOIN %T x ON x.taskID = t.id WHERE t.status != 0 AND x.oldValue IN (null, %s, %s) AND x.newValue NOT IN (%s, %s) AND t.dateModified >= %d AND x.dateCreated >= %d', $table->getTableName(), $xtable->getTableName(), json_encode((int) ManiphestTaskStatus::STATUS_OPEN), json_encode((string) ManiphestTaskStatus::STATUS_OPEN), json_encode((int) ManiphestTaskStatus::STATUS_OPEN), json_encode((string) ManiphestTaskStatus::STATUS_OPEN), $window_epoch, $window_epoch); return id(new ManiphestTask())->loadAllFromArray($tasks); }
/** * Load all the tasks that have been recently closed. */ private function loadRecentlyClosedTasks() { list($ignored, $window_epoch) = $this->getWindow(); $table = new ManiphestTask(); $xtable = new ManiphestTransaction(); $conn_r = $table->establishConnection('r'); // TODO: Gross. This table is not meant to be queried like this. Build // real stats tables. $open_status_list = array(); foreach (ManiphestTaskStatus::getOpenStatusConstants() as $constant) { $open_status_list[] = json_encode((string) $constant); } $rows = queryfx_all($conn_r, 'SELECT t.id FROM %T t JOIN %T x ON x.objectPHID = t.phid WHERE t.status NOT IN (%Ls) AND x.oldValue IN (null, %Ls) AND x.newValue NOT IN (%Ls) AND t.dateModified >= %d AND x.dateCreated >= %d', $table->getTableName(), $xtable->getTableName(), ManiphestTaskStatus::getOpenStatusConstants(), $open_status_list, $open_status_list, $window_epoch, $window_epoch); if (!$rows) { return array(); } $ids = ipull($rows, 'id'); $query = id(new ManiphestTaskQuery())->setViewer($this->getRequest()->getUser())->withIDs($ids); switch ($this->view) { case 'project': $query->needProjectPHIDs(true); break; } return $query->execute(); }
<?php $table = new ManiphestTransaction(); $conn_w = $table->establishConnection('w'); echo pht("Converting Maniphest project transactions to modern edge transactions...\n"); $metadata = array('edge:type' => PhabricatorProjectObjectHasProjectEdgeType::EDGECONST); foreach (new LiskMigrationIterator($table) as $txn) { if ($txn->getTransactionType() != 'projects') { continue; } $old_value = mig20141222_build_edge_data($txn->getOldValue(), $txn->getObjectPHID()); $new_value = mig20141222_build_edge_data($txn->getNewValue(), $txn->getObjectPHID()); queryfx($conn_w, 'UPDATE %T SET ' . 'transactionType = %s, oldValue = %s, newValue = %s, metaData = %s ' . 'WHERE id = %d', $table->getTableName(), PhabricatorTransactions::TYPE_EDGE, json_encode($old_value), json_encode($new_value), json_encode($metadata), $txn->getID()); } echo pht('Done.') . "\n"; function mig20141222_build_edge_data($project_phids, $task_phid) { $edge_data = array(); // See T9464. If we didn't get a proper array value out of the transaction, // just return an empty value so we can move forward. if (!is_array($project_phids)) { return $edge_data; } foreach ($project_phids as $project_phid) { if (!is_scalar($project_phid)) { continue; } $edge_data[$project_phid] = array('src' => $task_phid, 'type' => PhabricatorProjectObjectHasProjectEdgeType::EDGECONST, 'dst' => $project_phid); } return $edge_data; }
} echo "Done.\n"; } if ($purge_differential) { echo "Purging Differential comment cache...\n"; $table = new DifferentialComment(); queryfx($table->establishConnection('w'), 'UPDATE %T SET cache = NULL', $table->getTableName()); echo "Purging Differential inline comment cache...\n"; $table = new DifferentialInlineComment(); queryfx($table->establishConnection('w'), 'UPDATE %T SET cache = NULL', $table->getTableName()); echo "Done.\n"; } if ($purge_maniphest) { echo "Purging Maniphest comment cache...\n"; $table = new ManiphestTransaction(); queryfx($table->establishConnection('w'), 'UPDATE %T SET cache = NULL', $table->getTableName()); echo "Done.\n"; } echo "Ok, caches purged.\n"; function usage($message) { echo "Usage Error: {$message}"; echo "\n\n"; echo "Run 'purge_cache.php --help' for detailed help.\n"; exit(1); } function help() { $help = <<<EOHELP **SUMMARY**
/** * Load all the tasks that have been recently closed. */ private function loadRecentlyClosedTasks() { list(, , $window_epoch) = $this->getWindow($this->request); $table = new ManiphestTask(); $xtable = new ManiphestTransaction(); $conn_r = $table->establishConnection('r'); // TODO: Gross. This table is not meant to be queried like this. Build // real stats tables. $rows = queryfx_all($conn_r, 'SELECT t.id FROM %T t JOIN %T x ON x.objectPHID = t.phid WHERE t.status NOT IN (%Ls) AND x.oldValue IN (null, %Ls) AND x.newValue NOT IN (%Ls) AND t.dateModified >= %d AND x.dateCreated >= %d', $table->getTableName(), $xtable->getTableName(), ManiphestTaskStatus::getOpenStatusConstants(), $this->getOpenStatusList(), $this->getOpenStatusList(), $window_epoch, $window_epoch); if (!$rows) { return array(); } $ids = ipull($rows, 'id'); return id(new ManiphestTaskQuery())->setViewer($this->request->getUser())->withIDs($ids)->needProjectPHIDs(true)->execute(); }
<?php $table = new ManiphestTransaction(); $conn_w = $table->establishConnection('w'); echo pht("Converting Maniphest CC transactions to modern " . "subscriber transactions...\n"); foreach (new LiskMigrationIterator($table) as $txn) { // ManiphestTransaction::TYPE_CCS if ($txn->getTransactionType() == 'ccs') { queryfx($conn_w, 'UPDATE %T SET transactionType = %s WHERE id = %d', $table->getTableName(), PhabricatorTransactions::TYPE_SUBSCRIBERS, $txn->getID()); } } echo pht('Done.') . "\n";