From c77dd1aa3a66457b8ef85f4aa640ea6b0ec77551 Mon Sep 17 00:00:00 2001 From: Vadim Sadokhov <65451602+astrophysik@users.noreply.github.com> Date: Wed, 16 Oct 2024 17:09:18 +0300 Subject: [PATCH] move global php_disable_warnings in KphpCoreContext (#1119) --- runtime/interface.cpp | 2 +- runtime/php_assert.cpp | 3 +-- runtime/php_assert.h | 1 - tests/cpp/runtime/_runtime-tests-env.cpp | 2 +- tests/phpt/warnings/6_disable_warnings.php | 8 ++++++++ 5 files changed, 11 insertions(+), 5 deletions(-) create mode 100644 tests/phpt/warnings/6_disable_warnings.php diff --git a/runtime/interface.cpp b/runtime/interface.cpp index cb4439dc8f..5281810390 100644 --- a/runtime/interface.cpp +++ b/runtime/interface.cpp @@ -2301,7 +2301,7 @@ static void init_interface_lib() { finished = false; php_warning_level = std::max(2, php_warning_minimum_level); - php_disable_warnings = 0; + KphpCoreContext::current().php_disable_warnings = 0; is_json_log_on_timeout_enabled = true; is_demangled_stacktrace_logs_enabled = false; ignore_level = 0; diff --git a/runtime/php_assert.cpp b/runtime/php_assert.cpp index a41b6d1a8b..109e2c44fc 100644 --- a/runtime/php_assert.cpp +++ b/runtime/php_assert.cpp @@ -36,7 +36,6 @@ long long engine_tag_number = 0; const char *engine_pid = "] "; -int php_disable_warnings = 0; int php_warning_level = 2; int php_warning_minimum_level = 0; @@ -93,7 +92,7 @@ static void print_demangled_adresses(void **buffer, int nptrs, int num_shift, bo } static void php_warning_impl(bool out_of_memory, int error_type, char const *message, va_list args) { - if (php_warning_level == 0 || php_disable_warnings) { + if (php_warning_level == 0 || KphpCoreContext::current().php_disable_warnings) { return; } diff --git a/runtime/php_assert.h b/runtime/php_assert.h index e35ded1eef..6938094f4e 100644 --- a/runtime/php_assert.h +++ b/runtime/php_assert.h @@ -20,7 +20,6 @@ extern long long engine_tag_number; extern const char *engine_pid; -extern int php_disable_warnings; extern int php_warning_level; extern int php_warning_minimum_level; diff --git a/tests/cpp/runtime/_runtime-tests-env.cpp b/tests/cpp/runtime/_runtime-tests-env.cpp index ee911ea7b3..9fc7c59185 100644 --- a/tests/cpp/runtime/_runtime-tests-env.cpp +++ b/tests/cpp/runtime/_runtime-tests-env.cpp @@ -32,7 +32,7 @@ class RuntimeTestsEnvironment final : public testing::Environment { global_init_script_allocator(); init_runtime_environment(null_query_data{}, PhpScriptMutableGlobals::current().get_superglobals(), script_memory, script_memory_size); - php_disable_warnings = true; + KphpCoreContext::current().php_disable_warnings = true; php_warning_level = 0; } diff --git a/tests/phpt/warnings/6_disable_warnings.php b/tests/phpt/warnings/6_disable_warnings.php new file mode 100644 index 0000000000..15acc5482e --- /dev/null +++ b/tests/phpt/warnings/6_disable_warnings.php @@ -0,0 +1,8 @@ +@kphp_runtime_should_not_warn ok +