1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-09-20 01:08:50 +02:00

Treat PHP7 "Throwable" exceptions like other unhandled "Exception" cases in the worker queue

Summary: See PHI1745. Under PHP7, errors raised as Throwable miss this "generic exception" logic and don't increment their failure count. Instead, treat any "Throwable" we don't recognize like any "Exception" we don't recognize.

Test Plan:
  - Under PHP7, caused a worker task to raise a Throwable (e.g., call to undefined method, see D21270).
  - Ran `bin/worker execute --id ...`.
  - Before: worker failed, but did not increment failure count.
  - After: worker fails and increments failure count as it would for other types of unknown error.

Differential Revision: https://secure.phabricator.com/D21271
This commit is contained in:
epriestley 2020-05-19 10:36:43 -07:00
parent 43a8d8763d
commit 4257b26abc
2 changed files with 8 additions and 1 deletions

View file

@ -134,6 +134,7 @@ final class PhabricatorWorkerActiveTask extends PhabricatorWorkerTask {
$did_succeed = false;
$worker = null;
$caught = null;
try {
$worker = $this->getWorkerInstance();
$worker->setCurrentWorkerTask($this);
@ -180,6 +181,12 @@ final class PhabricatorWorkerActiveTask extends PhabricatorWorkerTask {
$result = $this;
} catch (Exception $ex) {
$caught = $ex;
} catch (Throwable $ex) {
$caught = $ex;
}
if ($caught) {
$this->setExecutionException($ex);
$this->setFailureCount($this->getFailureCount() + 1);
$this->setFailureTime(time());

View file

@ -34,7 +34,7 @@ abstract class PhabricatorWorkerTask extends PhabricatorWorkerDAO {
) + parent::getConfiguration();
}
final public function setExecutionException(Exception $execution_exception) {
final public function setExecutionException($execution_exception) {
$this->executionException = $execution_exception;
return $this;
}