[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/src/applications/daemon/garbagecollector/ -> PhabricatorDaemonTaskGarbageCollector.php (source)

   1  <?php
   2  
   3  final class PhabricatorDaemonTaskGarbageCollector
   4    extends PhabricatorGarbageCollector {
   5  
   6    public function collectGarbage() {
   7      $key = 'gcdaemon.ttl.task-archive';
   8      $ttl = PhabricatorEnv::getEnvConfig($key);
   9      if ($ttl <= 0) {
  10        return false;
  11      }
  12  
  13      $table = new PhabricatorWorkerArchiveTask();
  14      $data_table = new PhabricatorWorkerTaskData();
  15      $conn_w = $table->establishConnection('w');
  16  
  17      $rows = queryfx_all(
  18        $conn_w,
  19        'SELECT id, dataID FROM %T WHERE dateCreated < %d LIMIT 100',
  20        $table->getTableName(),
  21        time() - $ttl);
  22  
  23      if (!$rows) {
  24        return false;
  25      }
  26  
  27      $data_ids = array_filter(ipull($rows, 'dataID'));
  28      $task_ids = ipull($rows, 'id');
  29  
  30      $table->openTransaction();
  31        if ($data_ids) {
  32          queryfx(
  33            $conn_w,
  34            'DELETE FROM %T WHERE id IN (%Ld)',
  35            $data_table->getTableName(),
  36            $data_ids);
  37        }
  38        queryfx(
  39          $conn_w,
  40          'DELETE FROM %T WHERE id IN (%Ld)',
  41          $table->getTableName(),
  42          $task_ids);
  43      $table->saveTransaction();
  44  
  45      return (count($task_ids) == 100);
  46    }
  47  
  48  }


Generated: Sun Nov 30 09:20:46 2014 Cross-referenced by PHPXref 0.7.1