Skip to content

Commit fd689d0

Browse files
authored
Add enable hook can only be run in CLI mode (#3823)
* Add enable hook can only be run in CLI mode * fix * fix
1 parent 46aee5a commit fd689d0

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

ext-src/swoole_runtime.cc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1163,6 +1163,10 @@ bool PHPCoroutine::disable_hook() {
11631163
}
11641164

11651165
static PHP_METHOD(swoole_runtime, enableCoroutine) {
1166+
if (!SWOOLE_G(cli)) {
1167+
php_swoole_fatal_error(E_ERROR, "must be used in PHP CLI mode");
1168+
RETURN_FALSE;
1169+
}
11661170
zval *zflags = nullptr;
11671171
zend_long flags = PHPCoroutine::HOOK_ALL;
11681172

@@ -1200,6 +1204,10 @@ static PHP_METHOD(swoole_runtime, getHookFlags) {
12001204
}
12011205

12021206
static PHP_METHOD(swoole_runtime, setHookFlags) {
1207+
if (!SWOOLE_G(cli)) {
1208+
php_swoole_fatal_error(E_ERROR, "must be used in PHP CLI mode");
1209+
RETURN_FALSE;
1210+
}
12031211
zend_long flags = PHPCoroutine::HOOK_ALL;
12041212

12051213
ZEND_PARSE_PARAMETERS_START(1, 1)

0 commit comments

Comments
 (0)