diff options
author | Roeland Jago Douma <rullzer@users.noreply.github.com> | 2018-10-08 21:31:29 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-08 21:31:29 +0200 |
commit | 1178e852068cc220e6d27757c7db79709a602971 (patch) | |
tree | d54bdb12759d481174f7588e5b3ce8eadbcc491d /core | |
parent | 6994a2a87d691b3bf869219cb21ca2ae6625a8d5 (diff) | |
parent | 311de17730174dae1f951bdf38a657e6c5453574 (diff) | |
download | nextcloud-server-1178e852068cc220e6d27757c7db79709a602971.tar.gz nextcloud-server-1178e852068cc220e6d27757c7db79709a602971.zip |
Merge pull request #11664 from nextcloud/feature/noid/has-been-interrupted-throw-exception
Syntactic sugar for hasBeenInterrupted
Diffstat (limited to 'core')
-rw-r--r-- | core/Command/Base.php | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/core/Command/Base.php b/core/Command/Base.php index dbf6c71b8f4..4eca5bcaab7 100644 --- a/core/Command/Base.php +++ b/core/Command/Base.php @@ -129,15 +129,19 @@ class Base extends Command implements CompletionAwareInterface { } /** - * @return bool + * Throw InterruptedException when interrupted by user + * + * @throws InterruptedException */ - protected function hasBeenInterrupted() { - // return always false if pcntl_signal functions are not accessible - if ($this->php_pcntl_signal) { - pcntl_signal_dispatch(); - return $this->interrupted; - } else { - return false; + protected function abortIfInterrupted() { + if ($this->php_pcntl_signal === false) { + return; + } + + pcntl_signal_dispatch(); + + if ($this->interrupted === true) { + throw new InterruptedException('Command interrupted by user'); } } |