Skip to content

Commit

Permalink
move global php_disable_warnings in KphpCoreContext (#1119)
Browse files Browse the repository at this point in the history
  • Loading branch information
astrophysik authored Oct 16, 2024
1 parent b266bf4 commit c77dd1a
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion runtime/interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 1 addition & 2 deletions runtime/php_assert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
}

Expand Down
1 change: 0 additions & 1 deletion runtime/php_assert.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion tests/cpp/runtime/_runtime-tests-env.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
8 changes: 8 additions & 0 deletions tests/phpt/warnings/6_disable_warnings.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
@kphp_runtime_should_not_warn ok
<?php

function should_warn() {
warning("simple warning");
}

@should_warn();

0 comments on commit c77dd1a

Please sign in to comment.