From e5f2478b9f93a12590bae8af1720321880271797 Mon Sep 17 00:00:00 2001 From: Rajesh Taneja Date: Tue, 21 Jun 2016 12:15:21 +0800 Subject: [PATCH] MDL-54974 behat: Handle interupts on PHP7 As https://bugs.php.net/bug.php?id=71448 is not going to get fixed, we need to declare tick --- admin/tool/behat/cli/run.php | 3 +++ lib/tests/behat/behat_hooks.php | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/admin/tool/behat/cli/run.php b/admin/tool/behat/cli/run.php index 98fc3057314..f8a37e77523 100644 --- a/admin/tool/behat/cli/run.php +++ b/admin/tool/behat/cli/run.php @@ -101,6 +101,9 @@ if (empty($options['torun'])) { if (extension_loaded('pcntl')) { $disabled = explode(',', ini_get('disable_functions')); if (!in_array('pcntl_signal', $disabled)) { + // Handle interrupts on PHP7. + declare(ticks = 1); + pcntl_signal(SIGTERM, "signal_handler"); pcntl_signal(SIGINT, "signal_handler"); } diff --git a/lib/tests/behat/behat_hooks.php b/lib/tests/behat/behat_hooks.php index 0b954133e11..856968fff48 100644 --- a/lib/tests/behat/behat_hooks.php +++ b/lib/tests/behat/behat_hooks.php @@ -160,6 +160,14 @@ class behat_hooks extends behat_base { if (!empty($CFG->behat_faildump_path) && !is_writable($CFG->behat_faildump_path)) { throw new Exception('You set $CFG->behat_faildump_path to a non-writable directory'); } + + // Handle interrupts on PHP7. + if (extension_loaded('pcntl')) { + $disabled = explode(',', ini_get('disable_functions')); + if (!in_array('pcntl_signal', $disabled)) { + declare(ticks = 1); + } + } } /**