From 61d7343eb8fa3661baa7987ebb83e6942e08d079 Mon Sep 17 00:00:00 2001 From: Michal Nowacki Date: Wed, 25 Jun 2025 16:22:30 -0400 Subject: [PATCH 1/7] chore: bump version for next release (#1093) --- VERSION | 2 +- axiom/nr_version.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/VERSION b/VERSION index 933dbb1df..4b8f58769 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -11.10.0 +11.11.0 diff --git a/axiom/nr_version.c b/axiom/nr_version.c index 098fd0650..bc4c7d6c4 100644 --- a/axiom/nr_version.c +++ b/axiom/nr_version.c @@ -23,7 +23,6 @@ /* * Current version naming scheme is gemstones * - * impatiens 13Feb2023 (10.6) * jasmine 08Mar2023 (10.7) * kalmia 27Mar2023 (10.8) * lilac 05Apr2023 (10.9) @@ -50,8 +49,9 @@ * gaspeite 19Mar2025 (11.7) * hiddenite 21Apr2025 (11.8) * indicolite 13May2025 (11.9) + * jade 25Jun2025 (11.10) */ -#define NR_CODENAME "jade" +#define NR_CODENAME "kernite" const char* nr_version(void) { return NR_STR2(NR_VERSION); From 546c0e513bcba06129a46657bba638d620edd17a Mon Sep 17 00:00:00 2001 From: Michael Fulbright <89205663+mfulb@users.noreply.github.com> Date: Tue, 8 Jul 2025 10:26:04 -0400 Subject: [PATCH 2/7] tests: fix integration_runner opcache module loading (#1097) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit With recent official PHP docker images the Zend OPCache extension is loaded by default. This is causing some test failures as PHP will output a warning message when the `integration_runner` attempts to load this extension. As a result any `EXPECT` statements in tests will fail due to this extra output. The solution chosen was to use the “-m” option for the `php` and `php-cgi` binaries to probe if the Zend OPCache module is loaded by default in the PHP environment. Both binaries are used in testing so the defaults of both are considered. The value of the integration_runner command line option `opcache_off` is also noted. When a test is going to be run this information is used to determine if the `zend_extension=opcache.so` is needed as well as setting the values of `opcache.enable` and `opcache.enable_cli`. These INI values needed special handling because it is possible these are overwritten by values in the INI stanza of a given test case. Also consideration is needed to if the `PHPMODULES` stanza exists in the test case and specifies loading the `opcache.so` module. --------- Co-authored-by: Michal Nowacki --- daemon/cmd/integration_runner/main.go | 36 ++++++++---- .../internal/newrelic/integration/context.go | 14 +++-- daemon/internal/newrelic/integration/test.go | 46 +++++++++++++-- .../newrelic/integration/transaction.go | 57 ++++++++++++++++++- daemon/internal/newrelic/integration/util.go | 32 ++++++++++- 5 files changed, 159 insertions(+), 26 deletions(-) diff --git a/daemon/cmd/integration_runner/main.go b/daemon/cmd/integration_runner/main.go index 60c0247d8..04e32626b 100644 --- a/daemon/cmd/integration_runner/main.go +++ b/daemon/cmd/integration_runner/main.go @@ -51,6 +51,7 @@ var ( flagMaxCustomEvents = flag.Int("max_custom_events", 30000, "value for newrelic.custom_events.max_samples_stored") flagWarnIsFail = flag.Bool("warnisfail", false, "warn result is treated as a fail") flagOpcacheOff = flag.Bool("opcacheoff", false, "run without opcache. Some tests are intended to fail when run this way") + flagDebug = flag.Bool("debug", false, "enable debug logging for integration_runner") // externalPort is the port on which we start a server to handle // external calls. @@ -362,15 +363,8 @@ func main() { ctx.Settings["newrelic.loglevel"] = *flagLoglevel } - if false == *flagOpcacheOff { - // PHP Modules common to all tests - ctx.Settings["zend_extension"] = "opcache.so" - - // PHP INI values common to all tests - // These settings can be overwritten by adding new values to the INI block - ctx.Settings["opcache.enable"] = "1" - ctx.Settings["opcache.enable_cli"] = "1" - } + ctx.OPCacheModuleLoaded = integration.GetOPCacheModuleLoaded(*flagPHP, *flagCGI) + ctx.UseOPCache = !*flagOpcacheOff // If the user provided a custom agent extension, use it. if len(*flagAgent) > 0 { @@ -459,8 +453,14 @@ func main() { if numFailed > 0 { os.Exit(1) } - if *flagWarnIsFail && numWarned > 0 { - os.Exit(2) + + if numWarned > 0 { + if *flagWarnIsFail { + fmt.Println("WARNING: some tests were warned, but are treated as failures because --warnisfail is true") + os.Exit(2) + } else { + fmt.Printf("WARNING: some tests were warned, but are not treated as failures because --warnisfail is false\n") + } } } @@ -534,6 +534,10 @@ func runTest(t *integration.Test) { if skipIf != nil { _, body, err := skipIf.Execute() + if *flagDebug { + fmt.Printf("SkipIf output:\n%s\n", body) + } + if err != nil { t.Output = body t.Fatal(fmt.Errorf("error executing skipif: %v", err)) @@ -545,6 +549,12 @@ func runTest(t *integration.Test) { t.Skip(reason) return } + + if warnRE.Match(body) && *flagWarnIsFail { + reason := string(bytes.TrimSpace(head(body))) + t.Warn(reason) + return + } } // Reset global response headers before the test is run. This feature @@ -564,6 +574,10 @@ func runTest(t *integration.Test) { t.Duration = 0 } + if *flagDebug { + fmt.Printf("Test output:\n%s\n", body) + } + // Always save the test output. If an error occurred it may contain // critical information regarding the cause. Currently, it may also // contain valgrind commentary which we want to display. diff --git a/daemon/internal/newrelic/integration/context.go b/daemon/internal/newrelic/integration/context.go index 7801f31d2..6c5dd0224 100644 --- a/daemon/internal/newrelic/integration/context.go +++ b/daemon/internal/newrelic/integration/context.go @@ -12,12 +12,14 @@ import ( ) type Context struct { - PHP string // path to the PHP CLI executable - CGI string // path to the PHP CGI executable - Valgrind string // path to the Valgrind executable, or empty if disabled - Env map[string]string // environment variables to pass to each test - Settings map[string]string // settings to pass to each test - Timeout time.Duration // maximum test duration + PHP string // path to the PHP CLI executable + CGI string // path to the PHP CGI executable + Valgrind string // path to the Valgrind executable, or empty if disabled + Env map[string]string // environment variables to pass to each test + Settings map[string]string // settings to pass to each test + Timeout time.Duration // maximum test duration + OPCacheModuleLoaded map[string]bool // map of PHP and CGI to OPcache default loaded status + UseOPCache bool // whether to use OPcache in tests } func NewContext(php, cgi string) *Context { diff --git a/daemon/internal/newrelic/integration/test.go b/daemon/internal/newrelic/integration/test.go index 1911ac58c..0926564fd 100644 --- a/daemon/internal/newrelic/integration/test.go +++ b/daemon/internal/newrelic/integration/test.go @@ -201,7 +201,34 @@ func merge(a, b map[string]string) map[string]string { return merged } +// checks the context to see if opcache is loaded by default +// and then handles the PHP modules requests to make sure +// we don't load opcache.so if it is already loaded by default +func (t *Test) HandlePHPModules(php_executable string, ctx *Context) map[string]string { + // two cases: + // 1. Web test and php-cgi has opcache.so loaded by default - remove any PHPMODULE spec for opcache.so + // 2. PHP test and php has opcache.so loaded by default - remove any PHPMODULE spec for opcache.so + phpModulesCopy := make(map[string]string) + if ctx.OPCacheModuleLoaded[php_executable] { + for k, v := range t.PhpModules { + if !strings.Contains(v, "opcache.so") { + phpModulesCopy[k] = v + } + } + } + + return phpModulesCopy +} + func (t *Test) MakeRun(ctx *Context) (Tx, error) { + + // we don't support running C tests - assert this so we can + // troubleshoot if we try to run a C test + if t.IsC() { + fmt.Printf("ERROR - UNEXPECTED - Running C test: %s\n", t.Path) + os.Exit(1) + } + t.Env = merge(ctx.Env, t.Env) settings := merge(ctx.Settings, t.Settings) settings["newrelic.appname"] = t.Name @@ -214,11 +241,18 @@ func (t *Test) MakeRun(ctx *Context) (Tx, error) { } } - settings = merge(settings, t.PhpModules) - - if t.IsC() { - return CTx(ScriptFile(t.Path), t.Env, settings, headers, ctx) + var php_executable string + if t.IsWeb() { + php_executable = ctx.CGI + } else if t.IsPHP() { + php_executable = ctx.PHP + } else { + return nil, fmt.Errorf("unknown test type for %s", t.Path) } + + phpModulesCopy := t.HandlePHPModules(php_executable, ctx) + settings = merge(settings, phpModulesCopy) + if t.IsWeb() { return CgiTx(ScriptFile(t.Path), t.Env, settings, headers, ctx) } @@ -241,6 +275,10 @@ func (t *Test) MakeSkipIf(ctx *Context) (Tx, error) { data: t.rawSkipIf, } + // handle the PHPMODULES directive + phpModulesCopy := t.HandlePHPModules(ctx.PHP, ctx) + settings = merge(settings, phpModulesCopy) + return PhpTx(src, t.Env, settings, ctx) } diff --git a/daemon/internal/newrelic/integration/transaction.go b/daemon/internal/newrelic/integration/transaction.go index b69b4b004..dc582c4f5 100644 --- a/daemon/internal/newrelic/integration/transaction.go +++ b/daemon/internal/newrelic/integration/transaction.go @@ -41,12 +41,61 @@ func flatten(x map[string]string) []string { return s } +// fixup settings to handle opcache module loading gracefully +// +// php_executable is the name to the PHP executable +// env is the environment variables to pass to the PHP process +// settings is the PHP settings to apply to the process +// ctx is the context containing configuration options +func fixupSettings(php_executable string, env, settings map[string]string, ctx *Context) map[string]string { + + // Make a copy of settings to avoid mutating the original map + // Need to adjust settings to opcache + phpSettings := make(map[string]string, len(settings)) + setOPCacheEnable := true + setOPCacheEnableCLI := true + + for k, v := range settings { + phpSettings[k] = v + + // see if settings affect opcache config + // if so then we will not set config below + if k == "opcache.enable" { + setOPCacheEnable = false + } else if k == "opcache.enable_cli" { + setOPCacheEnableCLI = false + } + } + if ctx.UseOPCache { + if !ctx.OPCacheModuleLoaded[php_executable] { + phpSettings["zend_extension"] = "opcache.so" + } + if setOPCacheEnable { + phpSettings["opcache.enable"] = "1" + } + if setOPCacheEnableCLI { + phpSettings["opcache.enable_cli"] = "1" + } + } else { + if setOPCacheEnable { + phpSettings["opcache.enable"] = "0" + } + if setOPCacheEnableCLI { + phpSettings["opcache.enable_cli"] = "0" + } + } + + return phpSettings +} + // PhpTx constructs non-Web transactions to be executed by PHP. func PhpTx(src Script, env, settings map[string]string, ctx *Context) (Tx, error) { // Note: file path must be relative to the working directory. var txn Tx - args := phpArgs(nil, filepath.Base(src.Name()), false, settings) + newSettings := fixupSettings(ctx.PHP, env, settings, ctx) + + args := phpArgs(nil, filepath.Base(src.Name()), false, newSettings) if ctx.Valgrind != "" && settings["newrelic.appname"] != "skipif" { txn = &ValgrindCLI{ @@ -83,6 +132,8 @@ func CgiTx(src Script, env, settings map[string]string, headers http.Header, ctx var err error var txn Tx + newSettings := fixupSettings(ctx.CGI, env, settings, ctx) + req := &http.Request{ Method: env["REQUEST_METHOD"], RequestURI: "/" + filepath.Base(src.Name()) + "?" + env["QUERY_STRING"], @@ -113,7 +164,7 @@ func CgiTx(src Script, env, settings map[string]string, headers http.Header, ctx handler: &cgi.Handler{ Path: ctx.CGI, Dir: src.Dir(), - Args: phpArgs(nil, "", false, settings), + Args: phpArgs(nil, "", false, newSettings), }, }, Valgrind: ctx.Valgrind, @@ -144,7 +195,7 @@ func CgiTx(src Script, env, settings map[string]string, headers http.Header, ctx handler: &cgi.Handler{ Path: ctx.CGI, Dir: src.Dir(), - Args: phpArgs(nil, "", false, settings), + Args: phpArgs(nil, "", false, newSettings), }, } tx.handler.Env = append(tx.handler.Env, diff --git a/daemon/internal/newrelic/integration/util.go b/daemon/internal/newrelic/integration/util.go index 25ab9462f..daa75f607 100644 --- a/daemon/internal/newrelic/integration/util.go +++ b/daemon/internal/newrelic/integration/util.go @@ -6,12 +6,14 @@ package integration import ( + "bytes" "fmt" + "os" "os/exec" ) func GetPHPVersion() string { - cmd := exec.Command("php", "-r", "echo PHP_VERSION;") + cmd := exec.Command("php", "-d", "newrelic.daemon.dont_launch=3", "-r", "echo PHP_VERSION;") output, err := cmd.Output() if err != nil { @@ -23,7 +25,7 @@ func GetPHPVersion() string { } func GetAgentVersion(agent_extension string) string { - cmd := exec.Command("php", "-d", "extension="+agent_extension, "-r", "echo phpversion('newrelic');") + cmd := exec.Command("php", "-d", "newrelic.daemon.dont_launch=3", "-d", "extension="+agent_extension, "-r", "echo phpversion('newrelic');") output, err := cmd.Output() if err != nil { @@ -31,3 +33,29 @@ func GetAgentVersion(agent_extension string) string { } return string(output) } + +func IsOPcacheLoaded(php_executable string) bool { + fmt.Printf("Checking if OPcache is loaded using %s\n", php_executable) + cmd := exec.Command(php_executable, "-d", "newrelic.daemon.dont_launch=3", "-m") + + output, err := cmd.Output() + + if err != nil { + fmt.Printf("Failed to check if OPcache is loaded: %v\n", err) + os.Exit(1) + } + + // Check if "Zend OPcache" is in the output + return bytes.Contains(output, []byte("Zend OPcache")) +} + +func GetOPCacheModuleLoaded(php, cgi string) map[string]bool { + result := make(map[string]bool) + + result[php] = IsOPcacheLoaded(php) + result[cgi] = IsOPcacheLoaded(cgi) + + fmt.Printf("OPcache default loaded status: %+v\n", result) + + return result +} From f58a45912e27b2ba36b85d7550291bd5710f8b7c Mon Sep 17 00:00:00 2001 From: Hitesh Ahuja <108540135+hahuja2@users.noreply.github.com> Date: Wed, 9 Jul 2025 12:27:32 -0700 Subject: [PATCH 3/7] chore(agent): remove obsolete code (#1098) --- agent/config.m4 | 10 +- agent/fw_codeigniter.c | 4 - agent/fw_drupal8.c | 4 - agent/fw_hooks.h | 8 +- agent/fw_kohana.c | 113 ------- agent/fw_laminas3.c | 2 +- agent/fw_laravel.c | 5 - agent/fw_laravel_queue.c | 12 - agent/fw_lumen.c | 5 - agent/fw_silex.c | 108 ------ agent/fw_symfony.c | 205 ----------- agent/fw_symfony2.c | 129 ------- agent/fw_zend.c | 244 -------------- agent/{fw_zend2.c => fw_zend3.c} | 92 +++-- agent/lib_guzzle3.c | 319 ------------------ agent/lib_guzzle4.c | 29 -- agent/lib_guzzle6.c | 20 -- agent/lib_guzzle_common.c | 27 -- agent/lib_guzzle_common.h | 2 +- agent/lib_zend_http.c | 5 +- agent/php_agent.c | 300 +--------------- agent/php_agent.h | 87 +---- agent/php_api.c | 48 --- agent/php_api_datastore.c | 2 - agent/php_api_distributed_trace.c | 2 - agent/php_call.c | 116 +------ agent/php_compat.h | 116 ------- agent/php_curl.c | 4 - agent/php_environment.c | 29 -- agent/php_error.c | 22 -- agent/php_execute.c | 99 +----- agent/php_execute.h | 4 - agent/php_explain.c | 6 - agent/php_file_get_contents.c | 2 - agent/php_hash.c | 99 ------ agent/php_hash.h | 60 ---- agent/php_hooks.h | 9 - agent/php_includes.h | 10 - agent/php_internal_instrument.c | 21 +- agent/php_newrelic.h | 68 +--- agent/php_nrini.c | 35 -- agent/php_output.c | 35 +- agent/php_pdo.c | 4 - agent/php_pdo_private.h | 8 - agent/php_rshutdown.c | 2 - agent/php_stack.c | 112 ------ agent/php_txn.c | 23 -- agent/php_vm.c | 4 +- agent/php_wrapper.c | 46 +-- agent/php_zval.h | 58 ---- agent/scripts/newrelic.ini.template | 9 +- agent/tests/test_agent.c | 11 - agent/tests/test_api_datastore.c | 3 - agent/tests/test_api_distributed_trace.c | 3 - agent/tests/test_api_internal.c | 3 - agent/tests/test_api_metadata_dt_disabled.c | 3 - agent/tests/test_api_metadata_dt_enabled.c | 3 - agent/tests/test_call.c | 7 - agent/tests/test_curl.c | 3 - agent/tests/test_curl_md.c | 3 - agent/tests/test_datastore.c | 3 - agent/tests/test_fw_codeigniter.c | 9 - agent/tests/test_fw_drupal.c | 4 - agent/tests/test_fw_wordpress.c | 3 - agent/tests/test_hash.c | 3 - agent/tests/test_internal_instrument.c | 3 - agent/tests/test_lib_aws_sdk_php.c | 5 - agent/tests/test_lib_php_amqplib.c | 5 - agent/tests/test_mongodb.c | 10 - agent/tests/test_mysql.c | 3 - agent/tests/test_mysqli.c | 3 - agent/tests/test_output.c | 29 -- agent/tests/test_pdo.c | 5 - agent/tests/test_pdo_mysql.c | 3 - agent/tests/test_pdo_pgsql.c | 3 - agent/tests/test_pgsql.c | 3 - agent/tests/test_php_execute.c | 3 - agent/tests/test_php_stack.c | 3 - agent/tests/test_php_stacked_segment.c | 3 - agent/tests/test_php_wrapper.c | 3 - agent/tests/test_predis.c | 3 - agent/tests/test_redis.c | 3 - agent/tests/test_txn.c | 3 - agent/tests/test_user_instrument.c | 3 - agent/tests/test_user_instrument_hashmap.c | 3 - .../test_user_instrument_wraprec_hashmap.c | 3 - agent/tests/test_zval.c | 6 - agent/tests/tlib_php.c | 84 +---- .../errors/test_E_DEPRECATED_1.php | 75 ---- .../errors/test_E_DEPRECATED_2.php5.php | 78 ----- .../integration/errors/test_E_ERROR.php5.php | 75 ---- .../errors/test_E_ERROR.php7.0.0.php | 79 ----- .../errors/test_E_RECOVERABLE.php5.php | 80 ----- .../integration/errors/test_E_STRICT.php5.php | 81 ----- .../errors/test_E_WARNING.php5.php | 79 ----- .../test_ignore_all_except_E_WARNING.php5.php | 85 ----- .../frameworks/silex/Silex/Application.php | 46 --- tests/integration/frameworks/silex/skipif.inc | 10 - .../frameworks/silex/test_basic.php | 51 --- .../silex/test_basic_logging_off.php | 54 --- .../silex/test_invalid_attributes.php | 52 --- .../frameworks/silex/test_invalid_request.php | 48 --- .../lang/test_generator_5.6-7.0.php | 91 ----- tests/integration/memcached/test_cas.php5.php | 100 ------ .../memcached/test_cas_by_key.php5.php | 106 ------ .../output/test_clean_after_header_5.3.php | 54 --- 106 files changed, 108 insertions(+), 4172 deletions(-) delete mode 100644 agent/fw_kohana.c delete mode 100644 agent/fw_silex.c delete mode 100644 agent/fw_symfony.c delete mode 100644 agent/fw_symfony2.c delete mode 100644 agent/fw_zend.c rename agent/{fw_zend2.c => fw_zend3.c} (52%) delete mode 100644 agent/lib_guzzle3.c delete mode 100644 tests/integration/errors/test_E_DEPRECATED_1.php delete mode 100644 tests/integration/errors/test_E_DEPRECATED_2.php5.php delete mode 100644 tests/integration/errors/test_E_ERROR.php5.php delete mode 100644 tests/integration/errors/test_E_ERROR.php7.0.0.php delete mode 100644 tests/integration/errors/test_E_RECOVERABLE.php5.php delete mode 100644 tests/integration/errors/test_E_STRICT.php5.php delete mode 100644 tests/integration/errors/test_E_WARNING.php5.php delete mode 100644 tests/integration/errors/test_ignore_all_except_E_WARNING.php5.php delete mode 100644 tests/integration/frameworks/silex/Silex/Application.php delete mode 100644 tests/integration/frameworks/silex/skipif.inc delete mode 100644 tests/integration/frameworks/silex/test_basic.php delete mode 100644 tests/integration/frameworks/silex/test_basic_logging_off.php delete mode 100644 tests/integration/frameworks/silex/test_invalid_attributes.php delete mode 100644 tests/integration/frameworks/silex/test_invalid_request.php delete mode 100644 tests/integration/lang/test_generator_5.6-7.0.php delete mode 100644 tests/integration/memcached/test_cas.php5.php delete mode 100644 tests/integration/memcached/test_cas_by_key.php5.php delete mode 100644 tests/integration/output/test_clean_after_header_5.3.php diff --git a/agent/config.m4 b/agent/config.m4 index 03a386992..12ec7cc07 100644 --- a/agent/config.m4 +++ b/agent/config.m4 @@ -223,13 +223,13 @@ if test "$PHP_NEWRELIC" = "yes"; then php_user_instrument_wraprec_hashmap.c \ php_user_instrument_hashmap.c php_vm.c php_wrapper.c" FRAMEWORKS="fw_cakephp.c fw_codeigniter.c fw_drupal8.c \ - fw_drupal.c fw_drupal_common.c fw_joomla.c fw_kohana.c \ + fw_drupal.c fw_drupal_common.c fw_joomla.c \ fw_laminas3.c fw_laravel.c fw_laravel_queue.c fw_lumen.c \ fw_magento1.c fw_magento2.c fw_magento_common.c fw_mediawiki.c \ - fw_silex.c fw_slim.c fw_support.c fw_symfony4.c fw_symfony2.c \ - fw_symfony.c fw_symfony_common.c fw_wordpress.c fw_yii.c \ - fw_zend2.c fw_zend.c" - LIBRARIES="lib_aws_sdk_php.c lib_monolog.c lib_doctrine2.c lib_guzzle3.c \ + fw_slim.c fw_support.c fw_symfony4.c \ + fw_symfony_common.c fw_wordpress.c fw_yii.c \ + fw_zend3.c" + LIBRARIES="lib_aws_sdk_php.c lib_monolog.c lib_doctrine2.c \ lib_guzzle4.c lib_guzzle6.c lib_guzzle_common.c \ lib_mongodb.c lib_phpunit.c lib_predis.c lib_zend_http.c \ lib_composer.c lib_php_amqplib.c" diff --git a/agent/fw_codeigniter.c b/agent/fw_codeigniter.c index 1a85a1a7d..145a7b07f 100644 --- a/agent/fw_codeigniter.c +++ b/agent/fw_codeigniter.c @@ -15,7 +15,6 @@ #include "util_strings.h" zend_op_array* nr_codeigniter_get_topmost_user_op_array(TSRMLS_D) { -#ifdef PHP7 zend_execute_data* ed = NULL; for (ed = EG(current_execute_data); ed; ed = ed->prev_execute_data) { @@ -27,9 +26,6 @@ zend_op_array* nr_codeigniter_get_topmost_user_op_array(TSRMLS_D) { } return NULL; -#else - return EG(current_execute_data)->op_array; -#endif /* PHP7 */ } /* diff --git a/agent/fw_drupal8.c b/agent/fw_drupal8.c index 2178c9aee..66e449694 100644 --- a/agent/fw_drupal8.c +++ b/agent/fw_drupal8.c @@ -197,11 +197,7 @@ static int nr_drupal8_is_function_in_call_stack(const char* function, trace = nr_php_zval_alloc(); /* Grab the actual backtrace. */ -#if ZEND_MODULE_API_NO >= ZEND_5_4_X_API_NO zend_fetch_debug_backtrace(trace, 0, 1, 0 TSRMLS_CC); -#else /* PHP < 5.4 */ - zend_fetch_debug_backtrace(trace, 0, 1 TSRMLS_CC); -#endif if (!nr_php_is_zval_valid_array(trace)) { nrl_error(NRL_TXN, "%s: trace should never not be an array", __func__); diff --git a/agent/fw_hooks.h b/agent/fw_hooks.h index 93665862c..cb0bffe39 100644 --- a/agent/fw_hooks.h +++ b/agent/fw_hooks.h @@ -20,28 +20,22 @@ extern void nr_drupal_enable(TSRMLS_D); extern void nr_drupal8_enable(TSRMLS_D); extern void nr_joomla_enable(TSRMLS_D); -extern void nr_kohana_enable(TSRMLS_D); extern void nr_laminas3_enable(TSRMLS_D); extern void nr_laravel_enable(TSRMLS_D); extern void nr_lumen_enable(TSRMLS_D); extern void nr_magento1_enable(TSRMLS_D); extern void nr_magento2_enable(TSRMLS_D); extern void nr_mediawiki_enable(TSRMLS_D); -extern void nr_symfony1_enable(TSRMLS_D); -extern void nr_symfony2_enable(TSRMLS_D); extern void nr_symfony4_enable(TSRMLS_D); -extern void nr_silex_enable(TSRMLS_D); extern void nr_slim_enable(TSRMLS_D); extern void nr_wordpress_enable(TSRMLS_D); extern void nr_yii1_enable(TSRMLS_D); extern void nr_yii2_enable(TSRMLS_D); -extern void nr_zend_enable(TSRMLS_D); -extern void nr_fw_zend2_enable(TSRMLS_D); +extern void nr_fw_zend3_enable(TSRMLS_D); /* Libraries. */ extern void nr_aws_sdk_php_enable(); extern void nr_doctrine2_enable(TSRMLS_D); -extern void nr_guzzle3_enable(TSRMLS_D); extern void nr_guzzle4_enable(TSRMLS_D); extern void nr_guzzle6_enable(TSRMLS_D); extern void nr_laminas_http_enable(TSRMLS_D); diff --git a/agent/fw_kohana.c b/agent/fw_kohana.c deleted file mode 100644 index d618f4ba2..000000000 --- a/agent/fw_kohana.c +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Copyright 2020 New Relic Corporation. All rights reserved. - * SPDX-License-Identifier: Apache-2.0 - */ - -#include "php_agent.h" -#include "php_call.h" -#include "php_user_instrument.h" -#include "php_execute.h" -#include "php_wrapper.h" -#include "fw_hooks.h" -#include "fw_support.h" -#include "util_logging.h" - -/* Determine whether a Kohana request or route is actually an external call. */ -static int nr_kohana_is_external_request(zval* request TSRMLS_DC) { - int is_external = 0; - - if (nr_php_object_has_method(request, "is_external" TSRMLS_CC)) { - zval* retval; - - retval = nr_php_call(request, "is_external"); - is_external = nr_php_is_zval_true(retval); - nr_php_zval_free(&retval); - } - - return is_external; -} - -/* - * We trap calls to Kohana_Request::execute. We then verify two - * preconditions. 1) The request is internal (i.e. incoming to the app), - * and 2) the request matched a defined route. If both conditions are - * met, we name the transaction 'Controller/Action' where the values - * are retrieved from the request object. Note, the controller and action - * are only valid if a route was found. - */ -NR_PHP_WRAPPER(nr_kohana_name_the_wt) { - zval* this_var = NULL; - zval* route = NULL; - - (void)wraprec; - NR_UNUSED_SPECIALFN; - - NR_PHP_WRAPPER_REQUIRE_FRAMEWORK(NR_FW_KOHANA); - - this_var = nr_php_scope_get(NR_EXECUTE_ORIG_ARGS TSRMLS_CC); - - NR_PHP_WRAPPER_CALL; - - if (!nr_php_is_zval_valid_object(this_var)) { - nrl_verbosedebug(NRL_FRAMEWORK, "Kohana: invalid object"); - goto leave; - } - - if (nr_kohana_is_external_request(this_var TSRMLS_CC)) { - nrl_verbosedebug(NRL_FRAMEWORK, - "Kohana: request is external, no name this time"); - goto leave; - } - - if ((0 == nr_php_object_has_method(this_var, "route" TSRMLS_CC)) - || (0 == nr_php_object_has_method(this_var, "controller" TSRMLS_CC)) - || (0 == nr_php_object_has_method(this_var, "action" TSRMLS_CC))) { - nrl_verbosedebug(NRL_FRAMEWORK, - "Kohana: object inconsistent with a Kohana_Request"); - goto leave; - } - - route = nr_php_call(this_var, "route"); - if (nr_php_is_zval_valid_object(route)) { - /* Found a route, should have a valid controller and action. */ - zval* controller = NULL; - zval* action = NULL; - char name[255 + 1]; /* max metric name length + 1 */ - - controller = nr_php_call(this_var, "controller"); - action = nr_php_call(this_var, "action"); - - name[0] = '\0'; - snprintf( - name, sizeof(name), "%.*s/%.*s", - nr_php_is_zval_non_empty_string(controller) - ? NRSAFELEN(Z_STRLEN_P(controller)) - : 32, - nr_php_is_zval_non_empty_string(controller) ? Z_STRVAL_P(controller) - : "NoController", - nr_php_is_zval_non_empty_string(action) ? NRSAFELEN(Z_STRLEN_P(action)) - : 32, - nr_php_is_zval_non_empty_string(action) ? Z_STRVAL_P(action) - : "NoAction"); - nr_php_zval_free(&controller); - nr_php_zval_free(&action); - nr_txn_set_path("Kohana", NRPRG(txn), name, NR_PATH_TYPE_ACTION, - NR_OK_TO_OVERWRITE); - } - -leave: - nr_php_zval_free(&route); - nr_php_scope_release(&this_var); -} -NR_PHP_WRAPPER_END - -/* - * Enable the Kohana instrumentation - */ -void nr_kohana_enable(TSRMLS_D) { - /* We set the path to 'unknown' to prevent having to name routing errors. */ - nr_txn_set_path("Kohana", NRPRG(txn), "unknown", NR_PATH_TYPE_ACTION, - NR_NOT_OK_TO_OVERWRITE); - nr_php_wrap_user_function(NR_PSTR("Kohana_Request::execute"), - nr_kohana_name_the_wt TSRMLS_CC); -} diff --git a/agent/fw_laminas3.c b/agent/fw_laminas3.c index a57ce7286..f79eefd00 100644 --- a/agent/fw_laminas3.c +++ b/agent/fw_laminas3.c @@ -18,7 +18,7 @@ /* * Laminas is a rebranding of Zend, but the logic remains the same, * it is simply a name change and corresponds directly to Zend 3.x. - * Compare to `fw_zend2.c` + * Compare to `fw_zend3.c` * * How Laminas nee Zend Routing Works * ===================== diff --git a/agent/fw_laravel.c b/agent/fw_laravel.c index 29621e37d..dc409ec10 100644 --- a/agent/fw_laravel.c +++ b/agent/fw_laravel.c @@ -490,13 +490,8 @@ static void nr_laravel_name_transaction(zval* router, zval* request TSRMLS_DC) { * */ NR_PHP_WRAPPER(nr_laravel5_exception_render) { -#if ZEND_MODULE_API_NO >= ZEND_5_4_X_API_NO const char* class_name = NULL; const char* ignored = NULL; -#else - char* class_name = NULL; - char* ignored = NULL; -#endif /* PHP >= 5.4 */ char* name = NULL; diff --git a/agent/fw_laravel_queue.c b/agent/fw_laravel_queue.c index 0ac042800..e79451ead 100644 --- a/agent/fw_laravel_queue.c +++ b/agent/fw_laravel_queue.c @@ -620,7 +620,6 @@ NR_PHP_WRAPPER(nr_laravel_queue_worker_process) { if (EG(exception)) { zval* exception_zval = NULL; -#if ZEND_MODULE_API_NO >= ZEND_7_0_X_API_NO /* PHP 7.0+ */ /* * On PHP 7, EG(exception) is stored as a zend_object, and is only wrapped * in a zval when it actually needs to be. Unfortunately, our error handling @@ -640,12 +639,6 @@ NR_PHP_WRAPPER(nr_laravel_queue_worker_process) { ZVAL_OBJ(&exception, EG(exception)); exception_zval = &exception; -#else - /* - * On PHP 5, the exception is just a regular old zval. - */ - exception_zval = EG(exception); -#endif /* PHP7+ */ nr_php_error_record_exception( NRPRG(txn), exception_zval, NR_PHP_ERROR_PRIORITY_UNCAUGHT_EXCEPTION, @@ -835,13 +828,8 @@ NR_PHP_WRAPPER(nr_laravel_queue_queue_createpayload) { /* * Finally, we change the string in the return value to our new JSON. */ -#if ZEND_MODULE_API_NO >= ZEND_7_0_X_API_NO /* PHP 7.0+ */ zend_string_free(Z_STR_P(*retval_ptr)); Z_STR_P(*retval_ptr) = zend_string_copy(Z_STR_P(json)); -#else - efree(Z_STRVAL_PP(retval_ptr)); - nr_php_zval_str_len(*retval_ptr, Z_STRVAL_P(json), Z_STRLEN_P(json)); -#endif /* PHP7+ */ end: nr_php_zval_free(&payload); diff --git a/agent/fw_lumen.c b/agent/fw_lumen.c index 2d34551f0..79f89ebc3 100644 --- a/agent/fw_lumen.c +++ b/agent/fw_lumen.c @@ -166,13 +166,8 @@ NR_PHP_WRAPPER(nr_lumen_exception) { NR_PHP_WRAPPER_REQUIRE_FRAMEWORK(NR_FW_LUMEN); -#if ZEND_MODULE_API_NO >= ZEND_5_4_X_API_NO const char* class_name = NULL; const char* ignored = NULL; -#else - char* class_name = NULL; - char* ignored = NULL; -#endif /* PHP >= 5.4 */ char* name = NULL; diff --git a/agent/fw_silex.c b/agent/fw_silex.c deleted file mode 100644 index 147235ef6..000000000 --- a/agent/fw_silex.c +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Copyright 2020 New Relic Corporation. All rights reserved. - * SPDX-License-Identifier: Apache-2.0 - */ - -#include "php_agent.h" -#include "php_call.h" -#include "php_user_instrument.h" -#include "php_execute.h" -#include "php_wrapper.h" -#include "fw_hooks.h" -#include "fw_support.h" -#include "util_logging.h" -#include "util_memory.h" - -/* - * This instruments Silex 1.x, and at the time of writing (March 30, 2015), - * also instruments the pre-alpha Silex 2.0. - * - * This support is intentionally simple: while Silex permits many components to - * be swapped out, the framework itself is so simple that it's not unreasonable - * to expect users who do so to also make newrelic_name_transaction calls. At - * any rate, the call we need to instrument is only defined on HttpKernel, not - * the HttpKernelInterface contract it implements, so a user who's replaced the - * kernel probably won't reimplement this method and will instead handle their - * routing some other way. - */ - -NR_PHP_WRAPPER(nr_silex_name_the_wt) { - zval* attributes = NULL; - zval* name = NULL; - char* path = NULL; - zval* request = NULL; - zval* route = NULL; - - (void)wraprec; - - NR_PHP_WRAPPER_REQUIRE_FRAMEWORK(NR_FW_SILEX); - - request = nr_php_arg_get(1, NR_EXECUTE_ORIG_ARGS TSRMLS_CC); - if (!nr_php_object_instanceof_class( - request, "Symfony\\Component\\HttpFoundation\\Request" TSRMLS_CC)) { - nrl_verbosedebug(NRL_INSTRUMENT, - "%s: first parameter isn't a Request object", __func__); - NR_PHP_WRAPPER_CALL; - goto end; - } - - NR_PHP_WRAPPER_CALL; - - /* - * The approach here is straightforward: the first parameter to - * HttpKernel::handleRaw() is a Request object, which has an attributes - * property, which contains a _route property (accessible via a get() method) - * that is either a good autogenerated name (based on the route pattern) or - * the controller name the user provided explictly via the Controller::bind() - * method. - * - * Either way, let's grab it and name the transaction from it. - */ - - attributes = nr_php_get_zval_object_property(request, "attributes" TSRMLS_CC); - if (!nr_php_object_instanceof_class( - attributes, - "Symfony\\Component\\HttpFoundation\\ParameterBag" TSRMLS_CC)) { - nrl_verbosedebug(NRL_INSTRUMENT, - "%s: Request::$attributes isn't a ParameterBag object", - __func__); - goto end; - } - - name = nr_php_zval_alloc(); - nr_php_zval_str(name, "_route"); - - route = nr_php_call(attributes, "get", name); - if (!nr_php_is_zval_non_empty_string(route)) { - nrl_verbosedebug(NRL_INSTRUMENT, "%s: _route is not a valid string", - __func__); - goto end; - } - - path = nr_strndup(Z_STRVAL_P(route), Z_STRLEN_P(route)); - - /* - * This is marked as not OK to overwrite as we're unwinding the stack (due to - * this being a post-handler), and we want the innermost name to win to - * handle forwarded subrequests. - */ - nr_txn_set_path("Silex", NRPRG(txn), path, NR_PATH_TYPE_ACTION, - NR_NOT_OK_TO_OVERWRITE); - - /* FALLTHROUGH */ - -end: - nr_php_zval_free(&name); - nr_free(path); - nr_php_zval_free(&route); - nr_php_arg_release(&request); -} -NR_PHP_WRAPPER_END - -void nr_silex_enable(TSRMLS_D) { - NR_UNUSED_TSRMLS; - - nr_php_wrap_user_function( - NR_PSTR("Symfony\\Component\\HttpKernel\\HttpKernel::handleRaw"), - nr_silex_name_the_wt TSRMLS_CC); -} diff --git a/agent/fw_symfony.c b/agent/fw_symfony.c deleted file mode 100644 index a0f8e460d..000000000 --- a/agent/fw_symfony.c +++ /dev/null @@ -1,205 +0,0 @@ -/* - * Copyright 2020 New Relic Corporation. All rights reserved. - * SPDX-License-Identifier: Apache-2.0 - */ - -#include "php_agent.h" -#include "php_call.h" -#include "php_user_instrument.h" -#include "php_execute.h" -#include "php_wrapper.h" -#include "fw_hooks.h" -#include "fw_support.h" -#include "util_logging.h" -#include "util_memory.h" -#include "util_strings.h" - -NR_PHP_WRAPPER(nr_symfony1_controller_dispatch) { - int prev_dispatch = NRPRG(symfony1_in_dispatch); - - (void)wraprec; - NR_UNUSED_SPECIALFN; - - NR_PHP_WRAPPER_REQUIRE_FRAMEWORK(NR_FW_SYMFONY1); - - NRPRG(symfony1_in_dispatch) = 1; - NR_PHP_WRAPPER_CALL; - NRPRG(symfony1_in_dispatch) = prev_dispatch; -} -NR_PHP_WRAPPER_END - -NR_PHP_WRAPPER(nr_symfony1_error404exception_printstacktrace) { - int prev_error404 = NRPRG(symfony1_in_error404); - - (void)wraprec; - NR_UNUSED_SPECIALFN; - - NR_PHP_WRAPPER_REQUIRE_FRAMEWORK(NR_FW_SYMFONY1); - - NRPRG(symfony1_in_error404) = 1; - NR_PHP_WRAPPER_CALL; - NRPRG(symfony1_in_error404) = prev_error404; -} -NR_PHP_WRAPPER_END - -/* - * Determine the Web Transaction name from the Symfony1 dispatcher. - * Usage: called from a specific user function wrapper - */ -NR_PHP_WRAPPER(nr_symfony1_name_the_wt) { - zval* module_name = 0; - zval* action_name = 0; - - (void)wraprec; - NR_UNUSED_SPECIALFN; - - NR_PHP_WRAPPER_REQUIRE_FRAMEWORK(NR_FW_SYMFONY1); - - /* - * We're looking for a particular active call stack: - * 1. (php function) ...->dispatch (...) - * ..calls.. - * 2. (php function) ...->forward (module_name, action_name) (This function - * pre-call wrapped) - * - * This is to say we wrap the call to "forward", but are only sensitive to - * that frame if it is called from dispatch. We track this via the - * symfony1_in_dispatch global, which is set by the above - * nr_symfony1_controller_dispatch() wrapper. - */ - if (0 == NRPRG(symfony1_in_dispatch)) { - nrl_debug(NRL_FRAMEWORK, "%s: forward() called, but not from dispatch()", - __func__); - NR_PHP_WRAPPER_LEAVE; - } - - module_name = nr_php_arg_get(1, NR_EXECUTE_ORIG_ARGS TSRMLS_CC); - action_name = nr_php_arg_get(2, NR_EXECUTE_ORIG_ARGS TSRMLS_CC); - - if (0 == nr_php_is_zval_non_empty_string(module_name)) { - nrl_debug(NRL_FRAMEWORK, "Symfony1 module_name not a string"); - goto end; - } - - if (0 == nr_php_is_zval_non_empty_string(action_name)) { - nrl_debug(NRL_FRAMEWORK, "Symfony1 action_name not a string"); - goto end; - } - - { - char* name = nr_formatf("%.*s/%.*s", NRSAFELEN(Z_STRLEN_P(module_name)), - Z_STRVAL_P(module_name), - NRSAFELEN(Z_STRLEN_P(action_name)), - Z_STRVAL_P(action_name)); - nr_txn_assignment_t ok_to_override; - - /* - * This bit of hackery is here for BC reasons. Prior to version 6.6 of the - * agent, we always named Symfony 1 transactions based on the initially - * resolved action. This allowed for MGIs due to the way Symfony 1 handles - * 404 errors: it initially tries to synthesise the controller and action - * from the request URL and routes based on that, then only handles the - * routing error by forwarding after the 404 exception is thrown. - * - * The simple fix here is to name based on the final resolved action (after - * all forwards are complete), which is what we do in Symfony 2/3, but - * doing so will change the automatic transaction names for users who - * forward to different controller actions. So instead we'll have an extra - * check for whether Symfony is handling a 404: if so, then (and only then) - * will we use the target of the forwarded transaction to name the - * transaction. - * - * There is a very minor bit of cheese moving nevertheless: if the user - * calls sfAction::forward() _within_ an action configured as the 404 - * handler, we'll now name on the last action rather than the first. - */ - if (NRPRG(symfony1_in_error404)) { - ok_to_override = NR_OK_TO_OVERWRITE; - } else { - ok_to_override = NR_NOT_OK_TO_OVERWRITE; - } - - nr_txn_set_path("Symfony1", NRPRG(txn), name, NR_PATH_TYPE_ACTION, - ok_to_override); - - nr_free(name); - } - -end: - NR_PHP_WRAPPER_CALL; - - nr_php_arg_release(&module_name); - nr_php_arg_release(&action_name); -} -NR_PHP_WRAPPER_END - -NR_PHP_WRAPPER(nr_symfony1_context_loadfactories) { - zval* controller; - zval* name; - zval* scope; - - (void)wraprec; - NR_UNUSED_SPECIALFN; - - NR_PHP_WRAPPER_REQUIRE_FRAMEWORK(NR_FW_SYMFONY1); - - scope = nr_php_scope_get(NR_EXECUTE_ORIG_ARGS TSRMLS_CC); - - /* - * First, we need to actually call loadFactories(), since the information we - * need is filled in by it. - */ - NR_PHP_WRAPPER_CALL; - - /* - * Now we need to get the controller class so we can wrap methods on it. - * Effectively, we need to call $this->get('controller'). (Another option - * would be to poke around in the $factories array, but as get() is the - * public API, let's use that so we're not tied too deeply to implementation - * details.) - */ - name = nr_php_zval_alloc(); - nr_php_zval_str(name, "controller"); - controller = nr_php_call(scope, "get", name); - if (nr_php_is_zval_valid_object(controller)) { - const char* klass = nr_php_class_entry_name(Z_OBJCE_P(controller)); - char* method; - - method = nr_formatf("%s::dispatch", klass); - nr_php_wrap_user_function(method, nr_strlen(method), - nr_symfony1_controller_dispatch TSRMLS_CC); - nr_free(method); - - method = nr_formatf("%s::forward", klass); - nr_php_wrap_user_function(method, nr_strlen(method), - nr_symfony1_name_the_wt TSRMLS_CC); - nr_free(method); - } else { - nrl_verbosedebug(NRL_FRAMEWORK, - "%s: the controller factory is not an object", __func__); - } - nr_php_zval_free(&controller); - nr_php_zval_free(&name); - - nr_php_scope_release(&scope); -} -NR_PHP_WRAPPER_END - -void nr_symfony1_enable(TSRMLS_D) { - NRPRG(symfony1_in_dispatch) = 0; - NRPRG(symfony1_in_error404) = 0; - - /* - * We want to hook two methods on the controller class for naming purposes, - * but it's possible for the user to override which class this is via - * factories.yml. As a result, we'll hook the method that loads the factories - * (which is always called as part of initialising the application), then - * instrument once we know what the controller class is. - */ - nr_php_wrap_user_function(NR_PSTR("sfContext::loadFactories"), - nr_symfony1_context_loadfactories TSRMLS_CC); - - nr_php_wrap_user_function( - NR_PSTR("sfError404Exception::printStackTrace"), - nr_symfony1_error404exception_printstacktrace TSRMLS_CC); -} diff --git a/agent/fw_symfony2.c b/agent/fw_symfony2.c deleted file mode 100644 index 0e1761f35..000000000 --- a/agent/fw_symfony2.c +++ /dev/null @@ -1,129 +0,0 @@ -/* - * Copyright 2020 New Relic Corporation. All rights reserved. - * SPDX-License-Identifier: Apache-2.0 - */ - -#include "php_agent.h" -#include "php_call.h" -#include "php_user_instrument.h" -#include "php_execute.h" -#include "php_wrapper.h" -#include "fw_hooks.h" -#include "fw_support.h" -#include "fw_symfony_common.h" -#include "util_logging.h" -#include "util_memory.h" -#include "util_strings.h" - -NR_PHP_WRAPPER(nr_symfony2_name_the_wt) { - zval* event = NULL; - zval* request = NULL; - - /* Warning avoidance. */ - (void)wraprec; - - NR_PHP_WRAPPER_REQUIRE_FRAMEWORK(NR_FW_SYMFONY2); - - /* - * A high level overview of the logic: - * - * RouterListener::onKernelRequest() receives a GetResponseEvent parameter, - * which includes the request object accessible via the getRequest() method. - * We want to get the request, then access its attributes: the request - * matcher will create a number of internal attributes prefixed by - * underscores as part of resolving the controller action. - * - * If the user has given their action method a friendly name via an - * annotation or controller option, then this is available in _route. This is - * likely to be shorter and clearer than the auto-generated controller - * method, so it's the first preference. - * - * If _route doesn't exist, then _controller should always exist. For - * non-subrequests, this will be a name Symfony generates from the fully - * qualified class name and method. For subrequests, this is whatever the - * user gave Controller::forward(), which will hopefully be more or less the - * same thing. - */ - - event = nr_php_arg_get(1, NR_EXECUTE_ORIG_ARGS TSRMLS_CC); - if (0 == nr_php_is_zval_valid_object(event)) { - nrl_verbosedebug(NRL_TXN, - "Symfony 2: RouterListener::onKernelRequest() does not " - "have an event parameter"); - NR_PHP_WRAPPER_CALL; - goto end; - } - - NR_PHP_WRAPPER_CALL; - - /* Get the request object from the event. */ - request = nr_php_call(event, "getRequest"); - if (nr_php_object_instanceof_class( - request, "Symfony\\Component\\HttpFoundation\\Request" TSRMLS_CC)) { - /* Look for _route first. */ - zval* route_rval - = nr_symfony_object_get_string(request, "_route" TSRMLS_CC); - - if (route_rval) { - if (NR_SUCCESS - != nr_symfony_name_the_wt_from_zval(route_rval TSRMLS_CC, - "Symfony 2")) { - nrl_verbosedebug( - NRL_TXN, "Symfony 2: Request::get('_route') returned a non-string"); - } - nr_php_zval_free(&route_rval); - } else { - /* No _route. Look for _controller. */ - zval* controller_rval - = nr_symfony_object_get_string(request, "_controller" TSRMLS_CC); - - if (controller_rval) { - if (NR_SUCCESS - != nr_symfony_name_the_wt_from_zval(controller_rval TSRMLS_CC, - "Symfony 2")) { - nrl_verbosedebug( - NRL_TXN, - "Symfony 2: Request::get('_controller') returned a non-string"); - } - nr_php_zval_free(&controller_rval); - } else { - nrl_verbosedebug(NRL_TXN, - "Symfony 2: Neither _controller nor _route is set"); - } - } - } else { - nrl_verbosedebug(NRL_TXN, - "Symfony 2: GetResponseEvent::getRequest() returned a " - "non-Request object"); - } - -end: - nr_php_arg_release(&event); - nr_php_zval_free(&request); -} -NR_PHP_WRAPPER_END - -void nr_symfony2_enable(TSRMLS_D) { - /* - * We set the path to 'unknown' to prevent having to name routing errors. - */ - nr_txn_set_path("Symfony2", NRPRG(txn), "unknown", NR_PATH_TYPE_ACTION, - NR_NOT_OK_TO_OVERWRITE); - - /* - * Originally, we had a pre-callback hook on HttpKernel::filterResponse(). - * This works fine for simple requests, but fails on subrequests forwarded by - * Controller::forward() due to HttpKernel::filterResponse() being called in - * the reverse order as Symfony unwinds the request stack, which means we get - * the initial request name rather than the innermost, which is what we want. - * - * We'll hook into the RouterListener. Once onKernelRequest() has - * finished its work, the controller has been resolved, so we can go from - * there. This is reliable as long as the user hasn't replaced the router - * listener service, which is a pretty deep customisation: chances are a user - * who's doing that is quite capable of naming a transaction by hand. - */ - nr_php_wrap_user_function(NR_PSTR("Symfony\\Component\\HttpKernel\\EventListe" - "ner\\RouterListener::onKernelRequest"), - nr_symfony2_name_the_wt TSRMLS_CC); -} diff --git a/agent/fw_zend.c b/agent/fw_zend.c deleted file mode 100644 index 01e7712d3..000000000 --- a/agent/fw_zend.c +++ /dev/null @@ -1,244 +0,0 @@ -/* - * Copyright 2020 New Relic Corporation. All rights reserved. - * SPDX-License-Identifier: Apache-2.0 - */ - -#include "php_agent.h" -#include "php_call.h" -#include "php_user_instrument.h" -#include "php_execute.h" -#include "php_hash.h" -#include "php_wrapper.h" -#include "fw_hooks.h" -#include "fw_support.h" -#include "lib_zend_http.h" -#include "nr_header.h" -#include "util_logging.h" -#include "util_memory.h" -#include "util_strings.h" - -/* - * How ZF1 Routing Works - * ===================== - * - * In a standard ZF1 application, requests enter the front controller - * (Zend_Controller_Front) where a route is selected based on the request URL. - * Once a route has been found, the front controller then enters the dispatch - * loop where it will determine which controller(s) and action(s) to invoke. In - * most cases, this is the controller and action associated with the route. - * However, invoking a different action, or even multiple actions is a normal - * practice in Zend applications. For example, to forward a request to another - * controller, or redirect to another URL. Zend also provides a plugin interface - * to isolate cross-cutting routing concerns into separate classes. For example, - * implementing authentication. The following pseudo-php code demonstrates the - * core logic. - * - * ``` - * Zend_Application::run() - * Zend_Application_Bootstrap::run() - * Zend_Controller_Front::dispatch($request, $response) - * $request = new Zend_Controller_Request_Http() if $request == NULL - * $response = new Zend_Controller_Response_Http() if $response == NULL - * - * $plugins->routeStartup() - * $router->route($request) - * $plugins->routeShutdown() - * - * $plugins->dispatchLoopStartup() - * - * until $request->isDispatched() - * $request->setDispatched(true) - * $plugins->preDispatch($request) - * if $request->isDispatched() - * $dispatcher->dispatch($request, $response) - * $plugins->postDispatch($request) - * - * $plugins->dispatchLoopShutdown() - * ``` - * - * Ideally, we would hook `dispatchLoopShutdown()` and thereby wait until after - * the final controller and action were selected and invoked to name the - * transaction. There are two complications that prevent us from doing so. - * - * 1. An action or plugin can end the request early by calling the `exit()` - * function. If this occurs during the dispatch loop, - * `dispatchLoopShutdown()` will never be invoked. There are at least three - * standard Zend components that do this: Redirect, Json, and AutoComplete. - * 2. An exception can be thrown at any time. - * - * To address early exits, we also hook `preDispatch()`. This ensures we - * have a chance to name the transaction when an early exit occurs, at the - * cost of redundantly setting the transaction name in each hook otherwise. - * - * We explicitly choose not to try and cope with exceptions. The default - * behavior of Zend is it catch exceptions that occur during the dispatch - * loop and record it within the response. - */ - -/* - * Purpose : Name the transaction based on the current controller and action. - * - * Params : 1. A Zend_Controller_Request_Abstract object. - * - * Returns : Nothing. - */ -static void nr_zend_name_the_wt(zval* request TSRMLS_DC) { - zval* module = NULL; - zval* controller = NULL; - zval* action = NULL; - char buf[512]; - - if (NULL == request) { - return; - } - - if ((0 == nr_php_object_has_method(request, "getModuleName" TSRMLS_CC)) - || (0 == nr_php_object_has_method(request, "getControllerName" TSRMLS_CC)) - || (0 == nr_php_object_has_method(request, "getActionName" TSRMLS_CC))) { - return; - } - - module = nr_php_call(request, "getModuleName"); - controller = nr_php_call(request, "getControllerName"); - action = nr_php_call(request, "getActionName"); - - if (module || controller || action) { - buf[0] = '\0'; - snprintf( - buf, sizeof(buf), "%.*s/%.*s/%.*s", - nr_php_is_zval_non_empty_string(module) ? NRSAFELEN(Z_STRLEN_P(module)) - : 32, - nr_php_is_zval_non_empty_string(module) ? Z_STRVAL_P(module) - : "NoModule", - - nr_php_is_zval_non_empty_string(controller) - ? NRSAFELEN(Z_STRLEN_P(controller)) - : 32, - nr_php_is_zval_non_empty_string(controller) ? Z_STRVAL_P(controller) - : "NoController", - - nr_php_is_zval_non_empty_string(action) ? NRSAFELEN(Z_STRLEN_P(action)) - : 32, - nr_php_is_zval_non_empty_string(action) ? Z_STRVAL_P(action) - : "NoAction"); - - nr_txn_set_path("Zend", NRPRG(txn), buf, NR_PATH_TYPE_ACTION, - NR_OK_TO_OVERWRITE); - } - - nr_php_zval_free(&module); - nr_php_zval_free(&controller); - nr_php_zval_free(&action); -} - -/* - * Purpose : Invoke Zend_Controller_Plugin_Broker::getRequest(). - * - * Params : 1. A Zend_Controller_Plugin_Broker object. - * - * Returns : A pointer to a zval, which is the return value of the function, - * if successful; otherwise, NULL. The caller is responsible - * for destroying the return value. - */ -static zval* nr_zend_plugin_broker_get_request(zval* plugins TSRMLS_DC) { - zval* request = NULL; - - if (NULL == plugins) { - return NULL; - } - - request = nr_php_call(plugins, "getRequest"); - if (!nr_php_is_zval_valid_object(request)) { - nr_php_zval_free(&request); - return NULL; - } - - return request; -} - -/* - * Purpose : Wrap Zend_Controller_Plugin_Broker::preDispatch(request) to - * try and set the transaction name as soon as the final controller - * and action have been determined. This is to ensure we name the - * transaction even if an early exit occurs. - */ -NR_PHP_WRAPPER(nr_zend_plugin_broker_pre_dispatch) { - zval* this_var = NULL; - zval* request = NULL; - zval* dispatched = NULL; - - (void)wraprec; - NR_UNUSED_SPECIALFN; - - NR_PHP_WRAPPER_REQUIRE_FRAMEWORK(NR_FW_ZEND); - - this_var = nr_php_scope_get(NR_EXECUTE_ORIG_ARGS TSRMLS_CC); - if (0 == nr_php_is_zval_valid_object(this_var)) { - NR_PHP_WRAPPER_CALL; - goto end; - } - - NR_PHP_WRAPPER_CALL; - - request = nr_zend_plugin_broker_get_request(this_var TSRMLS_CC); - if (NULL == request) { - goto end; - } - - /* isDispatched() returns true when the final controller and action are found. - */ - dispatched = nr_php_call(request, "isDispatched"); - if (nr_php_is_zval_true(dispatched)) { - nr_zend_name_the_wt(request TSRMLS_CC); - } - - nr_php_zval_free(&dispatched); - nr_php_zval_free(&request); - -end: - nr_php_scope_release(&this_var); -} -NR_PHP_WRAPPER_END - -/* - * Purpose : Wrap Zend_Controller_Plugin_Broker::dispatchLoopShutdown() to - * ensure the transaction name reflects the final controller and - * action. - * - * Returns : Nothing. - */ -NR_PHP_WRAPPER(nr_zend_plugin_broker_dispatch_loop_shutdown) { - zval* this_var = NULL; - zval* request = NULL; - - (void)wraprec; - NR_UNUSED_SPECIALFN; - - NR_PHP_WRAPPER_REQUIRE_FRAMEWORK(NR_FW_ZEND); - - this_var = nr_php_scope_get(NR_EXECUTE_ORIG_ARGS TSRMLS_CC); - if (0 == nr_php_is_zval_valid_object(this_var)) { - goto end; - } - - request = nr_zend_plugin_broker_get_request(this_var TSRMLS_CC); - if (NULL != request) { - nr_zend_name_the_wt(request TSRMLS_CC); - nr_php_zval_free(&request); - } - -end: - NR_PHP_WRAPPER_CALL; - - nr_php_scope_release(&this_var); -} -NR_PHP_WRAPPER_END - -void nr_zend_enable(TSRMLS_D) { - nr_php_wrap_user_function( - NR_PSTR("Zend_Controller_Plugin_Broker::dispatchLoopShutdown"), - nr_zend_plugin_broker_dispatch_loop_shutdown TSRMLS_CC); - nr_php_wrap_user_function( - NR_PSTR("Zend_Controller_Plugin_Broker::preDispatch"), - nr_zend_plugin_broker_pre_dispatch TSRMLS_CC); -} diff --git a/agent/fw_zend2.c b/agent/fw_zend3.c similarity index 52% rename from agent/fw_zend2.c rename to agent/fw_zend3.c index b653bafe1..903008e46 100644 --- a/agent/fw_zend2.c +++ b/agent/fw_zend3.c @@ -14,37 +14,41 @@ #include "util_memory.h" /* - * How ZF2 Routing Works - * ===================== - * ZF2's has a Zend\Mvc\Router that decides which controller to call. + * Zend 3.x has a Zend\\Router + * that decides which controller to call. * - * Config is done in module.config.php (which exists per-module), which is a + * Config is done in `module/Application/config/module.config.php` + * (which exists per-module), which is a * PHP file returning an associative array containing something that looks like - * this example from the ZF2 Skeleton App: + * this example from the Zend Skeleton App tutorial + * https://docs.zendframework.com/tutorials/getting-started/routing-and-controllers/. + * + * 'router' => [ + * 'routes' => [ + * 'album' => [ + * 'type' => Segment::class, + * 'options' => [ + * 'route' => '/album[/:action[/:id]]', + * 'constraints' => [ + * 'action' => '[a-zA-Z][a-zA-Z0-9_-]*', + * 'id' => '[0-9]+', + * ], + * 'defaults' => [ + * 'controller' => Controller\AlbumController::class, + * 'action' => 'index', + * ], + * ], + * ], + * ], + * ], * - * 'router' => array( - * 'routes' => array( - * 'album' => array( - * 'type' => 'segment', - * 'options' => array( - * 'route' => '/album[/:action][/:id]', - * 'constraints' => array( - * 'action' => '[a-zA-Z][a-zA-Z0-9_-]*', - * 'id' => '[0-9]+', - * ), - * 'defaults' => array( - * 'controller' => 'Album\Controller\Album', - * 'action' => 'index', - * ), - * ), * ... * * Here, 'album' is the name of a route, and maps to some controller there is * an onRoute event that corresponds to making routing happen. We would * probably like to have some instrumentation of the type of actions that a * controller executes if the action is something like 'view' or 'list' or - * 'edit', but 'id' is likely to be sensitive, and mucking about in - * user-defined parameters is no fun anyways, so all we get is the route name. + * 'edit', but 'id' is likely to be sensitive, so all we get is the route name. * * One approach would be to instrument the onRoute event; we ended up going * with the setMatchedRouteName instead and just setting the path whenever that @@ -57,14 +61,22 @@ * presumably that was some optimization due to the return value not being used. */ -NR_PHP_WRAPPER(nr_zend2_name_the_wt) { +/* + * txn naming scheme: + * In this case, `nr_txn_set_path` is called after `NR_PHP_WRAPPER_CALL` with + * `NR_OK_TO_OVERWRITE` and as this corresponds to calling the wrapped function + * in func_end no change is needed to ensure OAPI compatibility as it will use + * the default func_end after callback. This entails that the first wrapped + * function call of this type gets to name the txn. + */ +NR_PHP_WRAPPER(nr_zend3_name_the_wt) { zval* path = NULL; zval* this_var = NULL; (void)wraprec; NR_UNUSED_SPECIALFN; - NR_PHP_WRAPPER_REQUIRE_FRAMEWORK(NR_FW_ZEND2); + NR_PHP_WRAPPER_REQUIRE_FRAMEWORK(NR_FW_ZEND3); this_var = nr_php_scope_get(NR_EXECUTE_ORIG_ARGS TSRMLS_CC); if (0 @@ -83,7 +95,7 @@ NR_PHP_WRAPPER(nr_zend2_name_the_wt) { if (nr_php_is_zval_valid_string(path)) { char* path_term = nr_strndup(Z_STRVAL_P(path), Z_STRLEN_P(path)); - nr_txn_set_path("Zend2", NRPRG(txn), path_term, NR_PATH_TYPE_ACTION, + nr_txn_set_path("Zend3", NRPRG(txn), path_term, NR_PATH_TYPE_ACTION, NR_OK_TO_OVERWRITE); nr_free(path_term); } else { @@ -99,36 +111,14 @@ NR_PHP_WRAPPER(nr_zend2_name_the_wt) { } NR_PHP_WRAPPER_END -void nr_fw_zend2_enable(TSRMLS_D) { - nr_txn_set_path("Zend2", NRPRG(txn), "unknown", NR_PATH_TYPE_ACTION, +void nr_fw_zend3_enable(TSRMLS_D) { + nr_txn_set_path("Zend3", NRPRG(txn), "unknown", NR_PATH_TYPE_ACTION, NR_OK_TO_OVERWRITE); - /* - * We instrument all three of these. The Console one is used for - * ZF2 Console requests - * (http://framework.zend.com/manual/2.3/en/modules/zend.console.routes.html). - * HTTP and Console both inherit from the third, so it's unlikely - * that that method will be called unless someone is using custom - * routing. - */ - nr_php_wrap_user_function( - NR_PSTR("Zend\\Mvc\\Router\\HTTP\\RouteMatch::setMatchedRouteName"), - nr_zend2_name_the_wt TSRMLS_CC); - nr_php_wrap_user_function( - NR_PSTR("Zend\\Mvc\\Router\\Console\\RouteMatch::setMatchedRouteName"), - nr_zend2_name_the_wt TSRMLS_CC); - nr_php_wrap_user_function( - NR_PSTR("Zend\\Mvc\\Router\\RouteMatch::setMatchedRouteName"), - nr_zend2_name_the_wt TSRMLS_CC); - - /* - * The functions above were moved to a new package and namespace in - * version 3.0. - */ nr_php_wrap_user_function( NR_PSTR("Zend\\Router\\HTTP\\RouteMatch::setMatchedRouteName"), - nr_zend2_name_the_wt TSRMLS_CC); + nr_zend3_name_the_wt TSRMLS_CC); nr_php_wrap_user_function( NR_PSTR("Zend\\Router\\RouteMatch::setMatchedRouteName"), - nr_zend2_name_the_wt TSRMLS_CC); + nr_zend3_name_the_wt TSRMLS_CC); } diff --git a/agent/lib_guzzle3.c b/agent/lib_guzzle3.c deleted file mode 100644 index 9bc9bc29e..000000000 --- a/agent/lib_guzzle3.c +++ /dev/null @@ -1,319 +0,0 @@ -/* - * Copyright 2020 New Relic Corporation. All rights reserved. - * SPDX-License-Identifier: Apache-2.0 - */ - -/* - * Guzzle is a general purpose library for making HTTP requests. It supports - * asynchronous, parallel requests using curl_multi_exec() while providing a - * modern OO API for users. - * - * It is a required component in Drupal 8, and strongly recommended by other - * frameworks, including Symfony 2. - * - * The general approach used is to watch for calls to - * Guzzle\Http\Message\Request::setState(): if the state is changing to - * STATE_TRANSFER or STATE_COMPLETE, then we know a request is about to be - * issued or has just completed, respectively. - * - * Source : https://github.com/guzzle/guzzle - * Docs : https://guzzle.readthedocs.org/en/latest/ - */ - -#include "php_agent.h" -#include "php_call.h" -#include "php_user_instrument.h" -#include "php_execute.h" -#include "php_hash.h" -#include "php_wrapper.h" -#include "fw_hooks.h" -#include "fw_support.h" -#include "lib_guzzle_common.h" -#include "nr_header.h" -#include "nr_segment_external.h" -#include "util_logging.h" -#include "util_memory.h" -#include "util_strings.h" - -static int nr_guzzle3_in_redirect_iterator(zval* frame, - int* in_guzzle_ptr, - zend_hash_key* key NRUNUSED - TSRMLS_DC) { - int idx; - const zval* klass; - - NR_UNUSED_TSRMLS; - - if (0 == nr_php_is_zval_valid_array(frame)) { - return ZEND_HASH_APPLY_KEEP; - } - if (NULL == in_guzzle_ptr) { - return ZEND_HASH_APPLY_KEEP; - } - - klass = nr_php_zend_hash_find(Z_ARRVAL_P(frame), "class"); - - if (0 == nr_php_is_zval_non_empty_string(klass)) { - return ZEND_HASH_APPLY_KEEP; - } - - /* - * NOTE: RedirectPlugin was added in Guzzle version v3.0.3 - * and therefore this approach will only work on that version or later. - */ - idx = nr_strncaseidx(Z_STRVAL_P(klass), "RedirectPlugin", Z_STRLEN_P(klass)); - if (idx >= 0) { - *in_guzzle_ptr = 1; - } - - return ZEND_HASH_APPLY_KEEP; -} - -static int nr_guzzle3_in_redirect(TSRMLS_D) { - int in_redirect = 0; - zval* stack = nr_php_backtrace(TSRMLS_C); - - if (nr_php_is_zval_valid_array(stack)) { - nr_php_zend_hash_zval_apply( - Z_ARRVAL_P(stack), (nr_php_zval_apply_t)nr_guzzle3_in_redirect_iterator, - &in_redirect TSRMLS_CC); - } - - nr_php_zval_free(&stack); - - return in_redirect; -} - -/* - * Purpose : Checks if the given state matches the expected state. - * - * Params : 1. The expected state constant, as a string. - * 2. The actual state zval. - * 3. The request object from which we want to retrieve the expected - * constant value. - * - * Returns : Non-zero if the state matches, zero if it doesn't. - */ -static int nr_guzzle3_is_state(const char* expected, - zval* state, - zval* request TSRMLS_DC) { - zval* expected_const = NULL; - int is_complete = 0; - zval result; - - if ((NULL == state) || (0 == nr_php_is_zval_valid_object(request))) { - return 0; - } - - /* Get the value of the expected state constant. */ - expected_const = nr_php_get_class_constant(Z_OBJCE_P(request), expected); - if (NULL == expected_const) { - nrl_verbosedebug(NRL_INSTRUMENT, - "Guzzle 3: Request class does not have a %s constant", - expected); - return 0; - } - - /* See if the constant and the state are identical. */ - nr_php_zval_bool(&result, 0); - if (SUCCESS - == is_identical_function(&result, expected_const, state TSRMLS_CC)) { - is_complete = nr_php_is_zval_true(&result); - } else { - nrl_verbosedebug(NRL_INSTRUMENT, - "Guzzle 3: is_identical_function failed when checking the " - "request state"); - } - - nr_php_zval_free(&expected_const); - return is_complete; -} - -/* - * Purpose : Returns an item from the cURL transfer information stored within a - * Guzzle Response object. - * - * Params : 1. The key of the item to return. - * 2. The response object. - * - * Returns : The zval returned by Response::getInfo(). This needs to be - * destroyed with nr_php_zval_free() when no longer needed. - */ -static zval* nr_guzzle3_response_get_info(const char* key, - zval* response TSRMLS_DC) { - zval* param = nr_php_zval_alloc(); - zval* retval = NULL; - - nr_php_zval_str(param, key); - - retval = nr_php_call(response, "getInfo", param); - if (NULL == retval) { - nrl_verbosedebug(NRL_INSTRUMENT, - "Guzzle 3: error calling Response::getInfo('" NRP_FMT "')", - NRP_ARGUMENTS(key)); - } - - nr_php_zval_free(¶m); - return retval; -} - -/* - * Purpose : Handles a request transitioning into the STATE_TRANSFER state. - * - * Params : 1. The request object. - */ -static void nr_guzzle3_request_state_transfer(zval* request TSRMLS_DC) { - nr_segment_t* segment; - - /* - * Add the request object to those we're tracking. - */ - segment = nr_guzzle_obj_add(request, "Guzzle 3" TSRMLS_CC); - - /* - * Set the request headers. - */ - nr_guzzle_request_set_outbound_headers(request, segment TSRMLS_CC); -} - -/* - * Purpose : Handles a request transitioning into the STATE_COMPLETE state. - * - * Params : 1. The request object. - */ -static void nr_guzzle3_request_state_complete(zval* request TSRMLS_DC) { - nrtime_t duration; - nr_segment_t* segment; - nr_segment_external_params_t external_params = {.library = "Guzzle 3"}; - zval* response = NULL; - zval* time = NULL; - zval* status = NULL; - zval* url = NULL; - - if (NR_FAILURE - == nr_guzzle_obj_find_and_remove(request, &segment TSRMLS_CC)) { - nrl_verbosedebug(NRL_INSTRUMENT, - "Guzzle 3: Request object entered STATE_COMPLETE without " - "being tracked"); - return; - } - - /* - * We can get the total request time by calling getInfo('total_time') on the - * response object. - */ - response = nr_php_call(request, "getResponse"); - if (0 - == nr_php_object_instanceof_class( - response, "Guzzle\\Http\\Message\\Response" TSRMLS_CC)) { - nrl_verbosedebug( - NRL_INSTRUMENT, - "Guzzle 3: Request::getResponse() didn't return a Response object"); - goto leave; - } - - /* - * Next, we want to get the request duration so we can set the stop time. - */ - time = nr_guzzle3_response_get_info("total_time", response TSRMLS_CC); - if ((NULL == time) || (IS_DOUBLE != Z_TYPE_P(time))) { - nrl_verbosedebug(NRL_INSTRUMENT, "Guzzle 3: total_time is not a double"); - goto leave; - } - duration = (nrtime_t)(Z_DVAL_P(time) * NR_TIME_DIVISOR); - - status = nr_php_call(response, "getStatusCode"); - - if (nr_php_is_zval_valid_integer(status)) { - external_params.status = Z_LVAL_P(status); - } - - /* - * We also need the URL to create a useful metric. - */ - url = nr_php_call(request, "getUrl"); - if (!nr_php_is_zval_valid_string(url)) { - goto leave; - } - external_params.uri = nr_strndup(Z_STRVAL_P(url), Z_STRLEN_P(url)); - - /* - * Grab the X-NewRelic-App-Data response header, if there is one. We don't - * check for a valid string below as it's not an error if the header doesn't - * exist (and hence NULL is returned). - */ - external_params.encoded_response_header - = nr_guzzle_response_get_header(X_NEWRELIC_APP_DATA, response TSRMLS_CC); - - if (NRPRG(txn) && NRTXN(special_flags.debug_cat)) { - nrl_verbosedebug( - NRL_CAT, "CAT: outbound response: transport='Guzzle 3' %s=" NRP_FMT, - X_NEWRELIC_APP_DATA, NRP_CAT(external_params.encoded_response_header)); - } - - nr_segment_set_timing(segment, segment->start_time, duration); - nr_segment_external_end(&segment, &external_params); - -leave: - nr_free(external_params.encoded_response_header); - nr_free(external_params.uri); - nr_php_zval_free(&response); - nr_php_zval_free(&time); - nr_php_zval_free(&url); - nr_php_zval_free(&status); -} - -NR_PHP_WRAPPER(nr_guzzle3_request_setstate) { - zval* state = NULL; - zval* this_var = NULL; - - (void)wraprec; - - this_var = nr_php_scope_get(NR_EXECUTE_ORIG_ARGS TSRMLS_CC); - if (0 == nr_php_is_zval_valid_object(this_var)) { - NR_PHP_WRAPPER_CALL; - goto end; - } - - if (nr_guzzle3_in_redirect(TSRMLS_C)) { - NR_PHP_WRAPPER_CALL; - goto end; - } - - /* - * There are two state transitions we're interested in: - * - * 1. STATE_TRANSFER: This indicates that the request is about to be sent. We - * want to get the current time so we can create an - * external metric later and inject our CAT headers. - * 2. STATE_COMPLETE: This indicates that the request is complete and that - * the response has been received in full. At this point, - * we're going to create the external metric. - */ - state = nr_php_arg_get(1, NR_EXECUTE_ORIG_ARGS TSRMLS_CC); - - NR_PHP_WRAPPER_CALL; - - if (nr_guzzle3_is_state("STATE_TRANSFER", state, this_var TSRMLS_CC)) { - nr_guzzle3_request_state_transfer(this_var TSRMLS_CC); - } else if (nr_guzzle3_is_state("STATE_COMPLETE", state, this_var TSRMLS_CC)) { - nr_guzzle3_request_state_complete(this_var TSRMLS_CC); - } - -end: - nr_php_arg_release(&state); - nr_php_scope_release(&this_var); -} -NR_PHP_WRAPPER_END - -void nr_guzzle3_enable(TSRMLS_D) { - if (0 == NRINI(guzzle_enabled)) { - return; - } - /* - * Instrument Request::setState() so we can detect when the request is - * completed and then generate the appropriate external metric. - */ - nr_php_wrap_user_function(NR_PSTR("Guzzle\\Http\\Message\\Request::setState"), - nr_guzzle3_request_setstate TSRMLS_CC); -} diff --git a/agent/lib_guzzle4.c b/agent/lib_guzzle4.c index c52ddffff..5ae0c8aaa 100644 --- a/agent/lib_guzzle4.c +++ b/agent/lib_guzzle4.c @@ -41,7 +41,6 @@ * we just won't build the Guzzle 4 support on older versions and will instead * provide simple stubs for the two exported functions to avoid linking errors. */ -#if ZEND_MODULE_API_NO >= ZEND_5_4_X_API_NO /* {{{ Convenience functions for Guzzle interface checks */ @@ -572,31 +571,3 @@ void nr_guzzle4_rshutdown(TSRMLS_D) { nr_php_remove_interface_from_class(nr_guzzle4_subscriber_ce, iface_ce TSRMLS_CC); } - -#else /* PHP >= 5.4.0 */ - -/* - * Stub implementations of the exported functions from this module for - * PHP < 5.4. - */ - -NR_PHP_WRAPPER_START(nr_guzzle4_client_construct) { - (void)wraprec; - NR_UNUSED_SPECIALFN; - NR_UNUSED_TSRMLS; -} -NR_PHP_WRAPPER_END - -void nr_guzzle4_enable(TSRMLS_D) { - NR_UNUSED_TSRMLS -} - -void nr_guzzle4_minit(TSRMLS_D) { - NR_UNUSED_TSRMLS -} - -void nr_guzzle4_rshutdown(TSRMLS_D) { - NR_UNUSED_TSRMLS -} - -#endif /* PHP >= 5.4.0 */ diff --git a/agent/lib_guzzle6.c b/agent/lib_guzzle6.c index e65a684b7..59592b1cf 100644 --- a/agent/lib_guzzle6.c +++ b/agent/lib_guzzle6.c @@ -65,7 +65,6 @@ * support on older versions and will instead provide simple stubs for the two * exported functions to avoid linking errors. */ -#if ZEND_MODULE_API_NO >= ZEND_5_5_X_API_NO /* {{{ newrelic\Guzzle6\RequestHandler class definition and methods */ @@ -525,22 +524,3 @@ void nr_guzzle6_minit(TSRMLS_D) { zend_declare_property_null(nr_guzzle6_requesthandler_ce, NR_PSTR("request"), ZEND_ACC_PRIVATE TSRMLS_CC); } - -#else /* PHP < 5.5 */ - -NR_PHP_WRAPPER_START(nr_guzzle6_client_construct) { - (void)wraprec; - NR_UNUSED_SPECIALFN; - NR_UNUSED_TSRMLS; -} -NR_PHP_WRAPPER_END - -void nr_guzzle6_enable(TSRMLS_D) { - NR_UNUSED_TSRMLS -} - -void nr_guzzle6_minit(TSRMLS_D) { - NR_UNUSED_TSRMLS; -} - -#endif /* 5.5.x */ diff --git a/agent/lib_guzzle_common.c b/agent/lib_guzzle_common.c index 7121702cc..966748b8b 100644 --- a/agent/lib_guzzle_common.c +++ b/agent/lib_guzzle_common.c @@ -231,33 +231,6 @@ char* nr_guzzle_response_get_header(const char* header, if (Z_STRLEN_P(retval) > 0) { value = nr_strndup(Z_STRVAL_P(retval), Z_STRLEN_P(retval)); } - } else if (nr_php_object_instanceof_class( - retval, "Guzzle\\Http\\Message\\Header" TSRMLS_CC)) { - /* - * Guzzle 3 returns an object that we can cast to a string, so let's do - * that. We'll call __toString() directly rather than going through PHP's - * convert_to_string() function, as that will generate a notice if the - * cast fails for some reason. - */ - zval* zv_str = nr_php_call(retval, "__toString"); - - if (nr_php_is_zval_non_empty_string(zv_str)) { - value = nr_strndup(Z_STRVAL_P(zv_str), Z_STRLEN_P(zv_str)); - } else if (NULL != zv_str) { - nrl_verbosedebug( - NRL_INSTRUMENT, - "Guzzle: Header::__toString() returned a non-string of type %d", - Z_TYPE_P(zv_str)); - } else { - /* - * We should never get NULL as the retval from nr_php_call, but handle it - * just in case... - */ - nrl_verbosedebug(NRL_INSTRUMENT, - "Guzzle: Header::__toString() returned a NULL retval"); - } - - nr_php_zval_free(&zv_str); } else { nrl_verbosedebug( NRL_INSTRUMENT, diff --git a/agent/lib_guzzle_common.h b/agent/lib_guzzle_common.h index 2431945fe..5cb6329ba 100644 --- a/agent/lib_guzzle_common.h +++ b/agent/lib_guzzle_common.h @@ -4,7 +4,7 @@ * * This file contains functions common to all supported Guzzle versions. * - * We support Guzzle 3 (LIB_GUZZLE3) and Guzzle 4 (LIB_GUZZLE4) within the + * We support Guzzle 4 (LIB_GUZZLE4) within the * agent. Some aspects of these frameworks are the same (mostly object * tracking), while the implementation details differ significantly. */ diff --git a/agent/lib_zend_http.c b/agent/lib_zend_http.c index 136244c1a..8d2efc32c 100644 --- a/agent/lib_zend_http.c +++ b/agent/lib_zend_http.c @@ -441,15 +441,13 @@ NR_PHP_WRAPPER_START(nr_zend_http_client_request) { NR_PHP_WRAPPER_END void nr_zend_http_enable(TSRMLS_D) { - if ((NR_FW_ZEND != NRPRG(current_framework)) - && (NR_FW_LAMINAS3 != NRPRG(current_framework))) { + if (NR_FW_LAMINAS3 != NRPRG(current_framework)) { nr_php_wrap_user_function(NR_PSTR(HTTP_CLIENT_REQUEST_Z), nr_zend_http_client_request TSRMLS_CC); } } void nr_laminas_http_enable(TSRMLS_D) { - if ((NR_FW_ZEND != NRPRG(current_framework))) { /* * Redefine zend to laminas. */ @@ -461,5 +459,4 @@ void nr_laminas_http_enable(TSRMLS_D) { nr_php_wrap_user_function(NR_PSTR(HTTP_CLIENT_REQUEST_L), nr_zend_http_client_request TSRMLS_CC); - } } diff --git a/agent/php_agent.c b/agent/php_agent.c index 50d942b62..97b029fd0 100644 --- a/agent/php_agent.c +++ b/agent/php_agent.c @@ -20,7 +20,6 @@ static zval* nr_php_get_zval_object_property_with_class_internal( zval* object, zend_class_entry* ce, const char* cname TSRMLS_DC) { -#if ZEND_MODULE_API_NO >= ZEND_7_0_X_API_NO /* PHP 7.0+ */ /* * Although the below notes still apply in principle, PHP 7 additionally broke * the API for zend_read_property by adding an rv parameter, which is used to @@ -41,25 +40,6 @@ static zval* nr_php_get_zval_object_property_with_class_internal( if (&EG(uninitialized_zval) != data) { return data; } -#else - /* - * This attempts to read uninitialized (or non existing) properties always - * return uninitialized_zval_ptr, even in the case where we read a property - * during pre-hook time on a constructor. - */ - zend_bool silent = 1; /* forces BP_VAR_IS semantics */ -#if ZEND_MODULE_API_NO >= ZEND_5_4_X_API_NO - zval* data = zend_read_property(ce, object, cname, nr_strlen(cname), - silent TSRMLS_CC); -#else - zval* data = zend_read_property(ce, object, (char*)nr_remove_const(cname), - nr_strlen(cname), silent TSRMLS_CC); -#endif /* PHP >= 5.4 */ - - if (EG(uninitialized_zval_ptr) != data) { - return data; - } -#endif /* PHP7+ */ return NULL; } @@ -149,32 +129,12 @@ int nr_php_object_has_method(zval* object, const char* lcname TSRMLS_DC) { return 0; } else { void* func; - -#if ZEND_MODULE_API_NO >= ZEND_7_0_X_API_NO /* PHP 7.0+ */ zend_string* name_str = zend_string_init(vname, namelen, 0); func = (void*)Z_OBJ_HT_P(object)->get_method(&Z_OBJ_P(object), name_str, NULL TSRMLS_CC); zend_string_release(name_str); -#elif ZEND_MODULE_API_NO >= ZEND_5_4_X_API_NO - /* - * This can leak if the object has a __call() method, as in that situation - * only, zend_std_get_method() will indirectly allocate a new - * zend_function in zend_get_user_call_function(). - * - * We can't easily detect this, and the zend_function() is allocated via - * emalloc(), so we're just going to let this slide and let the Zend - * Engine clean it up at RSHUTDOWN. Note that this needs to be suppressed - * in Valgrind, though. - */ - func = (void*)Z_OBJ_HT_P(object)->get_method( - &object, vname, namelen, - NULL TSRMLS_CC); /* nr_php_object_has_method */ -#else /* PHP < 5.4 */ - func = (void*)Z_OBJ_HT_P(object)->get_method( - &object, vname, namelen TSRMLS_CC); /* nr_php_object_has_method */ -#endif if (NULL == func) { return 0; @@ -214,23 +174,11 @@ zend_function* nr_php_find_function(const char* name TSRMLS_DC) { * whereas PHP 7 only uses a single level of indirection. */ zend_class_entry* nr_php_find_class(const char* name TSRMLS_DC) { -#if ZEND_MODULE_API_NO >= ZEND_7_0_X_API_NO /* PHP 7.0+ */ if (NULL == name) { return NULL; } return (zend_class_entry*)nr_php_zend_hash_find_ptr(EG(class_table), name); -#else - zend_class_entry** ce_ptr = 0; - - if (0 == name) { - return 0; - } - - ce_ptr = (zend_class_entry**)nr_php_zend_hash_find_ptr(EG(class_table), name); - - return ce_ptr ? *ce_ptr : NULL; -#endif /* PHP7+ */ } zend_function* nr_php_find_class_method(const zend_class_entry* klass, @@ -286,15 +234,9 @@ zend_function* nr_php_zval_to_function(zval* zv TSRMLS_DC) { return NULL; } -#if ZEND_MODULE_API_NO >= ZEND_7_0_X_API_NO /* PHP 7.0+ */ if (zend_is_callable_ex(zv, NULL, 0, NULL, &fcc, NULL)) { return fcc.function_handler; } -#else - if (zend_is_callable_ex(zv, NULL, 0, NULL, NULL, &fcc, NULL TSRMLS_CC)) { - return fcc.function_handler; - } -#endif /* PHP7+ */ return NULL; } @@ -316,137 +258,17 @@ zend_execute_data* nr_get_zend_execute_data(NR_EXECUTE_PROTO TSRMLS_DC) { = EG(current_execute_data); /* via zend engine global data structure */ NR_UNUSED_SPECIALFN; NR_UNUSED_FUNC_RETURN_VALUE; -#if ZEND_MODULE_API_NO >= ZEND_5_5_X_API_NO - { - /* - * ptra is argument passed in to us, it might be NULL if the caller doesn't - * have that info. - */ - zend_execute_data* ptra = execute_data; - if (NULL != ptra) { - return ptra; - } else { - return ptrg; - } - } -#else /* PHP < 5.5 */ - return ptrg; -#endif -} - -/* - * Purpose : Return a pointer to the arguments for the true frame that is - * legitimate_frame_delta frames down from the top. - * - * Params : 1. The number of true frames to walk down. 0 means "top of stack". - * The PHP5.5 half-formed stack top frame (with a null arguments - * block) is ignored. - * - * 2. The execution context supplied by the zend engine; this changes - * from PHP5.4 to PHP5.5, hence the use of macros. - * - * See this web page discussion migrating from 5.4 to 5.5 (July 22, 2013) - * http://www.php.net/manual/en/migration55.internals.php - * - * If the arguments pointer is null, it represents either a half-formed frame - * (or the base of the call stack). Go up one frame, and use the arguments - * vector from there. The two functions appear to be identical. - * - * For PHP 5.4 (and presumably earlier), this additional stack frame isn't - * there. - * - * See the picture near line 1525 of PHP 5.5.3 zend_execute.c - */ -#if ZEND_MODULE_API_NO >= ZEND_5_5_X_API_NO && !defined(PHP7) \ - && !defined(PHP8) /* PHP 5.5 and 5.6 */ -static void** nr_php_get_php55_stack_arguments(int legitimate_frame_delta, - NR_EXECUTE_PROTO TSRMLS_DC) { - zend_execute_data* ex; - void** arguments; - int i; - - ex = nr_get_zend_execute_data(NR_EXECUTE_ORIG_ARGS TSRMLS_CC); - - arguments = ex->function_state.arguments; - if (NULL == arguments) { - ex = ex->prev_execute_data; /* discard top partially formed frame */ - } - - if (NULL == ex) { - return NULL; - } - - arguments = ex->function_state.arguments; - if (NULL == arguments) { - return NULL; /* PHP stack appears to be be malformed */ - } - - for (i = 0; i < legitimate_frame_delta; i++) { - ex = ex->prev_execute_data; - if (NULL == ex) { - return NULL; /* No caller; we're at the bottom of the stack */ - } - arguments = ex->function_state.arguments; - if (NULL == arguments) { - return NULL; /* PHP stack appears to be be malformed */ - } - } - - return arguments; -} -#endif - -#if !defined(PHP7) && !defined(PHP8) /* PHP 5.5 and 5.6 */ -/* - * Use detailed zend specific knowledge of the interpreter stack - * to read the argument vector. - * Here, the 'h' suffix means "hackery". - */ -static zval* nr_php_get_user_func_arg_via_h(int requested_arg_index, - int* arg_count_p, - NR_EXECUTE_PROTO TSRMLS_DC) { - void** p = 0; - zval** argp = 0; - zval* arg = 0; - - NR_UNUSED_SPECIALFN; - - if (NULL == arg_count_p) { - return NULL; - } - *arg_count_p = -1; - if (NULL == nr_get_zend_execute_data(NR_EXECUTE_ORIG_ARGS TSRMLS_CC)) { - return NULL; - } - -#if ZEND_MODULE_API_NO >= ZEND_5_5_X_API_NO - p = nr_php_get_php55_stack_arguments(0, NR_EXECUTE_ORIG_ARGS TSRMLS_CC); - if (NULL == p) { - return NULL; - } - *arg_count_p = (int)(zend_uintptr_t)*p; -#else - p = nr_get_zend_execute_data(NR_EXECUTE_ORIG_ARGS TSRMLS_CC) - ->function_state.arguments; - if (NULL == p) { - return NULL; - } - *arg_count_p = (int)(zend_uintptr_t)*p; -#endif /* PHP >= 5.5 */ - - if (requested_arg_index > *arg_count_p) { - return NULL; - } - - argp = ((zval**)p) - *arg_count_p + requested_arg_index - 1; - if (NULL == argp) { - return NULL; + /* + * ptra is argument passed in to us, it might be NULL if the caller doesn't + * have that info. + */ + zend_execute_data* ptra = execute_data; + if (NULL != ptra) { + return ptra; + } else { + return ptrg; } - - arg = *argp; - return arg; } -#endif /* !PHP7 && !PHP8*/ /* * NOTICE: requested_arg_index is a 1-based value, not a 0-based value! @@ -462,7 +284,6 @@ zval* nr_php_get_user_func_arg(size_t requested_arg_index, return NULL; } -#if ZEND_MODULE_API_NO >= ZEND_7_0_X_API_NO /* PHP 7.0+ */ (void)arg_count_via_h; if (requested_arg_index > ZEND_CALL_NUM_ARGS(execute_data)) { @@ -470,33 +291,13 @@ zval* nr_php_get_user_func_arg(size_t requested_arg_index, } arg_via_h = ZEND_CALL_ARG(execute_data, requested_arg_index); -#else - arg_via_h = nr_php_get_user_func_arg_via_h( - requested_arg_index, &arg_count_via_h, NR_EXECUTE_ORIG_ARGS TSRMLS_CC); -#endif /* PHP7+ */ return arg_via_h; } size_t nr_php_get_user_func_arg_count(NR_EXECUTE_PROTO TSRMLS_DC) { -#if ZEND_MODULE_API_NO >= ZEND_7_0_X_API_NO /* PHP 7.0+ */ NR_UNUSED_FUNC_RETURN_VALUE; return (size_t)ZEND_CALL_NUM_ARGS(execute_data); -#else - int arg_count_via_h = -1; - - if (NULL - == nr_php_get_user_func_arg_via_h(1, &arg_count_via_h, - NR_EXECUTE_ORIG_ARGS TSRMLS_CC)) { - return 0; - } else if (arg_count_via_h < 0) { - nrl_verbosedebug(NRL_AGENT, "%s: unexpected argument count %d", __func__, - arg_count_via_h); - return 0; - } - - return (size_t)arg_count_via_h; -#endif /* PHP7+ */ } zend_execute_data* nr_php_get_caller_execute_data(NR_EXECUTE_PROTO, @@ -507,15 +308,11 @@ zend_execute_data* nr_php_get_caller_execute_data(NR_EXECUTE_PROTO, NR_UNUSED_SPECIALFN; NR_UNUSED_TSRMLS; -#if ZEND_MODULE_API_NO >= ZEND_5_5_X_API_NO ced = execute_data; if (NULL == ced) { ced = nr_get_zend_execute_data(NR_EXECUTE_ORIG_ARGS TSRMLS_CC); } -#else /* PHP < 5.5 */ - ced = nr_get_zend_execute_data(NR_EXECUTE_ORIG_ARGS TSRMLS_CC); -#endif for (i = 0; i < offset; i++) { if (NULL == ced) { @@ -525,30 +322,18 @@ zend_execute_data* nr_php_get_caller_execute_data(NR_EXECUTE_PROTO, ced = ced->prev_execute_data; } -#if ZEND_MODULE_API_NO >= ZEND_7_0_X_API_NO /* PHP 7.0+ */ if ((NULL == ced) || (NULL == ced->opline)) { return NULL; } -#else - if ((NULL == ced) || (NULL == ced->op_array)) { - return NULL; - } -#endif /* PHP7+ */ if ((ZEND_DO_FCALL != ced->opline->opcode) && (ZEND_DO_FCALL_BY_NAME != ced->opline->opcode)) { return NULL; } -#if ZEND_MODULE_API_NO >= ZEND_7_0_X_API_NO /* PHP 7.0+ */ if (NULL == ced->func) { return NULL; } -#else - if (0 == ced->function_state.function) { - return NULL; - } -#endif /* PHP7+ */ return ced; } @@ -562,17 +347,12 @@ const zend_function* nr_php_get_caller(NR_EXECUTE_PROTO, return NULL; } -#if ZEND_MODULE_API_NO >= ZEND_7_0_X_API_NO /* PHP 7.0+ */ return ped->func; -#else - return ped->function_state.function; -#endif /* PHP7+ */ } zval* nr_php_get_active_php_variable(const char* name TSRMLS_DC) { HashTable* table; -#if ZEND_MODULE_API_NO >= ZEND_7_0_X_API_NO /* PHP 7.0+ */ table = zend_rebuild_symbol_table(); /* @@ -586,10 +366,6 @@ zval* nr_php_get_active_php_variable(const char* name TSRMLS_DC) { * https://nikic.github.io/2015/06/19/Internal-value-representation-in-PHP-7-part-2.html#indirect-zvals */ return nr_php_zval_direct(nr_php_zend_hash_find(table, name)); -#else - table = EG(active_symbol_table); - return nr_php_zend_hash_find(table, name); -#endif /* PHP7+ */ } int nr_php_silence_errors(TSRMLS_D) { @@ -605,7 +381,6 @@ void nr_php_restore_errors(int error_reporting TSRMLS_DC) { } zval* nr_php_get_constant(const char* name TSRMLS_DC) { -#if ZEND_MODULE_API_NO >= ZEND_7_0_X_API_NO /* PHP 7.0+ */ zval* constant; zval* copy = NULL; zend_string* name_str; @@ -629,31 +404,9 @@ zval* nr_php_get_constant(const char* name TSRMLS_DC) { ZVAL_DUP(copy, constant); return copy; -#else - nr_string_len_t len; - int rv; - zval* constant = NULL; - - if (NULL == name) { - return NULL; - } - - len = nr_strlen(name); - constant = nr_php_zval_alloc(); - - /* zend_get_constant returns 0 and 1 (not SUCCESS or FAILURE) */ - rv = zend_get_constant(name, len, constant TSRMLS_CC); - if (0 == rv) { - nr_php_zval_free(&constant); - return NULL; - } - - return constant; -#endif /* PHP7+ */ } zval* nr_php_get_class_constant(const zend_class_entry* ce, const char* name) { -#if ZEND_MODULE_API_NO >= ZEND_7_1_X_API_NO zend_class_constant* constant = NULL; zval* copy = NULL; @@ -669,29 +422,6 @@ zval* nr_php_get_class_constant(const zend_class_entry* ce, const char* name) { } return copy; -#else - zval* constant = NULL; - zval* copy = NULL; - - if (NULL == ce) { - return NULL; - } - - constant = nr_php_zend_hash_find(&(ce->constants_table), name); - - if (constant) { - copy = nr_php_zval_alloc(); - - /* - * PHP 7.0 usually returns an IS_REF. We need to unwrap to ensure that we - * duplicate the concrete value, otherwise the caller will end up freeing a - * value that it doesn't own, and bad things will happen. - */ - ZVAL_DUP(copy, nr_php_zval_real_value(constant)); - } - - return copy; -#endif } char* nr_php_get_object_constant(zval* app, const char* name) { @@ -763,7 +493,6 @@ int nr_php_is_zval_named_constant(const zval* zv, const char* name TSRMLS_DC) { } int nr_php_zend_is_auto_global(const char* name, size_t name_len TSRMLS_DC) { -#if ZEND_MODULE_API_NO >= ZEND_7_0_X_API_NO /* PHP 7.0+ */ zend_bool rv; zend_string* zs = zend_string_init(name, name_len, 0); @@ -771,9 +500,6 @@ int nr_php_zend_is_auto_global(const char* name, size_t name_len TSRMLS_DC) { zend_string_free(zs); return rv; -#else - return (int)zend_is_auto_global(name, (int)name_len TSRMLS_CC); -#endif /* PHP7+ */ } const char* nr_php_use_license(const char* api_license TSRMLS_DC) { @@ -801,11 +527,7 @@ char* nr_php_get_server_global(const char* name TSRMLS_DC) { return NULL; } -#if ZEND_MODULE_API_NO >= ZEND_7_0_X_API_NO /* PHP 7.0+ */ global = &(PG(http_globals)[TRACK_VARS_SERVER]); -#else - global = PG(http_globals)[TRACK_VARS_SERVER]; -#endif if (!nr_php_is_zval_valid_array(global)) { return NULL; @@ -1128,11 +850,7 @@ char* nr_php_function_debug_name(const zend_function* func) { if ((ZEND_USER_FUNCTION == func->type) && (func->common.fn_flags & ZEND_ACC_CLOSURE)) { -#if ZEND_MODULE_API_NO >= ZEND_7_0_X_API_NO /* PHP 7.0+ */ const char* filename = ZSTR_VAL(func->op_array.filename); -#else - const char* filename = func->op_array.filename; -#endif /* PHP7+ */ char* orig_name = name; name = nr_formatf("%s declared at %s:%d", orig_name, NRSAFESTR(filename), diff --git a/agent/php_agent.h b/agent/php_agent.h index fbdc34620..ac2eb9aa3 100644 --- a/agent/php_agent.h +++ b/agent/php_agent.h @@ -363,7 +363,7 @@ static inline zval* nr_php_get_return_value(NR_EXECUTE_PROTO TSRMLS_DC) { return NULL; } return func_return_value; -#elif ZEND_MODULE_API_NO >= ZEND_7_0_X_API_NO /* PHP 7.0+ */ +#else NR_UNUSED_FUNC_RETURN_VALUE; if (NULL == execute_data) { /* @@ -374,12 +374,6 @@ static inline zval* nr_php_get_return_value(NR_EXECUTE_PROTO TSRMLS_DC) { } return execute_data->return_value; -#else - zval** return_value_ptr_ptr = EG(return_value_ptr_ptr); - - NR_UNUSED_SPECIALFN; - - return return_value_ptr_ptr ? *return_value_ptr_ptr : NULL; #endif /* PHP7+ */ } @@ -414,24 +408,11 @@ static inline zend_function* nr_php_execute_function( NR_UNUSED_TSRMLS; NR_UNUSED_FUNC_RETURN_VALUE; -#if ZEND_MODULE_API_NO >= ZEND_5_5_X_API_NO if (NULL == execute_data) { return NULL; } -#else - if (NULL == op_array_arg) { - return NULL; - } -#endif -#if ZEND_MODULE_API_NO >= ZEND_7_0_X_API_NO /* PHP 7.0+ */ return execute_data->func; -#elif ZEND_MODULE_API_NO >= ZEND_5_5_X_API_NO - return execute_data->function_state.function; -#else - return op_array_arg->prototype ? op_array_arg->prototype - : (zend_function*)op_array_arg; -#endif /* PHP7+ */ } static inline zval* nr_php_execute_scope(zend_execute_data* execute_data) { @@ -454,11 +435,8 @@ static inline zval* nr_php_execute_scope(zend_execute_data* execute_data) { } return NULL; -#elif ZEND_MODULE_API_NO >= ZEND_7_0_X_API_NO \ - && ZEND_MODULE_API_NO < ZEND_8_0_X_API_NO /* PHP 7.0 - 7.4 */ - return &execute_data->This; #else - return execute_data->object; + return &execute_data->This; #endif } @@ -662,74 +640,42 @@ extern const char* nr_php_function_filename(zend_function* func); static inline zend_class_entry* nr_php_zend_register_internal_class_ex( zend_class_entry* ce, zend_class_entry* parent_ce TSRMLS_DC) { -#if ZEND_MODULE_API_NO >= ZEND_7_0_X_API_NO /* PHP 7.0+ */ return zend_register_internal_class_ex(ce, parent_ce); -#else - return zend_register_internal_class_ex(ce, parent_ce, NULL TSRMLS_CC); -#endif /* PHP7+ */ } static inline char* nr_php_zend_ini_string(char* name, nr_string_len_t name_len, int orig) { -#if ZEND_MODULE_API_NO >= ZEND_7_0_X_API_NO /* PHP 7.0+ */ return zend_ini_string(name, name_len, orig); -#else - return zend_ini_string(name, name_len + 1, orig); -#endif /* PHP7+ */ } static inline const char* NRPURE nr_php_class_entry_name(const zend_class_entry* ce) { -#if ZEND_MODULE_API_NO >= ZEND_7_0_X_API_NO /* PHP 7.0+ */ return (ce->name && ce->name->len) ? ce->name->val : NULL; -#else - return ce->name; -#endif } static inline nr_string_len_t NRPURE nr_php_class_entry_name_length(const zend_class_entry* ce) { -#if ZEND_MODULE_API_NO >= ZEND_7_0_X_API_NO /* PHP 7.0+ */ return ce->name ? ce->name->len : 0; -#else - return NRSAFELEN(ce->name_length); -#endif } static inline const char* NRPURE nr_php_function_name(const zend_function* func) { -#if ZEND_MODULE_API_NO >= ZEND_7_0_X_API_NO /* PHP 7.0+ */ return (func->common.function_name && func->common.function_name->len) ? func->common.function_name->val : NULL; -#else - return func->common.function_name; -#endif } static inline nr_string_len_t NRPURE nr_php_function_name_length(const zend_function* func) { -#if ZEND_MODULE_API_NO >= ZEND_7_0_X_API_NO /* PHP 7.0+ */ return func->common.function_name ? func->common.function_name->len : 0; -#else - /* - * No NRSAFELEN macro here as nr_strlen can't return a negative value anyway - * (it simply casts the size_t returned by strlen() to an int. - */ - return nr_strlen(func->common.function_name); -#endif } static inline const char* NRPURE nr_php_op_array_file_name(const zend_op_array* op_array) { -#if ZEND_MODULE_API_NO >= ZEND_7_0_X_API_NO /* PHP 7.0+ */ return (op_array->filename && op_array->filename->len) ? op_array->filename->val : NULL; -#else - return op_array->filename; -#endif } static inline nr_string_len_t NRPURE @@ -739,26 +685,16 @@ nr_php_op_array_file_name_len(const zend_op_array* op_array) { static inline const char* NRPURE nr_php_op_array_function_name(const zend_op_array* op_array) { -#if ZEND_MODULE_API_NO >= ZEND_7_0_X_API_NO /* PHP 7.0+ */ return (op_array->function_name && op_array->function_name->len) ? op_array->function_name->val : NULL; -#else - return op_array->function_name; -#endif } static inline const char* NRPURE nr_php_op_array_scope_name(const zend_op_array* op_array) { -#if ZEND_MODULE_API_NO >= ZEND_7_0_X_API_NO /* PHP 7.0+ */ if (op_array->scope && op_array->scope->name && op_array->scope->name->len) { return op_array->scope->name->val; } -#else - if (op_array->scope) { - return op_array->scope->name; - } -#endif return NULL; } @@ -770,31 +706,20 @@ nr_php_function_filename_len(zend_function* func) { static inline const char* NRPURE nr_php_ini_entry_name(const zend_ini_entry* entry) { -#if ZEND_MODULE_API_NO >= ZEND_7_0_X_API_NO /* PHP 7.0+ */ return (entry->name && entry->name->len) ? entry->name->val : NULL; -#else - return entry->name; -#endif } static inline nr_string_len_t NRPURE nr_php_ini_entry_name_length(const zend_ini_entry* entry) { -#if ZEND_MODULE_API_NO >= ZEND_7_0_X_API_NO /* PHP 7.0+ */ return entry->name ? entry->name->len : 0; -#else - return NRSAFELEN(entry->name_length - 1); -#endif } #define NR_PHP_INTERNAL_FN_THIS() getThis() #if ZEND_MODULE_API_NO >= ZEND_8_0_X_API_NO /* PHP 8.0+ */ #define NR_PHP_USER_FN_THIS() nr_php_execute_scope(execute_data) -#elif ZEND_MODULE_API_NO >= ZEND_7_0_X_API_NO \ - && ZEND_MODULE_API_NO < ZEND_8_0_X_API_NO /* PHP 7.0 - 7.4 */ -#define NR_PHP_USER_FN_THIS() getThis() #else -#define NR_PHP_USER_FN_THIS() EG(This) -#endif /* PHP 7.0+ */ +#define NR_PHP_USER_FN_THIS() getThis() +#endif /* PHP 7.2+ */ #if ZEND_MODULE_API_NO >= ZEND_8_0_X_API_NO /* PHP 8.0+ */ /* PHP 8 expects zend_object not zval */ @@ -866,8 +791,6 @@ extern bool nr_php_function_is_static_method(const zend_function* func); */ extern zend_execute_data* nr_get_zend_execute_data(NR_EXECUTE_PROTO TSRMLS_DC); -#if ZEND_MODULE_API_NO >= ZEND_7_0_X_API_NO /* PHP7+ */ - #define NR_NOT_ZEND_USER_FUNC(x) \ (x && (!x->func || !ZEND_USER_CODE(x->func->type))) @@ -886,6 +809,4 @@ static inline uint32_t nr_php_zend_function_lineno(const zend_function* func) { return 0; } -#endif /* PHP 7+ */ - #endif /* PHP_AGENT_HDR */ diff --git a/agent/php_api.c b/agent/php_api.c index 865344442..3f8de5f8b 100644 --- a/agent/php_api.c +++ b/agent/php_api.c @@ -586,16 +586,11 @@ static nrobj_t* nr_php_api_zval_to_attribute_obj(const zval* z TSRMLS_DC) { case IS_DOUBLE: return nro_new_double(Z_DVAL_P(z)); -#ifdef PHP7 case IS_TRUE: return nro_new_boolean(1); case IS_FALSE: return nro_new_boolean(0); -#else - case IS_BOOL: - return nro_new_boolean(Z_BVAL_P(z)); -#endif /* PHP7 */ case IS_STRING: if (!nr_php_is_zval_valid_string(z)) { @@ -632,17 +627,10 @@ static nrobj_t* nr_php_api_zval_to_attribute_obj(const zval* z TSRMLS_DC) { return NULL; #endif /* PHP < 7.3 */ -#if ZEND_MODULE_API_NO >= ZEND_5_6_X_API_NO case IS_CONSTANT_AST: nr_php_api_error(NR_PHP_API_INVALID_ATTRIBUTE_FMT, get_active_function_name(TSRMLS_C), "constant AST"); return NULL; -#else - case IS_CONSTANT_ARRAY: - nr_php_api_error(NR_PHP_API_INVALID_ATTRIBUTE_FMT, - get_active_function_name(TSRMLS_C), "constant array"); - return NULL; -#endif /* PHP >= 5.6 */ default: nr_php_api_error(NR_PHP_API_INVALID_ATTRIBUTE_FMT, @@ -705,7 +693,6 @@ PHP_FUNCTION(newrelic_add_custom_parameter) { key = nr_strdup(tmp); break; -#ifdef PHP7 case IS_TRUE: key = nr_strdup("True"); break; @@ -713,11 +700,6 @@ PHP_FUNCTION(newrelic_add_custom_parameter) { case IS_FALSE: key = nr_strdup("False"); break; -#else - case IS_BOOL: - key = nr_strdup(Z_BVAL_P(zzkey) ? "True" : "False"); - break; -#endif /* PHP7 */ case IS_ARRAY: key = nr_strdup("(Array)"); @@ -747,15 +729,9 @@ PHP_FUNCTION(newrelic_add_custom_parameter) { break; #endif /* PHP < 7.3 */ -#if ZEND_MODULE_API_NO >= ZEND_5_6_X_API_NO case IS_CONSTANT_AST: key = nr_strdup("(Constant AST)"); /* NOTTESTED */ break; -#else - case IS_CONSTANT_ARRAY: - key = nr_strdup("(Constant array)"); /* NOTTESTED */ - break; -#endif /* PHP >= 5.6 */ default: key = nr_strdup("(?)"); /* NOTTESTED */ @@ -925,19 +901,7 @@ PHP_FUNCTION(newrelic_get_browser_timing_header) { /* * Required to silence warnings about PHP's prototypes. */ -#ifdef PHP7 RETVAL_STRING(timingScript); -#else -#if defined(__clang__) || (__GNUC__ > 4) \ - || ((__GNUC__ == 4) && (__GNUC_MINOR__ > 5)) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wcast-qual" - RETVAL_STRING(timingScript, 1); -#pragma GCC diagnostic pop -#else - RETVAL_STRING(timingScript, 1); -#endif -#endif /* PHP7 */ nr_free(timingScript); } @@ -984,19 +948,7 @@ PHP_FUNCTION(newrelic_get_browser_timing_footer) { /* * Required to silence warnings about PHP's prototypes. */ -#ifdef PHP7 RETVAL_STRING(buf); -#else -#if defined(__clang__) || (__GNUC__ > 4) \ - || ((__GNUC__ == 4) && (__GNUC_MINOR__ > 5)) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wcast-qual" - RETVAL_STRING(buf, 1); -#pragma GCC diagnostic pop -#else - RETVAL_STRING(buf, 1); -#endif -#endif /* PHP7 */ nr_free(buf); } diff --git a/agent/php_api_datastore.c b/agent/php_api_datastore.c index 2cddcf4bd..559eb1123 100644 --- a/agent/php_api_datastore.c +++ b/agent/php_api_datastore.c @@ -159,13 +159,11 @@ PHP_FUNCTION(newrelic_record_datastore_segment) { } retval = nr_php_call_fcall_info(fci, fcc); ZVAL_ZVAL(return_value, retval, 0, 1); -#ifdef PHP7 /* * Calling ZVAL_ZVAL with dtor set to true in PHP 7 won't free the * surrounding wrapper. */ efree(retval); -#endif /* PHP7 */ /* * Bail early if an error occurred earlier and we're not instrumenting the diff --git a/agent/php_api_distributed_trace.c b/agent/php_api_distributed_trace.c index 27248b33a..c43a76429 100644 --- a/agent/php_api_distributed_trace.c +++ b/agent/php_api_distributed_trace.c @@ -384,9 +384,7 @@ PHP_FUNCTION(newrelic_insert_distributed_trace_headers) { tracestate = nr_txn_create_w3c_tracestate_header( NRPRG(txn), nr_txn_get_current_segment(NRPRG(txn), NULL)); -#if ZEND_MODULE_API_NO >= ZEND_7_0_X_API_NO /* PHP 7.0+ */ SEPARATE_ARRAY(header_array); -#endif /* PHP7 */ /* * If a given header was created, insert it into the passed in array. diff --git a/agent/php_call.c b/agent/php_call.c index 119271f66..59726d071 100644 --- a/agent/php_call.c +++ b/agent/php_call.c @@ -14,7 +14,6 @@ zval* nr_php_call_user_func(zval* object_ptr, const char* function_name, zend_uint param_count, zval* params[] TSRMLS_DC) { -#if ZEND_MODULE_API_NO >= ZEND_7_0_X_API_NO /* PHP 7.0+ */ #if ZEND_MODULE_API_NO >= ZEND_8_2_X_API_NO zend_object* object = NULL; zend_string* method_name = NULL; @@ -98,43 +97,6 @@ zval* nr_php_call_user_func(zval* object_ptr, } nr_php_zval_free(&retval); return NULL; -#else /* PHP < 7 */ - int zend_result; - zval* fname = NULL; - int no_separation = 0; - HashTable* symbol_table = NULL; - zval*** param_ptrs = NULL; - zval* retval = NULL; - - if ((NULL == function_name) || (function_name[0] == '\0')) { - return NULL; - } - - if ((NULL != params) && (param_count > 0)) { - zend_uint i; - - param_ptrs = (zval***)nr_calloc(param_count, sizeof(zval**)); - for (i = 0; i < param_count; i++) { - param_ptrs[i] = ¶ms[i]; - } - } - - fname = nr_php_zval_alloc(); - nr_php_zval_str(fname, function_name); - zend_result = call_user_function_ex(EG(function_table), &object_ptr, fname, - &retval, param_count, param_ptrs, - no_separation, symbol_table TSRMLS_CC); - nr_php_zval_free(&fname); - - nr_free(param_ptrs); - - if (SUCCESS == zend_result) { - return retval; - } - - nr_php_zval_free(&retval); - return NULL; -#endif } zval* nr_php_call_user_func_catch(zval* object_ptr, @@ -160,43 +122,26 @@ zval* nr_php_call_user_func_catch(zval* object_ptr, * a zend_object. */ -#if ZEND_MODULE_API_NO >= ZEND_7_0_X_API_NO /* PHP 7.0+ */ - { - zend_object* exception_obj = EG(exception); - - retval - = nr_php_call_user_func(object_ptr, function_name, param_count, params); + zend_object* exception_obj = EG(exception); - if ((NULL != EG(exception)) && (EG(exception) != exception_obj)) { - zval* exception_zv = nr_php_zval_alloc(); + retval + = nr_php_call_user_func(object_ptr, function_name, param_count, params); - /* - * Wrap EG(exception) in a zval for API consistency with PHP 5, ensuring - * that we increment the refcount so that the caller's subsequent - * nr_php_zval_free() call does the right thing. - */ + if ((NULL != EG(exception)) && (EG(exception) != exception_obj)) { + zval* exception_zv = nr_php_zval_alloc(); - ZVAL_OBJ(exception_zv, EG(exception)); - Z_ADDREF_P(exception_zv); - - *exception = exception_zv; - zend_clear_exception(); - } - } -#else - { - zval* exception_zv = EG(exception); + /* + * Wrap EG(exception) in a zval for API consistency with PHP 5, ensuring + * that we increment the refcount so that the caller's subsequent + * nr_php_zval_free() call does the right thing. + */ - retval = nr_php_call_user_func(object_ptr, function_name, param_count, - params TSRMLS_CC); + ZVAL_OBJ(exception_zv, EG(exception)); + Z_ADDREF_P(exception_zv); - if ((NULL != EG(exception)) && (EG(exception) != exception_zv)) { - Z_ADDREF_P(EG(exception)); - *exception = EG(exception); - zend_clear_exception(TSRMLS_C); - } + *exception = exception_zv; + zend_clear_exception(); } -#endif /* PHP7+ */ return retval; } @@ -227,7 +172,6 @@ zval* nr_php_call_fcall_info_zval(zend_fcall_info fci, zend_fcall_info_cache fcc, zend_uint param_count, zval* params[] TSRMLS_DC) { -#ifdef PHP7 zend_uint i; if ((NULL != params) && (param_count > 0)) { @@ -246,30 +190,6 @@ zval* nr_php_call_fcall_info_zval(zend_fcall_info fci, nr_free(fci.params); return fci.retval; -#else - zend_uint i; - zval* retval = NULL; - - if ((NULL != params) && (param_count > 0)) { - fci.param_count = (uint32_t)param_count; - fci.params = (zval***)nr_calloc(param_count, sizeof(zval**)); - for (i = 0; i < param_count; i++) { - fci.params[i] = ¶ms[i]; - } - } - - /* - * We don't need to allocate retval; the Zend Engine will do that for us when - * the function returns a value. - */ - fci.retval_ptr_ptr = &retval; - if (SUCCESS != zend_call_function(&fci, &fcc TSRMLS_CC)) { - nr_php_zval_free(&retval); - } - - nr_free(fci.params); - return retval; -#endif /* PHP7 */ } void nr_php_call_user_func_array_handler(nrphpcufafn_t handler, @@ -279,19 +199,13 @@ void nr_php_call_user_func_array_handler(nrphpcufafn_t handler, const zend_function* caller = NULL; if (prev_execute_data) { -#ifdef PHP7 caller = prev_execute_data->func; -#else - caller = prev_execute_data->function_state.function; -#endif /* PHP7 */ } else { #if ZEND_MODULE_API_NO >= ZEND_8_0_X_API_NO \ && !defined OVERWRITE_ZEND_EXECUTE_DATA caller = nr_php_get_caller(EG(current_execute_data), NULL, 1 TSRMLS_CC); -#elif ZEND_MODULE_API_NO >= ZEND_5_5_X_API_NO - caller = nr_php_get_caller(EG(current_execute_data), 1 TSRMLS_CC); #else - caller = nr_php_get_caller(NULL, 1 TSRMLS_CC); + caller = nr_php_get_caller(EG(current_execute_data), 1 TSRMLS_CC); #endif /* PHP >= 5.5 */ } diff --git a/agent/php_compat.h b/agent/php_compat.h index ef727e66a..4100051a8 100644 --- a/agent/php_compat.h +++ b/agent/php_compat.h @@ -10,9 +10,6 @@ #define PHP8 #endif /* PHP 8.0+ */ -#if ZEND_MODULE_API_NO >= ZEND_7_0_X_API_NO /* PHP 7.0+ */ -#define PHP7 - typedef uint32_t zend_uint; typedef size_t nr_string_len_t; typedef size_t nr_output_buffer_string_len_t; @@ -43,117 +40,4 @@ static inline zval* nr_php_zval_direct(zval* zv) { return zv; } -#else /* PHP 5 */ -typedef int nr_string_len_t; -typedef uint nr_output_buffer_string_len_t; -typedef const char nr_php_string_hash_key_t; - -typedef long zend_long; - -#define NR_STRING_LEN_FMT "%d" -#define ZEND_STRING_LEN(s) nr_strlen(s) -#define ZEND_STRING_VALUE(s) (s) - -#define NR_ULONG_FMT "%lu" - -/* - * We need INIT_PZVAL_COPY for ZVAL_DUP, but it's not exported in PHP 5.3. - */ -#if ZEND_MODULE_API_NO <= ZEND_5_3_X_API_NO -#define INIT_PZVAL_COPY(z, v) \ - (z)->value = (v)->value; \ - Z_TYPE_P(z) = Z_TYPE_P(v); \ - Z_SET_REFCOUNT_P(z, 1); \ - Z_UNSET_ISREF_P(z); -#endif - -/* - * Reimplement PHP 7's ZVAL_DUP macro, which is basically just copying the zval - * value and calling zval_copy_ctor() to reinitialise the destination zval's - * garbage collection and reference data. - */ -#define ZVAL_DUP(__dest, __src) \ - do { \ - zval* __d = (__dest); \ - zval* __s = (__src); \ - \ - INIT_PZVAL_COPY(__d, __s); \ - zval_copy_ctor(__d); \ - } while (0); - -static inline zval* nr_php_zval_dereference(zval* zv) { - return zv; -} - -static inline zval* nr_php_zval_direct(zval* zv) { - return zv; -} - -/* - * Reimplement some of the macros that PHP 7 defines to make iteration easier. - * For now, only the macros we actually need are implemented. - */ - -#define ZEND_HASH_FOREACH(ht) \ - do { \ - HashPosition pos; \ - zval** value_ptr = NULL; \ - \ - for (zend_hash_internal_pointer_reset_ex((ht), &pos); \ - SUCCESS \ - == zend_hash_get_current_data_ex((ht), (void**)&value_ptr, &pos); \ - zend_hash_move_forward_ex((ht), &pos)) { -#define ZEND_HASH_FOREACH_VAL(ht, _value) \ - ZEND_HASH_FOREACH(ht) \ - if (NULL == value_ptr) { \ - continue; \ - } \ - _value = *value_ptr; - -#define ZEND_HASH_FOREACH_KEY_VAL(ht, _index, _key, _value) \ - ZEND_HASH_FOREACH(ht) \ - zend_ulong index = 0; \ - uint key_len = 0; \ - char* key_ptr = NULL; \ - int key_type; \ - \ - if (NULL == value_ptr) { \ - continue; \ - } \ - _value = *value_ptr; \ - \ - key_type = zend_hash_get_current_key_ex((ht), &key_ptr, &key_len, &index, 0, \ - &pos); \ - switch (key_type) { \ - case HASH_KEY_IS_LONG: \ - _key = NULL; \ - _index = index; \ - break; \ - \ - case HASH_KEY_IS_STRING: \ - _key = key_ptr; \ - _index = 0; \ - break; \ - \ - default: \ - continue; \ - } - -#define ZEND_HASH_FOREACH_PTR(ht, _ptr) \ - do { \ - HashPosition pos; \ - void** value_ptr = NULL; \ - \ - for (zend_hash_internal_pointer_reset_ex((ht), &pos); \ - SUCCESS \ - == zend_hash_get_current_data_ex((ht), (void**)&value_ptr, &pos); \ - zend_hash_move_forward_ex((ht), &pos)) { -#define ZEND_HASH_FOREACH_END() \ - } /* close the for loop */ \ - } \ - while (0) \ - ; - -#endif /* PHP 7.0+ */ - #endif /* PHP_COMPAT_HDR */ diff --git a/agent/php_curl.c b/agent/php_curl.c index 966831e16..a8df77b86 100644 --- a/agent/php_curl.c +++ b/agent/php_curl.c @@ -205,13 +205,9 @@ static inline void nr_php_curl_copy_header_value(zval* dest, zval* element) { * Copy the header into the destination array, being careful to increment the * refcount on the element to avoid double frees. */ -#ifdef PHP7 if (Z_REFCOUNTED_P(element)) { Z_ADDREF_P(element); } -#else - Z_ADDREF_P(element); -#endif add_next_index_zval(dest, element); } diff --git a/agent/php_environment.c b/agent/php_environment.c index 24f390b1d..c0cae57d1 100644 --- a/agent/php_environment.c +++ b/agent/php_environment.c @@ -185,7 +185,6 @@ static void call_phpinfo(TSRMLS_D) { sapi_module.phpinfo_as_text = save_sapi_flag; } -#if ZEND_MODULE_API_NO >= ZEND_5_4_X_API_NO /* * PHP's output system was rewritten in PHP 5.4. Among the many new * capabilities, internal output handlers can register an opaque pointer that @@ -274,34 +273,6 @@ static void nr_php_gather_php_information(nrobj_t* env TSRMLS_DC) { end: nr_buffer_destroy(&buf); } -#else -static void nr_php_gather_php_information(nrobj_t* env TSRMLS_DC) { - zval* output_handler = NULL; - long chunk_size = 0; - zend_bool erase = 1; - zval* tmp_obj = NULL; - - if (FAILURE - == php_start_ob_buffer(output_handler, chunk_size, erase TSRMLS_CC)) { - /* don't call phpinfo() if we can't buffer because otherwise we're - * going to dump into the user's page. - */ - return; - } - - call_phpinfo(TSRMLS_C); - - tmp_obj = nr_php_zval_alloc(); - - php_ob_get_buffer(tmp_obj TSRMLS_CC); - php_end_ob_buffer(0, 0 TSRMLS_CC); - - nr_php_parse_rocket_assignment_list(Z_STRVAL_P(tmp_obj), Z_STRLEN_P(tmp_obj), - env); - - nr_php_zval_free(&tmp_obj); -} -#endif /* PHP >= 5.4 */ static void nr_php_gather_machine_information(nrobj_t* env) { const char* dyno_value = NULL; diff --git a/agent/php_error.c b/agent/php_error.c index 539911dcc..f7ee90e7f 100644 --- a/agent/php_error.c +++ b/agent/php_error.c @@ -280,11 +280,7 @@ PHP_FUNCTION(newrelic_exception_handler) { * that we can use to do this, rather than having to replicate that logic * ourselves. */ -#ifdef PHP7 zend_exception_error(Z_OBJ_P(exception), E_ERROR TSRMLS_CC); -#else - zend_exception_error(exception, E_ERROR TSRMLS_CC); -#endif /* PHP7 */ } /* PHP Fatal errors: E_ERROR | E_USER_ERROR | E_PARSE | E_CORE_ERROR | @@ -347,11 +343,7 @@ void nr_php_error_install_exception_handler(TSRMLS_D) { * handler installed and this function is called, we'll handle that case * anyway in case another extension is trying to do the same thing. */ -#ifdef PHP7 has_user_exception_handler = (IS_UNDEF != Z_TYPE(EG(user_exception_handler))); -#else - has_user_exception_handler = (NULL != EG(user_exception_handler)); -#endif /* PHP7 */ if (has_user_exception_handler) { nrl_verbosedebug(NRL_ERROR, @@ -365,24 +357,14 @@ void nr_php_error_install_exception_handler(TSRMLS_D) { * user_exception_handlers stack. We don't need to copy it: ownership of * the pointer simply passes from executor_globals to the stack. */ -#ifdef PHP7 zend_stack_push(&EG(user_exception_handlers), &EG(user_exception_handler)); -#else - zend_ptr_stack_push(&EG(user_exception_handlers), - EG(user_exception_handler)); -#endif /* PHP7 */ } /* * Actually allocate and set the user_exception_handler zval. PHP itself * will destroy this at the end of the request. */ -#ifdef PHP7 nr_php_zval_str(&EG(user_exception_handler), "newrelic_exception_handler"); -#else - ALLOC_INIT_ZVAL(EG(user_exception_handler)); - nr_php_zval_str(EG(user_exception_handler), "newrelic_exception_handler"); -#endif } /* @@ -840,9 +822,5 @@ nr_status_t nr_php_error_record_exception_segment(nrtxn_t* txn, } int nr_php_error_zval_is_exception(zval* zv TSRMLS_DC) { -#ifdef PHP7 return nr_php_object_instanceof_class(zv, "Throwable" TSRMLS_CC); -#else - return nr_php_object_instanceof_class(zv, "Exception" TSRMLS_CC); -#endif /* PHP7 */ } diff --git a/agent/php_execute.c b/agent/php_execute.c index 7257f7471..54a7d5a57 100644 --- a/agent/php_execute.c +++ b/agent/php_execute.c @@ -155,12 +155,10 @@ int nr_format_zval_for_debug(zval* arg, break; } -#if ZEND_MODULE_API_NO >= ZEND_7_0_X_API_NO /* PHP7+ */ if (NULL == Z_STR_P(arg)) { safe_append("invalid string", 14); break; } -#endif str = Z_STRVAL_P(arg); len = Z_STRLEN_P(arg); @@ -199,7 +197,6 @@ int nr_format_zval_for_debug(zval* arg, safe_append(tmp, len); break; -#if ZEND_MODULE_API_NO >= ZEND_7_0_X_API_NO /* PHP7+ */ case IS_TRUE: safe_append("true", 4); break; @@ -207,15 +204,6 @@ int nr_format_zval_for_debug(zval* arg, case IS_FALSE: safe_append("false", 5); break; -#else - case IS_BOOL: - if (0 == Z_BVAL_P(arg)) { - safe_append("false", 5); - } else { - safe_append("true", 4); - } - break; -#endif /* PHP7 */ case IS_DOUBLE: /* @@ -227,12 +215,10 @@ int nr_format_zval_for_debug(zval* arg, break; case IS_OBJECT: -#if ZEND_MODULE_API_NO >= ZEND_7_0_X_API_NO /* PHP7+ */ if (NULL == Z_OBJ_P(arg)) { safe_append("invalid object", 14); break; } -#endif /* PHP7 */ ce = Z_OBJCE_P(arg); len = snprintf(tmp, sizeof(tmp) - 1, @@ -353,9 +339,6 @@ static const nr_framework_table_t all_frameworks[] = { {"Joomla", "joomla", NR_PSTR("libraries/joomla/factory.php"), 0, nr_joomla_enable, NR_FW_JOOMLA}, /* >= Joomla 1.6, including 2.5 and 3.2 */ - {"Kohana", "kohana", NR_PSTR("kohana/core.php"), 0, nr_kohana_enable, NR_FW_KOHANA}, - {"Kohana", "kohana", NR_PSTR("kohana/core.php"), 0, nr_kohana_enable, NR_FW_KOHANA}, - /* See below: Zend, the legacy project of Laminas, which shares much of the instrumentation implementation with Laminas */ {"Laminas3", "laminas3", NR_PSTR("laminas/mvc/application.php"), 0, @@ -385,23 +368,11 @@ static const nr_framework_table_t all_frameworks[] = { {"MediaWiki", "mediawiki", NR_PSTR("includes/webstart.php"), 0, nr_mediawiki_enable, NR_FW_MEDIAWIKI}, - {"Silex", "silex", NR_PSTR("silex/application.php"), 0, nr_silex_enable, - NR_FW_SILEX}, - {"Slim", "slim", NR_PSTR("slim/slim/app.php"), 0, nr_slim_enable, NR_FW_SLIM}, /* 3.x */ {"Slim", "slim", NR_PSTR("slim/slim/slim.php"), 0, nr_slim_enable, NR_FW_SLIM}, /* 2.x */ - {"Symfony", "symfony1", NR_PSTR("sfcontext.class.php"), 0, nr_symfony1_enable, - NR_FW_SYMFONY1}, - {"Symfony", "symfony1", NR_PSTR("sfconfig.class.php"), 0, nr_symfony1_enable, - NR_FW_SYMFONY1}, - {"Symfony2", "symfony2", NR_PSTR("bootstrap.php.cache"), 0, nr_symfony2_enable, - NR_FW_SYMFONY2}, /* also Symfony 3 */ - {"Symfony2", "symfony2", - NR_PSTR("symfony/bundle/frameworkbundle/frameworkbundle.php"), 0, - nr_symfony2_enable, NR_FW_SYMFONY2}, /* also Symfony 3 */ {"Symfony4", "symfony4", NR_PSTR("http-kernel/httpkernel.php"), 0, nr_symfony4_enable, NR_FW_SYMFONY4}, /* also Symfony 5/6/7 */ @@ -414,11 +385,12 @@ static const nr_framework_table_t all_frameworks[] = { /* See above: Laminas, the successor to Zend, which shares much of the instrumentation implementation with Zend */ - {"Zend", "zend", NR_PSTR("zend/loader.php"), 0, nr_zend_enable, NR_FW_ZEND}, - {"Zend2", "zend2", NR_PSTR("zend/mvc/application.php"), 0, nr_fw_zend2_enable, - NR_FW_ZEND2}, - {"Zend2", "zend2", NR_PSTR("zend-mvc/src/application.php"), 0, nr_fw_zend2_enable, - NR_FW_ZEND2}, + // treating zend2 as zend3 for backwards compatibility + {"Zend3", "zend2", NULL, 0, 0, nr_fw_zend3_enable, NR_FW_ZEND3}, + {"Zend3", "zend3", NR_PSTR("zend/mvc/application.php"), 0, nr_fw_zend3_enable, + NR_FW_ZEND3}, + {"Zend3", "zend3", NR_PSTR("zend-mvc/src/application.php"), 0, nr_fw_zend3_enable, + NR_FW_ZEND3}, }; // clang-format: on static const int num_all_frameworks @@ -484,7 +456,6 @@ static nr_library_table_t libraries[] = { /* Doctrine 2.18 reworked the directory structure */ {"Doctrine 2", NR_PSTR("doctrine/orm/src/query.php"), nr_doctrine2_enable}, - {"Guzzle 3", NR_PSTR("guzzle/http/client.php"), nr_guzzle3_enable}, {"Guzzle 4-5", NR_PSTR("hasemitterinterface.php"), nr_guzzle4_enable}, {"Guzzle 6", NR_PSTR("guzzle/src/functions_include.php"), nr_guzzle6_enable}, @@ -1041,7 +1012,6 @@ void nr_php_execute_file(const zend_op_array* op_array, */ static void nr_php_execute_metadata_init(nr_php_execute_metadata_t* metadata, zend_op_array* op_array) { -#if ZEND_MODULE_API_NO >= ZEND_7_0_X_API_NO /* PHP7+ */ if (op_array->scope && op_array->scope->name && op_array->scope->name->len) { metadata->scope = op_array->scope->name; zend_string_addref(metadata->scope); @@ -1067,13 +1037,8 @@ static void nr_php_execute_metadata_init(nr_php_execute_metadata_t* metadata, } metadata->function_lineno = op_array->line_start; - -#else - metadata->op_array = op_array; -#endif /* PHP7 */ } -#if ZEND_MODULE_API_NO >= ZEND_7_0_X_API_NO /* PHP7+ */ /* * Purpose : If code level metrics are enabled, use the metadata to create agent * attributes in the segment with code level metrics. @@ -1212,7 +1177,6 @@ static inline void nr_php_execute_segment_add_code_level_metrics( "code.lineno", metadata->function_lineno); } -#endif /* * Purpose : Create a metric name from the given metadata. * @@ -1231,13 +1195,8 @@ static void nr_php_execute_metadata_metric( const char* function_name; const char* scope_name; -#if ZEND_MODULE_API_NO >= ZEND_7_0_X_API_NO /* PHP7+ */ scope_name = metadata->scope ? ZSTR_VAL(metadata->scope) : NULL; function_name = metadata->function ? ZSTR_VAL(metadata->function) : NULL; -#else - scope_name = nr_php_op_array_scope_name(metadata->op_array); - function_name = nr_php_op_array_function_name(metadata->op_array); -#endif /* PHP7 */ snprintf(buf, len, "Custom/%s%s%s", scope_name ? scope_name : "", scope_name ? "::" : "", function_name ? function_name : ""); @@ -1250,7 +1209,6 @@ static void nr_php_execute_metadata_metric( */ static inline void nr_php_execute_metadata_release( nr_php_execute_metadata_t* metadata) { -#if ZEND_MODULE_API_NO >= ZEND_7_0_X_API_NO if (NULL != metadata->scope) { zend_string_release(metadata->scope); @@ -1266,10 +1224,6 @@ static inline void nr_php_execute_metadata_release( zend_string_release(metadata->filepath); metadata->filepath = NULL; } - -#else - metadata->op_array = NULL; -#endif /* PHP7 */ } static inline void nr_php_execute_segment_add_metric( @@ -1347,11 +1301,9 @@ static inline void nr_php_execute_segment_end( * Check if code level metrics are enabled in the ini. * If they aren't, exit and don't create any CLM. */ -#if ZEND_MODULE_API_NO >= ZEND_7_0_X_API_NO /* PHP >= PHP7 */ if (NRINI(code_level_metrics_enabled)) { nr_php_execute_segment_add_code_level_metrics(s, metadata); } -#endif nr_segment_end(&s); } else { @@ -1485,7 +1437,6 @@ static void nr_php_execute_enabled(NR_EXECUTE_PROTO TSRMLS_DC) { zval* exception_zval = NULL; nr_status_t status; -#if ZEND_MODULE_API_NO >= ZEND_7_0_X_API_NO /* PHP7+ */ /* * On PHP 7, EG(exception) is stored as a zend_object, and is only * wrapped in a zval when it actually needs to be. @@ -1494,12 +1445,6 @@ static void nr_php_execute_enabled(NR_EXECUTE_PROTO TSRMLS_DC) { ZVAL_OBJ(&exception, EG(exception)); exception_zval = &exception; -#else - /* - * On PHP 5, the exception is just a regular old zval. - */ - exception_zval = EG(exception); -#endif /* PHP7 */ status = nr_php_error_record_exception_segment( NRPRG(txn), exception_zval, &NRPRG(exception_filters) TSRMLS_CC); @@ -1651,28 +1596,11 @@ static void nr_php_show_exec_internal(NR_EXECUTE_PROTO_OVERWRITE, NRP_PHP(name ? name : "?"), NRP_ARGSTR(argstr)); } -#if ZEND_MODULE_API_NO >= ZEND_7_0_X_API_NO #define CALL_ORIGINAL \ (NR_PHP_PROCESS_GLOBALS(orig_execute_internal)(execute_data, return_value)) void nr_php_execute_internal(zend_execute_data* execute_data, zval* return_value NRUNUSED) -#elif ZEND_MODULE_API_NO >= ZEND_5_5_X_API_NO -#define CALL_ORIGINAL \ - (NR_PHP_PROCESS_GLOBALS(orig_execute_internal)(execute_data, fci, \ - return_value_used TSRMLS_CC)) - -void nr_php_execute_internal(zend_execute_data* execute_data, - zend_fcall_info* fci, - int return_value_used TSRMLS_DC) -#else -#define CALL_ORIGINAL \ - (NR_PHP_PROCESS_GLOBALS(orig_execute_internal)(execute_data, \ - return_value_used TSRMLS_CC)) - -void nr_php_execute_internal(zend_execute_data* execute_data, - int return_value_used TSRMLS_DC) -#endif { nrtime_t duration = 0; zend_function* func = NULL; @@ -1689,11 +1617,7 @@ void nr_php_execute_internal(zend_execute_data* execute_data, return; } -#if ZEND_MODULE_API_NO >= ZEND_7_0_X_API_NO /* PHP7+ */ func = execute_data->func; -#else - func = execute_data->function_state.function; -#endif /* PHP7 */ if (nrunlikely(NULL == func)) { nrl_verbosedebug(NRL_AGENT, "%s: NULL func", __func__); @@ -1710,18 +1634,7 @@ void nr_php_execute_internal(zend_execute_data* execute_data, * implementing it. */ if (nrunlikely(NR_PHP_PROCESS_GLOBALS(special_flags).show_executes)) { -#if ZEND_MODULE_API_NO >= ZEND_5_5_X_API_NO nr_php_show_exec_internal(NR_EXECUTE_ORIG_ARGS_OVERWRITE, func TSRMLS_CC); -#else - /* - * We're passing the same pointer twice. This is inefficient. However, no - * user is ever likely to be affected, since this is a code path handling - * a special flag, and it makes the nr_php_show_exec_internal() API cleaner - * for modern versions of PHP without needing to have another function - * conditionally compiled. - */ - nr_php_show_exec_internal((zend_op_array*)func, func TSRMLS_CC); -#endif /* PHP >= 5.5 */ } segment = nr_segment_start(NRPRG(txn), NULL, NULL); CALL_ORIGINAL; diff --git a/agent/php_execute.h b/agent/php_execute.h index c92ec6e3d..b7fb23e30 100644 --- a/agent/php_execute.h +++ b/agent/php_execute.h @@ -84,14 +84,10 @@ typedef nr_framework_classification_t (*nr_framework_special_fn_t)( * Therefore we have to be more selective in our approach. */ typedef struct { -#if ZEND_MODULE_API_NO >= ZEND_7_0_X_API_NO /* PHP7+ */ zend_string* scope; zend_string* function; zend_string* filepath; uint32_t function_lineno; -#else - zend_op_array* op_array; -#endif /* PHP7 */ } nr_php_execute_metadata_t; extern nrframework_t nr_php_framework_from_config(const char* config_name); diff --git a/agent/php_explain.c b/agent/php_explain.c index a456326f9..b640dace8 100644 --- a/agent/php_explain.c +++ b/agent/php_explain.c @@ -61,7 +61,6 @@ nr_status_t nr_php_explain_add_value_to_row(const zval* zv, nrobj_t* row) { nro_set_array_none(row, 0); break; -#ifdef PHP7 case IS_TRUE: nro_set_array_boolean(row, 0, 1); break; @@ -69,11 +68,6 @@ nr_status_t nr_php_explain_add_value_to_row(const zval* zv, nrobj_t* row) { case IS_FALSE: nro_set_array_boolean(row, 0, 0); break; -#else - case IS_BOOL: - nro_set_array_boolean(row, 0, Z_BVAL_P(zv)); - break; -#endif default: nrl_verbosedebug(NRL_SQL, "%s: unknown zval type %d", __func__, diff --git a/agent/php_file_get_contents.c b/agent/php_file_get_contents.c index e6be72065..fa6029fbd 100644 --- a/agent/php_file_get_contents.c +++ b/agent/php_file_get_contents.c @@ -478,13 +478,11 @@ nr_status_t nr_php_file_get_contents_recurse_with_context( nr_php_zval_free(&context); if (rval) { ZVAL_ZVAL(return_value, rval, 0, 1); -#if ZEND_MODULE_API_NO >= ZEND_7_0_X_API_NO /* PHP 7.0+ */ /* * Calling ZVAL_ZVAL with dtor set to true in PHP 7 won't free the * surrounding wrapper. */ efree(rval); -#endif /* PHP7 */ } else { ZVAL_FALSE(return_value); } diff --git a/agent/php_hash.c b/agent/php_hash.c index be35d9d64..c0d9b14f0 100644 --- a/agent/php_hash.c +++ b/agent/php_hash.c @@ -5,7 +5,6 @@ #include "php_agent.h" #include "php_hash.h" -#ifdef PHP7 static int nr_php_zend_hash_ptr_apply_wrapper(zval* value, int num_args, va_list args, @@ -24,26 +23,6 @@ static int nr_php_zend_hash_ptr_apply_wrapper(zval* value, return (apply_func)(Z_PTR_P(value), arg, hash_key TSRMLS_CC); } -#else -static int nr_php_zend_hash_ptr_apply_wrapper(void* value TSRMLS_DC, - int num_args, - va_list args, - zend_hash_key* hash_key) { - nr_php_ptr_apply_t apply_func; - void* arg; - - (void)num_args; - - apply_func = (nr_php_ptr_apply_t)va_arg(args, nr_php_ptr_apply_t); - arg = (void*)va_arg(args, void*); - - if (NULL == value) { - return ZEND_HASH_APPLY_KEEP; - } - - return (apply_func)(value, arg, hash_key TSRMLS_CC); -} -#endif /* PHP7 */ void nr_php_zend_hash_ptr_apply(HashTable* ht, nr_php_ptr_apply_t apply_func, @@ -53,7 +32,6 @@ void nr_php_zend_hash_ptr_apply(HashTable* ht, apply_func, arg); } -#ifdef PHP7 static int nr_php_zend_hash_zval_apply_wrapper(zval* value, int num_args, va_list args, @@ -68,28 +46,6 @@ static int nr_php_zend_hash_zval_apply_wrapper(zval* value, return (apply_func)(value, arg, hash_key TSRMLS_CC); } -#else -static int nr_php_zend_hash_zval_apply_wrapper(zval** value TSRMLS_DC, - int num_args, - va_list args, - zend_hash_key* hash_key) { - nr_php_zval_apply_t apply_func; - void* arg; - - (void)num_args; - - apply_func = (nr_php_zval_apply_t)va_arg(args, nr_php_zval_apply_t); - arg = (void*)va_arg(args, void*); - - if ((NULL == value) || (NULL == *value)) { - return ZEND_HASH_APPLY_KEEP; - } - - (void)num_args; - - return (apply_func)(*value, arg, hash_key TSRMLS_CC); -} -#endif /* PHP7 */ void nr_php_zend_hash_zval_apply(HashTable* ht, nr_php_zval_apply_t apply_func, @@ -104,7 +60,6 @@ int nr_php_zend_hash_del(HashTable* ht, const char* key) { return 0; } -#ifdef PHP7 int retval; zend_string* zs = zend_string_init(key, nr_strlen(key), 0); @@ -112,9 +67,6 @@ int nr_php_zend_hash_del(HashTable* ht, const char* key) { zend_string_free(zs); return (SUCCESS == retval); -#else - return (SUCCESS == zend_hash_del(ht, key, nr_strlen(key) + 1)); -#endif /* PHP7 */ } int nr_php_zend_hash_exists(const HashTable* ht, const char* key) { @@ -124,14 +76,9 @@ int nr_php_zend_hash_exists(const HashTable* ht, const char* key) { * lookups! */ -#ifdef PHP7 return zend_hash_str_exists(ht, key, nr_strlen(key)); -#else - return zend_hash_exists(ht, key, nr_strlen(key) + 1); -#endif /* PHP7 */ } -#ifdef PHP7 zval* nr_php_zend_hash_find(const HashTable* ht, const char* key) { if ((NULL == ht) || (NULL == key) || ('\0' == key[0])) { return NULL; @@ -155,49 +102,3 @@ zval* nr_php_zend_hash_index_find(const HashTable* ht, zend_ulong index) { return zend_hash_index_find(ht, index); } -#else /* Not PHP7 */ -void* nr_php_zend_hash_find_ptr(const HashTable* ht, const char* key) { - void* data = NULL; - int keylen; - int rv; - - if ((0 == ht) || (0 == key)) { - return NULL; - } - - keylen = nr_strlen(key); - if (keylen <= 0) { - return NULL; - } - keylen += 1; /* Lookup length requires null terminator */ - - rv = zend_hash_find(ht, key, keylen, &data); - if (SUCCESS != rv) { - return NULL; - } - - return data; -} - -zval* nr_php_zend_hash_find(const HashTable* ht, const char* key) { - zval** zv_pp = (zval**)nr_php_zend_hash_find_ptr(ht, key); - - if (NULL == zv_pp) { - return NULL; - } - - return *zv_pp; -} - -zval* nr_php_zend_hash_index_find(const HashTable* ht, zend_ulong index) { - void* data = NULL; - int rv; - - rv = zend_hash_index_find(ht, index, &data); - if ((SUCCESS != rv) || (NULL == data)) { - return NULL; - } - - return *((zval**)data); -} -#endif /* PHP7 */ diff --git a/agent/php_hash.h b/agent/php_hash.h index f808af370..0fc51863d 100644 --- a/agent/php_hash.h +++ b/agent/php_hash.h @@ -29,11 +29,7 @@ nr_php_zend_hash_key_is_string(const zend_hash_key* hash_key) { return 0; } -#ifdef PHP7 return (NULL != hash_key->key); -#else - return ((NULL != hash_key->arKey) && (0 != hash_key->nKeyLength)); -#endif /* PHP7 */ } static inline int NRPURE @@ -56,11 +52,7 @@ nr_php_zend_hash_key_string_len(const zend_hash_key* hash_key) { return 0; } -#ifdef PHP7 return hash_key->key ? hash_key->key->len : 0; -#else - return (nr_string_len_t)NRSAFELEN(hash_key->nKeyLength); -#endif } static inline const char* NRPURE @@ -69,11 +61,7 @@ nr_php_zend_hash_key_string_value(const zend_hash_key* hash_key) { return NULL; } -#ifdef PHP7 return hash_key->key ? hash_key->key->val : NULL; -#else - return hash_key->arKey; -#endif } /* @@ -84,7 +72,6 @@ nr_php_zend_hash_key_string_value(const zend_hash_key* hash_key) { * Strings will always be duplicated, since that's non-optional in * PHP 7 anyway. */ -#ifdef PHP7 #define nr_php_add_assoc_string(ht, key, str) \ add_assoc_string((ht), (key), (str)) @@ -95,19 +82,6 @@ nr_php_zend_hash_key_string_value(const zend_hash_key* hash_key) { #define nr_php_add_next_index_stringl(ht, str, strlen) \ add_next_index_stringl((ht), (str), (strlen)) -#else -#define nr_php_add_assoc_string(ht, key, str) \ - add_assoc_string((ht), (key), (str), 1) - -#define nr_php_add_assoc_stringl(ht, key, str, strlen) \ - add_assoc_stringl((ht), (key), (str), (strlen), 1) - -#define nr_php_add_next_index_string(ht, str) \ - add_next_index_string((ht), (str), 1) - -#define nr_php_add_next_index_stringl(ht, str, strlen) \ - add_next_index_stringl((ht), (str), (strlen), 1) -#endif /* PHP7 */ /* * Purpose : Wrap add_assoc_zval to ensure consistent ownership behaviour. @@ -122,7 +96,6 @@ nr_php_zend_hash_key_string_value(const zend_hash_key* hash_key) { static inline int nr_php_add_assoc_zval(zval* arr, const char* key, zval* value) { -#if ZEND_MODULE_API_NO >= ZEND_7_0_X_API_NO /* PHP 7.0+ */ zval copy; ZVAL_DUP(©, value); @@ -133,22 +106,6 @@ static inline int nr_php_add_assoc_zval(zval* arr, #else return add_assoc_zval(arr, key, ©); #endif /* PHP8 */ -#else /* Less than PHP7 */ - zval* copy; - - ALLOC_ZVAL(copy); - INIT_PZVAL(copy); - - /* - * When we drop support for PHP 5.3, we can just use ZVAL_COPY_VALUE here. - */ - copy->value = value->value; - Z_TYPE_P(copy) = Z_TYPE_P(value); - - zval_copy_ctor(copy); - - return add_assoc_zval(arr, key, copy); -#endif /* PHP7 */ } /* @@ -164,28 +121,11 @@ static inline int nr_php_add_assoc_zval(zval* arr, static inline int nr_php_add_index_zval(zval* arr, zend_ulong index, zval* value) { -#ifdef PHP7 zval copy; ZVAL_DUP(©, value); return add_index_zval(arr, index, ©); -#else - zval* copy; - - ALLOC_ZVAL(copy); - INIT_PZVAL(copy); - - /* - * When we drop support for PHP 5.3, we can just use ZVAL_COPY_VALUE here. - */ - copy->value = value->value; - Z_TYPE_P(copy) = Z_TYPE_P(value); - - zval_copy_ctor(copy); - - return add_index_zval(arr, index, copy); -#endif /* PHP7 */ } typedef int (*nr_php_ptr_apply_t)(void* value, diff --git a/agent/php_hooks.h b/agent/php_hooks.h index 63a81eb34..718aef020 100644 --- a/agent/php_hooks.h +++ b/agent/php_hooks.h @@ -61,16 +61,7 @@ extern void nr_php_error_cb(int type, ZEND_ATTRIBUTE_PTR_FORMAT(printf, 4, 0); #endif /* PHP >= 8.1 */ -#if ZEND_MODULE_API_NO >= ZEND_7_0_X_API_NO /* PHP 7.0+ */ extern void nr_php_execute_internal(zend_execute_data* execute_data, zval* return_value); -#elif ZEND_MODULE_API_NO >= ZEND_5_5_X_API_NO -extern void nr_php_execute_internal(zend_execute_data* execute_data, - zend_fcall_info* fci, - int return_value_used TSRMLS_DC); -#else -extern void nr_php_execute_internal(zend_execute_data* execute_data, - int return_value_used TSRMLS_DC); -#endif #endif /* PHP_HOOKS_HDR */ diff --git a/agent/php_includes.h b/agent/php_includes.h index da255fdbc..a1575e51d 100644 --- a/agent/php_includes.h +++ b/agent/php_includes.h @@ -41,12 +41,6 @@ * Zend Engine API numbers. * Find these numbers at: php-src/Zend/zend_modules.h */ -#define ZEND_5_3_X_API_NO 20090626 -#define ZEND_5_4_X_API_NO 20100525 -#define ZEND_5_5_X_API_NO 20121212 -#define ZEND_5_6_X_API_NO 20131226 -#define ZEND_7_0_X_API_NO 20151012 -#define ZEND_7_1_X_API_NO 20160303 #define ZEND_7_2_X_API_NO 20170718 #define ZEND_7_3_X_API_NO 20180731 #define ZEND_7_4_X_API_NO 20190902 @@ -60,11 +54,7 @@ #include "Zend/zend_observer.h" #endif -#if ZEND_MODULE_API_NO >= ZEND_5_6_X_API_NO #include "Zend/zend_virtual_cwd.h" -#else /* PHP < 5.6 */ -#include "tsrm_virtual_cwd.h" -#endif #if defined(ZTS) #include "TSRM.h" diff --git a/agent/php_internal_instrument.c b/agent/php_internal_instrument.c index e37510e32..1c7725a76 100644 --- a/agent/php_internal_instrument.c +++ b/agent/php_internal_instrument.c @@ -1231,11 +1231,9 @@ NR_INNER_WRAPPER(mysqli_stmt_bind_param) { && !defined OVERWRITE_ZEND_EXECUTE_DATA argv[i] = nr_php_get_user_func_arg(i + 1, EG(current_execute_data), NULL TSRMLS_CC); -#elif ZEND_MODULE_API_NO >= ZEND_5_5_X_API_NO +#else argv[i] = nr_php_get_user_func_arg(i + 1, EG(current_execute_data) TSRMLS_CC); -#else /* PHP < 5.5 */ - argv[i] = nr_php_get_user_func_arg(i + 1, EG(active_op_array) TSRMLS_CC); #endif } @@ -3021,11 +3019,7 @@ static inline int nr_php_should_instrument_exception_handler( NR_INNER_WRAPPER(exception_common) { zval* exception_handler = NULL; -#if ZEND_MODULE_API_NO >= ZEND_7_0_X_API_NO /* PHP 7.0+ */ exception_handler = &EG(user_exception_handler); -#else - exception_handler = EG(user_exception_handler); -#endif /* * Remove instrumentation from the current exception handler, if any. @@ -3043,11 +3037,7 @@ NR_INNER_WRAPPER(exception_common) { */ nr_wrapper->oldhandler(INTERNAL_FUNCTION_PARAM_PASSTHRU); -#if ZEND_MODULE_API_NO >= ZEND_7_0_X_API_NO /* PHP 7.0+ */ exception_handler = &EG(user_exception_handler); -#else - exception_handler = EG(user_exception_handler); -#endif /* * Add instrumentation to the new exception handler, if any. @@ -3057,11 +3047,7 @@ NR_INNER_WRAPPER(exception_common) { func = nr_php_zval_to_function(exception_handler TSRMLS_CC); nr_php_add_exception_function(func TSRMLS_CC); -#if ZEND_MODULE_API_NO >= ZEND_7_0_X_API_NO /* PHP 7.0+ */ } else if (IS_UNDEF == Z_TYPE_P(exception_handler)) { -#else - } else if (NULL == exception_handler) { -#endif /* PHP7+ */ nr_php_error_install_exception_handler(TSRMLS_C); } } @@ -3443,13 +3429,8 @@ void nr_php_generate_internal_wrap_records(void) { 0) NR_INTERNAL_WRAPREC("mysqli_commit", mysqli_commit, mysqli_commit, 0, 0) -#if ZEND_MODULE_API_NO >= ZEND_7_0_X_API_NO /* PHP 7.0+ */ NR_INTERNAL_WRAPREC("mysqli::__construct", mysqliC_construct, mysqli_construct, 0, 0) -#else - NR_INTERNAL_WRAPREC("mysqli::mysqli", mysqliC_construct, mysqli_construct, 0, - 0) -#endif /* PHP7+ */ NR_INTERNAL_WRAPREC("mysqli::multi_query", mysqliC_multi_query, mysqli_general_query, 0, 0) diff --git a/agent/php_newrelic.h b/agent/php_newrelic.h index 9080dd370..9683bad28 100644 --- a/agent/php_newrelic.h +++ b/agent/php_newrelic.h @@ -68,8 +68,7 @@ extern zend_module_entry newrelic_module_entry; #define NR_UNUSED_FUNC_RETURN_VALUE (void)func_return_value /* NR_ZEND_EXECUTE_HOOK to be removed in future ticket */ #define NR_ZEND_EXECUTE_HOOK zend_execute_ex - -#elif ZEND_MODULE_API_NO >= ZEND_7_0_X_API_NO /* PHP 7.0+ and overwrite hook*/ +#else #define NR_SPECIALFNPTR_PROTO \ struct _nruserfn_t *wraprec, nr_segment_t *auto_segment, \ zend_execute_data *execute_data @@ -83,36 +82,6 @@ extern zend_module_entry newrelic_module_entry; #define NR_UNUSED_SPECIALFN (void)execute_data #define NR_UNUSED_FUNC_RETURN_VALUE #define NR_ZEND_EXECUTE_HOOK zend_execute_ex - -#elif ZEND_MODULE_API_NO >= ZEND_5_5_X_API_NO -#define NR_SPECIALFNPTR_PROTO \ - struct _nruserfn_t *wraprec, nr_segment_t *auto_segment, \ - zend_execute_data *execute_data -#define NR_SPECIALFNPTR_ORIG_ARGS wraprec, auto_segment, execute_data -#define NR_SPECIALFN_PROTO nruserfn_t *wraprec, zend_execute_data *execute_data -#define NR_OP_ARRAY (execute_data->op_array) -#define NR_EXECUTE_PROTO zend_execute_data* execute_data -#define NR_EXECUTE_PROTO_OVERWRITE zend_execute_data* execute_data -#define NR_EXECUTE_ORIG_ARGS_OVERWRITE execute_data -#define NR_EXECUTE_ORIG_ARGS execute_data -#define NR_UNUSED_SPECIALFN (void)execute_data -#define NR_UNUSED_FUNC_RETURN_VALUE -#define NR_ZEND_EXECUTE_HOOK zend_execute_ex - -#else /* PHP < 5.5 */ -#define NR_SPECIALFNPTR_PROTO \ - struct _nruserfn_t *wraprec, nr_segment_t *auto_segment, \ - zend_op_array *op_array_arg -#define NR_SPECIALFNPTR_ORIG_ARGS wraprec, auto_segment, op_array_arg -#define NR_SPECIALFN_PROTO nruserfn_t *wraprec, zend_op_array *op_array_arg -#define NR_OP_ARRAY (op_array_arg) -#define NR_EXECUTE_PROTO zend_op_array* op_array_arg -#define NR_EXECUTE_PROTO_OVERWRITE zend_op_array* op_array_arg -#define NR_EXECUTE_ORIG_ARGS_OVERWRITE op_array_arg -#define NR_EXECUTE_ORIG_ARGS op_array_arg -#define NR_UNUSED_SPECIALFN (void)op_array_arg -#define NR_UNUSED_FUNC_RETURN_VALUE -#define NR_ZEND_EXECUTE_HOOK zend_execute #endif #if ZEND_MODULE_API_NO >= ZEND_8_0_X_API_NO \ @@ -122,30 +91,17 @@ extern zend_module_entry newrelic_module_entry; #define NR_GET_RETURN_VALUE_PTR nr_php_get_return_value_ptr(TSRMLS_C) #endif -#if ZEND_MODULE_API_NO >= ZEND_7_0_X_API_NO /* PHP 7.0+ */ #define NR_UNUSED_EXECUTE_DATA (void)execute_data; #define NR_UNUSED_HT #define NR_UNUSED_RETURN_VALUE (void)return_value; #define NR_UNUSED_RETURN_VALUE_PTR #define NR_UNUSED_RETURN_VALUE_USED #define NR_UNUSED_THIS_PTR -#else -#define NR_UNUSED_EXECUTE_DATA -#define NR_UNUSED_HT (void)ht; -#define NR_UNUSED_RETURN_VALUE (void)return_value; -#define NR_UNUSED_RETURN_VALUE_PTR (void)return_value_ptr; -#define NR_UNUSED_RETURN_VALUE_USED (void)return_value_used; -#define NR_UNUSED_THIS_PTR (void)this_ptr; -#endif /* PHP7+ */ /* * Convenience macro to handle unused TSRM parameters. */ -#if ZTS && !defined(PHP7) && !defined(PHP8) -#define NR_UNUSED_TSRMLS (void)tsrm_ls; -#else #define NR_UNUSED_TSRMLS -#endif typedef enum { NR_FW_UNSET = 0, @@ -155,22 +111,17 @@ typedef enum { NR_FW_DRUPAL, /* Drupal 6/7 */ NR_FW_DRUPAL8, NR_FW_JOOMLA, - NR_FW_KOHANA, NR_FW_LARAVEL, NR_FW_LUMEN, NR_FW_MAGENTO1, NR_FW_MAGENTO2, NR_FW_MEDIAWIKI, - NR_FW_SILEX, NR_FW_SLIM, - NR_FW_SYMFONY1, - NR_FW_SYMFONY2, NR_FW_SYMFONY4, NR_FW_WORDPRESS, NR_FW_YII1, NR_FW_YII2, - NR_FW_ZEND, - NR_FW_ZEND2, + NR_FW_ZEND3, NR_FW_LAMINAS3, NR_FW_NONE, /* Must be immediately before NR_FW_MUST_BE_LAST */ NR_FW_MUST_BE_LAST @@ -265,20 +216,9 @@ typedef int (*nrphphdrfn_t)(sapi_header_struct* sapi_header, sapi_header_op_enum op, sapi_headers_struct* sapi_headers TSRMLS_DC); -#if ZEND_MODULE_API_NO >= ZEND_7_0_X_API_NO /* PHP 7.0+ */ typedef void (*nr_php_execute_internal_function_t)( zend_execute_data* execute_data, zval* return_value); -#elif ZEND_MODULE_API_NO >= ZEND_5_5_X_API_NO -typedef void (*nr_php_execute_internal_function_t)( - zend_execute_data* execute_data, - zend_fcall_info* fci, - int return_value_used TSRMLS_DC); -#else -typedef void (*nr_php_execute_internal_function_t)( - zend_execute_data* execute_data, - int return_value_used TSRMLS_DC); -#endif typedef struct _nr_php_ini_attribute_config_t { nrinibool_t enabled; @@ -449,10 +389,6 @@ size_t drupal_http_request_depth; /* The current depth of drupal_http_request() && !defined OVERWRITE_ZEND_EXECUTE_DATA nr_segment_t* drupal_http_request_segment; #endif -int symfony1_in_dispatch; /* Whether we are currently within a - sfFrontWebController::dispatch() frame */ -int symfony1_in_error404; /* Whether we are currently within a - sfError404Exception::printStackTrace() frame */ #if ZEND_MODULE_API_NO >= ZEND_8_0_X_API_NO \ && !defined OVERWRITE_ZEND_EXECUTE_DATA diff --git a/agent/php_nrini.c b/agent/php_nrini.c index 6cddef5b2..d586a2bf3 100644 --- a/agent/php_nrini.c +++ b/agent/php_nrini.c @@ -279,21 +279,12 @@ static nr_status_t nr_strtoi(int* val_p, const char* str, int base) { return NR_SUCCESS; } -#ifdef PHP7 #define PHP_INI_ENTRY_NAME(ie) (ie)->name->val #define PHP_INI_ENTRY_NAME_LEN(ie) (ie)->name->len + 1 #define PHP_INI_ENTRY_ORIG_VALUE(ie) (ie)->orig_value->val #define PHP_INI_ENTRY_ORIG_VALUE_LEN(ie) (ie)->orig_value->len #define PHP_INI_ENTRY_VALUE(ie) (ie)->value->val #define PHP_INI_ENTRY_VALUE_LEN(ie) (ie)->value->len -#else -#define PHP_INI_ENTRY_NAME(ie) (ie)->name -#define PHP_INI_ENTRY_NAME_LEN(ie) (ie)->name_length -#define PHP_INI_ENTRY_ORIG_VALUE(ie) (ie)->orig_value -#define PHP_INI_ENTRY_ORIG_VALUE_LEN(ie) (ie)->orig_value_length -#define PHP_INI_ENTRY_VALUE(ie) (ie)->value -#define PHP_INI_ENTRY_VALUE_LEN(ie) (ie)->value_length -#endif /* * Next we declare some custom display functions for producing more neatly @@ -417,13 +408,8 @@ static PHP_INI_DISP(nr_framework_dh) { * Now begin the modify handlers. Firstly, we shall define some compatibility * macros. */ -#ifdef PHP7 #define NEW_VALUE new_value->val #define NEW_VALUE_LEN new_value->len -#else -#define NEW_VALUE new_value -#define NEW_VALUE_LEN new_value_length -#endif /* PHP7 */ /* * On PHP 5, the arguments to the modify handlers are: @@ -3527,7 +3513,6 @@ nrobj_t* nr_php_app_settings(void) { } int nr_php_ini_setting_is_set_by_user(const char* name) { -#ifdef PHP7 int found; zend_string* zs; @@ -3540,24 +3525,4 @@ int nr_php_ini_setting_is_set_by_user(const char* name) { zend_string_free(zs); return found; -#else - int zend_rv; - uint name_length; - zval default_value; - - if (0 == name) { - return 0; - } - - name_length = nr_strlen(name) + 1; - - nr_memset(&default_value, 0, sizeof(default_value)); - - zend_rv = zend_get_configuration_directive(name, name_length, &default_value); - if (SUCCESS == zend_rv) { - return 1; - } else { - return 0; - } -#endif /* PHP7 */ } diff --git a/agent/php_output.c b/agent/php_output.c index b09543800..4f0ee2115 100644 --- a/agent/php_output.c +++ b/agent/php_output.c @@ -38,12 +38,7 @@ */ int nr_php_output_has_content(int flags) { -#if ZEND_MODULE_API_NO >= ZEND_5_4_X_API_NO return !(flags & PHP_OUTPUT_HANDLER_CLEAN); -#else - (void)flags; - return 1; -#endif /* PHP >= 5.4 */ } void nr_php_output_install_handler(const char* name, @@ -63,32 +58,12 @@ void nr_php_output_install_handler(const char* name, * On PHP 5.3, php_ob_set_internal_handler doesn't check for duplicate * handlers, so we check with php_ob_handler_used. */ -#if ZEND_MODULE_API_NO >= ZEND_5_4_X_API_NO - { - int flags = PHP_OUTPUT_HANDLER_STDFLAGS; - size_t chunk_size = 40960; - int name_len = nr_strlen(name); + int flags = PHP_OUTPUT_HANDLER_STDFLAGS; + size_t chunk_size = 40960; + int name_len = nr_strlen(name); - php_output_start_internal(name, name_len, handler, chunk_size, - flags TSRMLS_CC); - } -#else /* PHP < 5.4 */ - /* Everything else before it */ - { - zend_bool erase = 1; - uint buffer_size = 40960; - char name_duplicate[256]; - - /* Copy the name onto the stack to avoid const warnings. */ - name_duplicate[0] = '\0'; - snprintf(name_duplicate, sizeof(name_duplicate), "%s", name); - - if (!php_ob_handler_used(name_duplicate TSRMLS_CC)) { - php_ob_set_internal_handler(handler, buffer_size, name_duplicate, - erase TSRMLS_CC); - } - } -#endif + php_output_start_internal(name, name_len, handler, chunk_size, + flags TSRMLS_CC); } int nr_php_output_is_end(int flags) { diff --git a/agent/php_pdo.c b/agent/php_pdo.c index a34a8e839..d850ffa82 100644 --- a/agent/php_pdo.c +++ b/agent/php_pdo.c @@ -130,11 +130,7 @@ int nr_php_pdo_rebind_apply_parameter(struct pdo_bound_param_data* param, zval* type = nr_php_zval_alloc(); zval* retval = NULL; -#if ZEND_MODULE_API_NO >= ZEND_7_0_X_API_NO /* PHP 7.0+ */ value = ¶m->parameter; -#else - value = param->parameter; -#endif /* PHP 7.0+ */ if (nr_php_zend_hash_key_is_string(hash_key)) { /* diff --git a/agent/php_pdo_private.h b/agent/php_pdo_private.h index faa87ce0c..85e81d4f0 100644 --- a/agent/php_pdo_private.h +++ b/agent/php_pdo_private.h @@ -118,11 +118,7 @@ extern int nr_php_pdo_rebind_apply_parameter(struct pdo_bound_param_data* param, */ static inline pdo_dbh_t* nr_php_pdo_get_database_object_internal( zval* dbh TSRMLS_DC) { -#ifdef PHP7 return Z_PDO_DBH_P(dbh); -#else - return (pdo_dbh_t*)zend_object_store_get_object(dbh TSRMLS_CC); -#endif /* PHP7 */ } /* @@ -138,11 +134,7 @@ static inline pdo_dbh_t* nr_php_pdo_get_database_object_internal( */ static inline pdo_stmt_t* nr_php_pdo_get_statement_object_internal( zval* stmt TSRMLS_DC) { -#ifdef PHP7 return Z_PDO_STMT_P(stmt); -#else - return (pdo_stmt_t*)zend_object_store_get_object(stmt TSRMLS_CC); -#endif /* PHP7 */ } /* diff --git a/agent/php_rshutdown.c b/agent/php_rshutdown.c index 24b1311e4..a4165ed7a 100644 --- a/agent/php_rshutdown.c +++ b/agent/php_rshutdown.c @@ -80,7 +80,6 @@ int nr_php_post_deactivate(void) { nrl_verbosedebug(NRL_INIT, "post-deactivate processing started"); -#if ZEND_MODULE_API_NO >= ZEND_7_0_X_API_NO /* * PHP 7 has a singleton trampoline op array that is used for the life of an * executor (which, in non-ZTS mode, is the life of the process). We need to @@ -91,7 +90,6 @@ int nr_php_post_deactivate(void) { */ #if ZEND_MODULE_API_NO < ZEND_7_4_X_API_NO EG(trampoline).op_array.reserved[NR_PHP_PROCESS_GLOBALS(zend_offset)] = NULL; -#endif /* PHP7 */ #endif /* * End the txn before we clean up all the globals it might need. diff --git a/agent/php_stack.c b/agent/php_stack.c index 74c3b1002..82b7b81bb 100644 --- a/agent/php_stack.c +++ b/agent/php_stack.c @@ -13,10 +13,7 @@ #include "util_strings.h" #include "util_syscalls.h" #include "util_logging.h" - -#ifdef PHP7 #include "zend_generators.h" -#endif static int nr_php_stack_iterator(zval* frame, nrobj_t* arr, @@ -153,12 +150,7 @@ zval* nr_php_backtrace(TSRMLS_D) { trace = nr_php_zval_alloc(); -#if ZEND_MODULE_API_NO >= ZEND_5_4_X_API_NO zend_fetch_debug_backtrace(trace, skip_last, options, limit TSRMLS_CC); -#else /* PHP < 5.4 */ - zend_fetch_debug_backtrace(trace, skip_last, options TSRMLS_CC); - (void)limit; -#endif return trace; } @@ -185,8 +177,6 @@ typedef struct _nr_php_frame_info_t { int decl_line; /* starting line number of the declaration site */ } nr_php_frame_info_t; -#ifdef PHP7 - static int nr_php_is_include_or_eval(zend_execute_data* ex) { zend_execute_data* prev; @@ -336,106 +326,6 @@ static void nr_php_frame_info(nr_php_frame_info_t* info, } } -#else /* PHP7 */ - -static void nr_php_frame_info(nr_php_frame_info_t* info, - zend_execute_data* ex TSRMLS_DC) { - zend_function* func; - - info->class_name = ""; - info->call_type = ""; - info->func_name = ""; - info->file = ""; - info->line = 0; - info->decl_file = ""; - info->decl_line = 0; - - if (NULL == ex) { - return; - } - - info->func_name = "unknown"; - func = ex->function_state.function; - - if (NULL == func) { - return; - } - - if (ex->op_array && ex->opline) { - info->file = ex->op_array->filename; - info->line = ex->opline->lineno; - } - - /* - * For closures, gather the file and line where the closure was declared - * in addition to the file and line of the call site. - */ - if ((ZEND_USER_FUNCTION == func->type) - && (func->common.fn_flags & ZEND_ACC_CLOSURE)) { - info->decl_file = func->op_array.filename; - info->decl_line = func->op_array.line_start; - } - - if (func->common.function_name) { - info->func_name = func->common.function_name; - - if (ex->object) { - info->call_type = "->"; - - /* - * Ignore the scope for closures, it's redundant given the file and - * line where the closure was declared. - */ - if (0 == (func->common.fn_flags & ZEND_ACC_CLOSURE)) { - if (func->common.scope) { - info->class_name = func->common.scope->name; - } else { - /* - * A method was invoked, but the runtime did not set the scope? - * It's unclear how/when this can happen, but the Zend Engine handles - * this case, so handle it here too. - */ - if (Z_OBJCE_P(ex->object) && Z_OBJCE_P(ex->object)->name) { - info->class_name = Z_OBJCE_P(ex->object)->name; - } else { - info->class_name = "???"; - } - } - } - } else if (func->common.scope) { - info->call_type = "::"; - info->class_name = func->common.scope->name; - } - - return; - } - - if (ex->opline && ex->opline->opcode == ZEND_INCLUDE_OR_EVAL) { - switch (ex->opline->extended_value) { - case ZEND_EVAL: - info->func_name = "eval"; - break; - case ZEND_INCLUDE: - info->func_name = "include"; - break; - case ZEND_REQUIRE: - info->func_name = "require"; - break; - case ZEND_INCLUDE_ONCE: - info->func_name = "include_once"; - break; - case ZEND_REQUIRE_ONCE: - info->func_name = "require_once"; - break; - default: - info->func_name = "ZEND_INCLUDE_OR_EVAL"; - break; - } - } -} - -#endif /* PHP7 */ - /* Output format: @@ -455,9 +345,7 @@ void nr_php_backtrace_fd(int fd, int limit TSRMLS_DC) { ex = EG(current_execute_data); while (ex) { -#ifdef PHP7 ex = zend_generator_check_placeholder_frame(ex); -#endif nr_php_frame_info(&frame, ex TSRMLS_CC); diff --git a/agent/php_txn.c b/agent/php_txn.c index 32fd8c90e..4b92f40c6 100644 --- a/agent/php_txn.c +++ b/agent/php_txn.c @@ -64,11 +64,7 @@ static void nr_php_set_initial_path(nrtxn_t* txn TSRMLS_DC) { return; } -#ifdef PHP7 server = &PG(http_globals)[TRACK_VARS_SERVER]; -#else - server = PG(http_globals)[TRACK_VARS_SERVER]; -#endif /* PHP7 */ if (nr_php_is_zval_valid_array(server)) { if ((NR_PHP_PROCESS_GLOBALS(special_flags).enable_path_translated) @@ -89,17 +85,10 @@ static void nr_php_set_initial_path(nrtxn_t* txn TSRMLS_DC) { "SCRIPT_NAME"))) { whence = "WT_IS_FILENAME & SCRIPT_NAME"; /* uri has a zval with the name of the script */ -#ifdef PHP7 } else if (CG(active_op_array)) { whence = "WT_IS_FILENAME & op_array"; suri = nr_php_op_array_file_name(CG(active_op_array)); /* suri has a char* to the name of the script */ -#else - } else if (EG(active_op_array)) { - whence = "WT_IS_FILENAME & op_array"; - suri = nr_php_op_array_file_name(EG(active_op_array)); -/* suri has a char* to the name of the script */ -#endif /* PHP7 */ } if ((NULL == uri) && (NULL == suri)) { @@ -213,7 +202,6 @@ static int nr_php_capture_request_parameter(zval* element, nr_double_to_str(datastr, sizeof(datastr), Z_DVAL_P(element)); break; -#ifdef PHP7 case IS_TRUE: nr_strcpy(datastr, "true"); break; @@ -221,21 +209,14 @@ static int nr_php_capture_request_parameter(zval* element, case IS_FALSE: nr_strcpy(datastr, "false"); break; -#else - case IS_BOOL: - nr_strcpy(datastr, Z_BVAL_P(element) ? "true" : "false"); - break; -#endif /* PHP7 */ case IS_STRING: { nr_string_len_t len; -#ifdef PHP7 if (NULL == Z_STR_P(element)) { nr_strcpy(datastr, "[invalid string]"); break; } -#endif /* PHP7 */ len = Z_STRLEN_P(element) < NR_MAX_STRLEN ? Z_STRLEN_P(element) : NR_MAX_STRLEN - 1; @@ -266,11 +247,7 @@ static int nr_php_capture_request_parameter(zval* element, * IS_CONSTANT_AST. For the purposes of this function, it can be * considered the same thing. */ -#if ZEND_MODULE_API_NO >= ZEND_5_6_X_API_NO case IS_CONSTANT_AST: -#else - case IS_CONSTANT_ARRAY: -#endif /* PHP >= 5.6 */ nr_strcpy(datastr, "[constants]"); break; diff --git a/agent/php_vm.c b/agent/php_vm.c index 982d0aff1..10029131a 100644 --- a/agent/php_vm.c +++ b/agent/php_vm.c @@ -11,9 +11,9 @@ /* * If we are using OAPI, we do not want to modify any opcodes */ -#if ZEND_MODULE_API_NO >= ZEND_7_0_X_API_NO \ +#if ZEND_MODULE_API_NO >= ZEND_7_2_X_API_NO \ && !(ZEND_MODULE_API_NO >= ZEND_8_0_X_API_NO \ - && !defined OVERWRITE_ZEND_EXECUTE_DATA) /* PHP 7.0+ and not OAPI */ + && !defined OVERWRITE_ZEND_EXECUTE_DATA) /* PHP 7.2+ and not OAPI */ /* * An entry in the previous_opcode_handlers table. diff --git a/agent/php_wrapper.c b/agent/php_wrapper.c index 6631c06d2..30938173a 100644 --- a/agent/php_wrapper.c +++ b/agent/php_wrapper.c @@ -209,44 +209,21 @@ nruserfn_t* nr_php_wrap_generic_callable(zval* callable, } inline static void release_zval(zval** ppzv) { -#ifdef PHP7 nr_php_zval_free(ppzv); -#else - if (NULL == ppzv) { - return; - } - if (NULL == *ppzv) { - return; - } - - zval_ptr_dtor(ppzv); - *ppzv = NULL; -#endif /* PHP7 */ } zval* nr_php_arg_get(ssize_t index, NR_EXECUTE_PROTO TSRMLS_DC) { zval* arg; NR_UNUSED_FUNC_RETURN_VALUE; -#ifdef PHP7 - { - zval* orig; + zval* orig; - arg = NULL; - orig = nr_php_get_user_func_arg((zend_uint)index, NR_EXECUTE_ORIG_ARGS); + arg = NULL; + orig = nr_php_get_user_func_arg((zend_uint)index, NR_EXECUTE_ORIG_ARGS); - if (orig) { - arg = nr_php_zval_alloc(); - ZVAL_DUP(arg, orig); - } + if (orig) { + arg = nr_php_zval_alloc(); + ZVAL_DUP(arg, orig); } -#else - arg = nr_php_get_user_func_arg((zend_uint)index, - NR_EXECUTE_ORIG_ARGS TSRMLS_CC); - - if (arg) { - Z_ADDREF_P(arg); - } -#endif /* PHP7 */ return arg; } @@ -360,15 +337,8 @@ zval* nr_php_scope_get(NR_EXECUTE_PROTO TSRMLS_DC) { return NULL; } -#ifdef PHP7 this_copy = nr_php_zval_alloc(); ZVAL_DUP(this_copy, this_obj); -#else - NR_UNUSED_SPECIALFN; - - this_copy = this_obj; - Z_ADDREF_P(this_copy); -#endif return this_copy; } @@ -378,13 +348,9 @@ void nr_php_scope_release(zval** ppzv) { } zval** nr_php_get_return_value_ptr(TSRMLS_D) { -#ifdef PHP7 if (NULL == EG(current_execute_data)) { return NULL; } return &EG(current_execute_data)->return_value; -#else - return EG(return_value_ptr_ptr); -#endif /* PHP7 */ } diff --git a/agent/php_zval.h b/agent/php_zval.h index ccfb97a0f..9d50afc03 100644 --- a/agent/php_zval.h +++ b/agent/php_zval.h @@ -60,13 +60,8 @@ inline static zval* nr_php_zval_alloc(void) { zval* zv = NULL; -#if ZEND_MODULE_API_NO >= ZEND_7_0_X_API_NO /* PHP 7.0+ */ zv = (zval*)emalloc(sizeof(zval)); ZVAL_UNDEF(zv); -#else - MAKE_STD_ZVAL(zv); - ZVAL_NULL(zv); -#endif return zv; } @@ -82,14 +77,9 @@ inline static zval* nr_php_zval_alloc(void) { */ inline static void nr_php_zval_free(zval** zv) { if ((NULL != zv) && (NULL != *zv)) { -#ifdef PHP7 zval_ptr_dtor(*zv); efree(*zv); *zv = NULL; -#else - zval_ptr_dtor(zv); - *zv = NULL; -#endif } } @@ -116,15 +106,9 @@ static inline int nr_php_is_zval_valid_bool(const zval* z) { return 0; } -#ifdef PHP7 if ((IS_TRUE == Z_TYPE_P(z)) || (IS_FALSE == Z_TYPE_P(z))) { return 1; } -#else - if (IS_BOOL == Z_TYPE_P(z)) { - return 1; - } -#endif /* PHP7 */ return 0; } @@ -134,11 +118,9 @@ static inline int nr_php_is_zval_valid_resource(const zval* z) { return 0; } -#ifdef PHP7 if (NULL == Z_RES_P(z)) { return 0; } -#endif /* PHP7 */ return 1; } @@ -156,15 +138,9 @@ static inline int nr_php_is_zval_valid_string(const zval* z) { return 0; } -#ifdef PHP7 if (NULL == Z_STR_P(z)) { return 0; } -#else - if (Z_STRLEN_P(z) < 0) { - return 0; - } -#endif /* PHP7 */ return 1; } @@ -190,7 +166,6 @@ static inline int nr_php_is_zval_valid_object(const zval* z) { return 0; } -#ifdef PHP7 /* * It's possible in PHP 7 to have a zval with type IS_OBJECT but a NULL * zend_object pointer. @@ -198,7 +173,6 @@ static inline int nr_php_is_zval_valid_object(const zval* z) { if (NULL == Z_OBJ_P(z)) { return 0; } -#endif /* PHP7 */ return 1; } @@ -241,12 +215,8 @@ static inline int nr_php_is_zval_valid_scalar(const zval* z) { } switch (Z_TYPE_P(z)) { -#ifdef PHP7 case IS_TRUE: case IS_FALSE: -#else - case IS_BOOL: -#endif case IS_LONG: case IS_DOUBLE: return 1; @@ -293,11 +263,7 @@ static inline long nr_php_zval_resource_id(const zval* zv) { if (!nr_php_is_zval_valid_resource(zv)) { return 0; } -#if ZEND_MODULE_API_NO >= ZEND_7_0_X_API_NO /* PHP 7.0+ */ return Z_RES_P(zv)->handle; -#else - return Z_LVAL_P(zv); -#endif /* PHP7 */ } /* @@ -332,19 +298,11 @@ static inline long nr_php_zval_object_id(const zval* zv) { static inline void nr_php_zval_str_len(zval* zv, const char* str, nr_string_len_t len) { -#ifdef PHP7 ZVAL_STRINGL(zv, str, len); -#else - ZVAL_STRINGL(zv, str, len, 1); -#endif /* PHP7 */ } static inline void nr_php_zval_str(zval* zv, const char* str) { -#ifdef PHP7 nr_php_zval_str_len(zv, str, nr_strlen(str)); -#else - ZVAL_STRING(zv, str, 1); -#endif /* PHP7 */ } #if defined(__clang__) || (__GNUC__ > 4) \ @@ -362,11 +320,7 @@ static inline void nr_php_zval_bool(zval* zv, int b) { * that function will then set the value). */ static inline void nr_php_zval_prepare_out_arg(zval* zv) { -#if ZEND_MODULE_API_NO >= ZEND_7_0_X_API_NO /* PHP 7.0+ */ ZVAL_NEW_REF(zv, &EG(uninitialized_zval)); -#else - ZVAL_NULL(zv); -#endif } /* }}} */ @@ -382,7 +336,6 @@ static inline void nr_php_zval_prepare_out_arg(zval* zv) { * Note that you will need to use nr_php_zval_real_value() (below) if you don't * want to do this in place. */ -#if ZEND_MODULE_API_NO >= ZEND_7_0_X_API_NO /* PHP 7.0+ */ #define nr_php_zval_unwrap(zv) ZVAL_DEREF(zv) /* @@ -403,17 +356,6 @@ static inline zval* nr_php_zval_real_value(zval* zv) { } return zv; } -#else -#define nr_php_zval_unwrap(zv) (void)(zv) - -static inline zval* nr_php_zval_real_value(zval* zv) { - /* - * As PHP 5 doesn't have a concept of typed reference zvals, this function - * should just return the input value. - */ - return zv; -} -#endif /* PHP7 */ /* }}} */ diff --git a/agent/scripts/newrelic.ini.template b/agent/scripts/newrelic.ini.template index cecc1486c..945b2672e 100644 --- a/agent/scripts/newrelic.ini.template +++ b/agent/scripts/newrelic.ini.template @@ -637,12 +637,11 @@ newrelic.daemon.logfile = "/var/log/newrelic/newrelic-daemon.log" ; encounter a failure with framework autodetection. ; ; Must be one of the following values: -; cakephp, codeigniter, drupal, drupal8, joomla, kohana, laravel, -; magento, magento2, mediawiki, slim, symfony2, symfony4, -; wordpress, yii, yii2, zend, zend2, no_framework +; cakephp, codeigniter, drupal, drupal8, joomla, laravel, +; magento, magento2, mediawiki, slim, symfony4, +; wordpress, yii, yii2, zend3, no_framework ; -; Note that "drupal" covers only Drupal 6 and 7 and "symfony2" -; now only supports Symfony 3.x. +; Note that "drupal" covers only Drupal 6 and 7. ; ;newrelic.framework = "" diff --git a/agent/tests/test_agent.c b/agent/tests/test_agent.c index 53b3495ee..548fc6e7a 100644 --- a/agent/tests/test_agent.c +++ b/agent/tests/test_agent.c @@ -562,8 +562,6 @@ static void test_default_address() { #endif } -#if ZEND_MODULE_API_NO >= ZEND_7_0_X_API_NO /* PHP7+ */ - static void test_nr_php_zend_function_lineno() { zend_function func = {0}; @@ -589,12 +587,7 @@ static void test_nr_php_zend_function_lineno() { nr_php_zend_function_lineno(&func)); } -#endif /* PHP 7+ */ - void test_main(void* p NRUNUSED) { -#if defined(ZTS) && !defined(PHP7) - void*** tsrm_ls = NULL; -#endif /* ZTS && !PHP7 */ tlib_php_engine_create("" PTSRMLS_CC); @@ -614,11 +607,7 @@ void test_main(void* p NRUNUSED) { * Tests that require state and will handle their own request startup and * shutdown. */ - -#if ZEND_MODULE_API_NO >= ZEND_7_0_X_API_NO /* PHP7+ */ test_nr_php_zend_function_lineno(); -#endif /* PHP 7+ */ - test_function_debug_name(TSRMLS_C); test_get_zval_object_property(TSRMLS_C); test_get_zval_object_property_with_class(TSRMLS_C); diff --git a/agent/tests/test_api_datastore.c b/agent/tests/test_api_datastore.c index a3a5c0368..1bdfb823c 100644 --- a/agent/tests/test_api_datastore.c +++ b/agent/tests/test_api_datastore.c @@ -131,9 +131,6 @@ static void test_validate(TSRMLS_D) { } void test_main(void* p NRUNUSED) { -#if defined(ZTS) && !defined(PHP7) - void*** tsrm_ls = NULL; -#endif /* ZTS && !PHP7 */ tlib_php_engine_create("" PTSRMLS_CC); diff --git a/agent/tests/test_api_distributed_trace.c b/agent/tests/test_api_distributed_trace.c index 51aab79ee..86fe74fda 100644 --- a/agent/tests/test_api_distributed_trace.c +++ b/agent/tests/test_api_distributed_trace.c @@ -35,9 +35,6 @@ static void test_accept_distributed_trace_payload() { } void test_main(void* p NRUNUSED) { -#if defined(ZTS) && !defined(PHP7) - void*** tsrm_ls = NULL; -#endif /* ZTS && !PHP7 */ tlib_php_engine_create("" PTSRMLS_CC); diff --git a/agent/tests/test_api_internal.c b/agent/tests/test_api_internal.c index 70a7752f8..1ab3cef87 100644 --- a/agent/tests/test_api_internal.c +++ b/agent/tests/test_api_internal.c @@ -150,9 +150,6 @@ static void test_segments(TSRMLS_D) { } void test_main(void* p NRUNUSED) { -#if defined(ZTS) && !defined(PHP7) - void*** tsrm_ls = NULL; -#endif /* ZTS && !PHP7 */ tlib_php_engine_create("" PTSRMLS_CC); diff --git a/agent/tests/test_api_metadata_dt_disabled.c b/agent/tests/test_api_metadata_dt_disabled.c index 33003be35..cf41e4962 100644 --- a/agent/tests/test_api_metadata_dt_disabled.c +++ b/agent/tests/test_api_metadata_dt_disabled.c @@ -86,9 +86,6 @@ static void test_get_trace_metadata_when_dt_disabled(TSRMLS_D) { } void test_main(void* p NRUNUSED) { -#if defined(ZTS) && !defined(PHP7) - void*** tsrm_ls = NULL; -#endif /* ZTS && !PHP7 */ tlib_php_engine_create( "newrelic.distributed_tracing_enabled = false\n" PTSRMLS_CC); diff --git a/agent/tests/test_api_metadata_dt_enabled.c b/agent/tests/test_api_metadata_dt_enabled.c index 218387c55..5b047060e 100644 --- a/agent/tests/test_api_metadata_dt_enabled.c +++ b/agent/tests/test_api_metadata_dt_enabled.c @@ -88,9 +88,6 @@ static void test_get_trace_metadata_when_dt_enabled(TSRMLS_D) { } void test_main(void* p NRUNUSED) { -#if defined(ZTS) && !defined(PHP7) - void*** tsrm_ls = NULL; -#endif /* ZTS && !PHP7 */ tlib_php_engine_create("newrelic.distributed_tracing_enabled = true\n" PTSRMLS_CC); diff --git a/agent/tests/test_call.c b/agent/tests/test_call.c index d3f449b67..458bf1508 100644 --- a/agent/tests/test_call.c +++ b/agent/tests/test_call.c @@ -78,7 +78,6 @@ static void test_callable(TSRMLS_D) { nr_php_zval_free(&callable); nr_php_zval_free(&retval); -#ifdef PHP7 callable = tlib_php_request_eval_expr( "new class { function __invoke() { return 42; } }" TSRMLS_CC); retval = nr_php_call_callable(callable); @@ -89,7 +88,6 @@ static void test_callable(TSRMLS_D) { (long)Z_LVAL_P(retval)); nr_php_zval_free(&callable); nr_php_zval_free(&retval); -#endif /* PHP7 */ /* * Test : With parameters. @@ -150,7 +148,6 @@ static void test_callable(TSRMLS_D) { nr_php_zval_free(&callable); nr_php_zval_free(&retval); -#ifdef PHP7 callable = tlib_php_request_eval_expr( "new class { function __invoke($n) { return square($n); } }" TSRMLS_CC); retval = nr_php_call_callable(callable, param); @@ -161,16 +158,12 @@ static void test_callable(TSRMLS_D) { (long)Z_LVAL_P(retval)); nr_php_zval_free(&callable); nr_php_zval_free(&retval); -#endif /* PHP7 */ nr_php_zval_free(¶m); tlib_php_request_end(); } void test_main(void* p NRUNUSED) { -#if defined(ZTS) && !defined(PHP7) - void*** tsrm_ls = NULL; -#endif /* ZTS && !PHP7 */ tlib_php_engine_create("" PTSRMLS_CC); diff --git a/agent/tests/test_curl.c b/agent/tests/test_curl.c index 6ef796c49..2c20439c9 100644 --- a/agent/tests/test_curl.c +++ b/agent/tests/test_curl.c @@ -106,9 +106,6 @@ static void test_curl_exec(TSRMLS_D) { } void test_main(void* p NRUNUSED) { -#if defined(ZTS) && !defined(PHP7) - void*** tsrm_ls = NULL; -#endif /* ZTS && !PHP7 */ tlib_php_engine_create("" PTSRMLS_CC); diff --git a/agent/tests/test_curl_md.c b/agent/tests/test_curl_md.c index 0008d5cb7..9ef7482a8 100644 --- a/agent/tests/test_curl_md.c +++ b/agent/tests/test_curl_md.c @@ -456,9 +456,6 @@ static void test_curl_multi_md_initialized(TSRMLS_D) { } void test_main(void* p NRUNUSED) { -#if defined(ZTS) && !defined(PHP7) - void*** tsrm_ls = NULL; -#endif /* ZTS && !PHP7 */ tlib_php_engine_create("" PTSRMLS_CC); diff --git a/agent/tests/test_datastore.c b/agent/tests/test_datastore.c index b998cc2bf..421127293 100644 --- a/agent/tests/test_datastore.c +++ b/agent/tests/test_datastore.c @@ -191,9 +191,6 @@ static void test_make_key(TSRMLS_D) { } void test_main(void* p NRUNUSED) { -#if defined(ZTS) && !defined(PHP7) - void*** tsrm_ls = NULL; -#endif /* ZTS && !PHP7 */ tlib_php_engine_create("" PTSRMLS_CC); diff --git a/agent/tests/test_fw_codeigniter.c b/agent/tests/test_fw_codeigniter.c index 9d6562885..553dc197e 100644 --- a/agent/tests/test_fw_codeigniter.c +++ b/agent/tests/test_fw_codeigniter.c @@ -27,7 +27,6 @@ static void invoke_cufa(TSRMLS_D) { } static void test_get_topmost_user_op_array(TSRMLS_D) { -#ifdef PHP7 /* * First, we'll test this with call_user_func_array() inlining. */ @@ -43,19 +42,11 @@ static void test_get_topmost_user_op_array(TSRMLS_D) { CG(compiler_options) |= ZEND_COMPILE_NO_BUILTINS; invoke_cufa(TSRMLS_C); tlib_php_request_end(); -#else - tlib_php_request_start(); - invoke_cufa(TSRMLS_C); - tlib_php_request_end(); -#endif /* PHP7 */ } tlib_parallel_info_t parallel_info = {.suggested_nthreads = 1, .state_size = 0}; void test_main(void* p NRUNUSED) { -#if defined(ZTS) && !defined(PHP7) - void*** tsrm_ls = NULL; -#endif /* ZTS && !PHP7 */ tlib_php_engine_create("" PTSRMLS_CC); test_get_topmost_user_op_array(TSRMLS_C); diff --git a/agent/tests/test_fw_drupal.c b/agent/tests/test_fw_drupal.c index f2f383110..81295db9e 100644 --- a/agent/tests/test_fw_drupal.c +++ b/agent/tests/test_fw_drupal.c @@ -370,10 +370,6 @@ static void test_drupal_http_request_drupal_6(TSRMLS_D) { } void test_main(void* p NRUNUSED) { - -#if defined(ZTS) && !defined(PHP7) - void*** tsrm_ls = NULL; -#endif /* ZTS && !PHP7 */ tlib_php_engine_create("" PTSRMLS_CC); test_module_name(); test_drupal_headers_add(TSRMLS_C); diff --git a/agent/tests/test_fw_wordpress.c b/agent/tests/test_fw_wordpress.c index 03b3fce85..69244767e 100644 --- a/agent/tests/test_fw_wordpress.c +++ b/agent/tests/test_fw_wordpress.c @@ -124,9 +124,6 @@ static void test_wordpress_plugin_matcher() { } void test_main(void* p NRUNUSED) { -#if defined(ZTS) && !defined(PHP7) - void*** tsrm_ls = NULL; -#endif /* ZTS && !PHP7 */ tlib_php_engine_create("" PTSRMLS_CC); test_wordpress_plugin_matcher(); test_wordpress_core_matcher(); diff --git a/agent/tests/test_hash.c b/agent/tests/test_hash.c index 4a56bd5ac..f0a1839f3 100644 --- a/agent/tests/test_hash.c +++ b/agent/tests/test_hash.c @@ -43,9 +43,6 @@ static void test_del(void) { } void test_main(void* p NRUNUSED) { -#if defined(ZTS) && !defined(PHP7) - void*** tsrm_ls = NULL; -#endif /* ZTS && !PHP7 */ tlib_php_engine_create("" PTSRMLS_CC); tlib_php_request_start(); diff --git a/agent/tests/test_internal_instrument.c b/agent/tests/test_internal_instrument.c index 4215c80cc..9d9b6f3d7 100644 --- a/agent/tests/test_internal_instrument.c +++ b/agent/tests/test_internal_instrument.c @@ -106,9 +106,6 @@ static void test_cufa_indirect(TSRMLS_D) { } void test_main(void* p NRUNUSED) { -#if defined(ZTS) && !defined(PHP7) - void*** tsrm_ls = NULL; -#endif /* ZTS && !PHP7 */ tlib_php_engine_create("" PTSRMLS_CC); diff --git a/agent/tests/test_lib_aws_sdk_php.c b/agent/tests/test_lib_aws_sdk_php.c index 4077e9d0c..ee0989168 100644 --- a/agent/tests/test_lib_aws_sdk_php.c +++ b/agent/tests/test_lib_aws_sdk_php.c @@ -419,8 +419,6 @@ static void test_nr_lib_aws_sdk_php_sqs_parse_queueurl() { } #endif /* PHP 8.1+ */ -#if ZEND_MODULE_API_NO > ZEND_7_1_X_API_NO - static void declare_aws_sdk_class(const char* ns, const char* klass, const char* sdk_version) { @@ -1119,6 +1117,3 @@ void test_main(void* p NRUNUSED) { test_nr_lib_aws_sdk_php_dynamodb_set_params(); #endif /* PHP 8.1+ */ } -#else -void test_main(void* p NRUNUSED) {} -#endif diff --git a/agent/tests/test_lib_php_amqplib.c b/agent/tests/test_lib_php_amqplib.c index c0261cfc2..d73405c2a 100644 --- a/agent/tests/test_lib_php_amqplib.c +++ b/agent/tests/test_lib_php_amqplib.c @@ -12,8 +12,6 @@ tlib_parallel_info_t parallel_info = {.suggested_nthreads = -1, .state_size = 0}; -#if ZEND_MODULE_API_NO > ZEND_7_1_X_API_NO - static void declare_php_amqplib_package_class(const char* ns, const char* klass, const char* package_version) { @@ -139,6 +137,3 @@ void test_main(void* p NRUNUSED) { test_nr_lib_php_amqplib_handle_version(); tlib_php_engine_destroy(); } -#else -void test_main(void* p NRUNUSED) {} -#endif diff --git a/agent/tests/test_mongodb.c b/agent/tests/test_mongodb.c index cbfeac1c8..e9d991555 100644 --- a/agent/tests/test_mongodb.c +++ b/agent/tests/test_mongodb.c @@ -15,7 +15,6 @@ tlib_parallel_info_t parallel_info /* * The mongodb extension requires PHP 5.4. */ -#if ZEND_MODULE_API_NO >= ZEND_5_4_X_API_NO static char* system_host_name; @@ -192,9 +191,6 @@ static void test_get_host_and_port_path_or_id_individually(TSRMLS_D) { } void test_main(void* p NRUNUSED) { -#if defined(ZTS) && !defined(PHP7) - void*** tsrm_ls = NULL; -#endif /* ZTS && !PHP7 */ system_host_name = nr_system_get_hostname(); @@ -207,9 +203,3 @@ void test_main(void* p NRUNUSED) { nr_free(system_host_name); } - -#else - -void test_main(void* p NRUNUSED) {} - -#endif /* PHP >= 5.4 */ diff --git a/agent/tests/test_mysql.c b/agent/tests/test_mysql.c index 686c2a6dd..37345d510 100644 --- a/agent/tests/test_mysql.c +++ b/agent/tests/test_mysql.c @@ -355,9 +355,6 @@ static void test_create_datastore_instance() { } void test_main(void* p NRUNUSED) { -#if defined(ZTS) && !defined(PHP7) - void*** tsrm_ls = NULL; -#endif /* ZTS && !PHP7 */ system_host_name = nr_system_get_hostname(); tlib_php_engine_create("mysql.default_socket=" DEFAULT_SOCKET PTSRMLS_CC); diff --git a/agent/tests/test_mysqli.c b/agent/tests/test_mysqli.c index 1a75413d2..54a2c90e3 100644 --- a/agent/tests/test_mysqli.c +++ b/agent/tests/test_mysqli.c @@ -365,9 +365,6 @@ static void test_strip_persistent_prefix(void) { } void test_main(void* p NRUNUSED) { -#if defined(ZTS) && !defined(PHP7) - void*** tsrm_ls = NULL; -#endif /* ZTS && !PHP7 */ system_host_name = nr_system_get_hostname(); tlib_php_engine_create("mysqli.default_socket=" DEFAULT_SOCKET PTSRMLS_CC); diff --git a/agent/tests/test_output.c b/agent/tests/test_output.c index 8b16f941d..d062dd705 100644 --- a/agent/tests/test_output.c +++ b/agent/tests/test_output.c @@ -26,7 +26,6 @@ tlib_parallel_info_t parallel_info } while (0) static void test_output_flags(void) { -#if ZEND_MODULE_API_NO >= ZEND_5_4_X_API_NO test_output_flag_func("has content", nr_php_output_has_content, 1, PHP_OUTPUT_HANDLER_WRITE); test_output_flag_func("has content", nr_php_output_has_content, 1, @@ -62,31 +61,6 @@ static void test_output_flags(void) { test_output_flag_func("is start", nr_php_output_is_start, 0, PHP_OUTPUT_HANDLER_FINAL); test_output_flag_func("is start", nr_php_output_is_start, 1, INT_MAX); -#else /* PHP < 5.4 */ - test_output_flag_func("has content", nr_php_output_has_content, 1, - PHP_OUTPUT_HANDLER_START); - test_output_flag_func("has content", nr_php_output_has_content, 1, - PHP_OUTPUT_HANDLER_CONT); - test_output_flag_func("has content", nr_php_output_has_content, 1, - PHP_OUTPUT_HANDLER_END); - test_output_flag_func("has content", nr_php_output_has_content, 1, INT_MAX); - - test_output_flag_func("is end", nr_php_output_is_end, 0, - PHP_OUTPUT_HANDLER_START); - test_output_flag_func("is end", nr_php_output_is_end, 0, - PHP_OUTPUT_HANDLER_CONT); - test_output_flag_func("is end", nr_php_output_is_end, 1, - PHP_OUTPUT_HANDLER_END); - test_output_flag_func("is end", nr_php_output_is_end, 1, INT_MAX); - - test_output_flag_func("is start", nr_php_output_is_start, 1, - PHP_OUTPUT_HANDLER_START); - test_output_flag_func("is start", nr_php_output_is_start, 0, - PHP_OUTPUT_HANDLER_CONT); - test_output_flag_func("is start", nr_php_output_is_start, 0, - PHP_OUTPUT_HANDLER_END); - test_output_flag_func("is start", nr_php_output_is_start, 1, INT_MAX); -#endif /* PHP >= 5.4 */ } /* @@ -228,9 +202,6 @@ static void test_output_install_handler(TSRMLS_D) { } void test_main(void* p NRUNUSED) { -#if defined(ZTS) && !defined(PHP7) - void*** tsrm_ls = NULL; -#endif /* ZTS && !PHP7 */ tlib_php_engine_create("" PTSRMLS_CC); diff --git a/agent/tests/test_pdo.c b/agent/tests/test_pdo.c index 28f6ce8cf..73306f190 100644 --- a/agent/tests/test_pdo.c +++ b/agent/tests/test_pdo.c @@ -302,11 +302,9 @@ static void test_disable_persistence(TSRMLS_D) { "array(PDO::ATTR_PERSISTENT => false)" TSRMLS_CC); for (i = 0; bad_options[i]; i++) { -#ifdef PHP7 if (IS_UNDEF == Z_TYPE_P(bad_options[i])) { continue; } -#endif input = nr_php_zval_alloc(); @@ -358,9 +356,6 @@ static void test_disable_persistence(TSRMLS_D) { } void test_main(void* p NRUNUSED) { -#if defined(ZTS) && !defined(PHP7) - void*** tsrm_ls = NULL; -#endif /* ZTS && !PHP7 */ tlib_php_engine_create("" PTSRMLS_CC); diff --git a/agent/tests/test_pdo_mysql.c b/agent/tests/test_pdo_mysql.c index fec795199..65c03d718 100644 --- a/agent/tests/test_pdo_mysql.c +++ b/agent/tests/test_pdo_mysql.c @@ -213,9 +213,6 @@ static void test_create_datastore_instance(TSRMLS_D) { } void test_main(void* p NRUNUSED) { -#if defined(ZTS) && !defined(PHP7) - void*** tsrm_ls = NULL; -#endif /* ZTS && !PHP7 */ system_host_name = nr_system_get_hostname(); tlib_php_engine_create("pdo_mysql.default_socket=" DEFAULT_SOCKET PTSRMLS_CC); diff --git a/agent/tests/test_pdo_pgsql.c b/agent/tests/test_pdo_pgsql.c index 2a827883a..a2c636477 100644 --- a/agent/tests/test_pdo_pgsql.c +++ b/agent/tests/test_pdo_pgsql.c @@ -107,9 +107,6 @@ static void test_create_datastore_instance(TSRMLS_D) { } void test_main(void* p NRUNUSED) { -#if defined(ZTS) && !defined(PHP7) - void*** tsrm_ls = NULL; -#endif /* ZTS && !PHP7 */ system_host_name = nr_system_get_hostname(); tlib_php_engine_create("" PTSRMLS_CC); diff --git a/agent/tests/test_pgsql.c b/agent/tests/test_pgsql.c index 55bd79d32..c697308bc 100644 --- a/agent/tests/test_pgsql.c +++ b/agent/tests/test_pgsql.c @@ -280,9 +280,6 @@ static void test_create_datastore_instance() { } void test_main(void* p NRUNUSED) { -#if defined(ZTS) && !defined(PHP7) - void*** tsrm_ls = NULL; -#endif /* ZTS && !PHP7 */ system_host_name = nr_system_get_hostname(); tlib_php_engine_create("" PTSRMLS_CC); diff --git a/agent/tests/test_php_execute.c b/agent/tests/test_php_execute.c index de770bc7d..a14c06541 100644 --- a/agent/tests/test_php_execute.c +++ b/agent/tests/test_php_execute.c @@ -120,9 +120,6 @@ static void test_php_cur_stack_depth(TSRMLS_D) { } void test_main(void* p NRUNUSED) { -#if defined(ZTS) && !defined(PHP7) - void*** tsrm_ls = NULL; -#endif /* ZTS && !PHP7 */ tlib_php_engine_create("" PTSRMLS_CC); test_add_segment_metric(TSRMLS_C); test_txn_restart_in_callstack(TSRMLS_C); diff --git a/agent/tests/test_php_stack.c b/agent/tests/test_php_stack.c index 08ed861cc..e9a6a63c1 100644 --- a/agent/tests/test_php_stack.c +++ b/agent/tests/test_php_stack.c @@ -88,9 +88,6 @@ static void test_stack_trace_limit(TSRMLS_D) { } void test_main(void* p NRUNUSED) { -#if defined(ZTS) && !defined(PHP7) - void*** tsrm_ls = NULL; -#endif /* ZTS && !PHP7 */ tlib_php_engine_create("" PTSRMLS_CC); test_stack_trace_limit(TSRMLS_C); tlib_php_engine_destroy(TSRMLS_C); diff --git a/agent/tests/test_php_stacked_segment.c b/agent/tests/test_php_stacked_segment.c index 7d71f5ecd..edc9877e4 100644 --- a/agent/tests/test_php_stacked_segment.c +++ b/agent/tests/test_php_stacked_segment.c @@ -117,9 +117,6 @@ static void test_unwind(TSRMLS_D) { tlib_php_request_end(); } void test_main(void* p NRUNUSED) { -#if defined(ZTS) && !defined(PHP7) - void*** tsrm_ls = NULL; -#endif /* ZTS && !PHP7 */ tlib_php_engine_create("" PTSRMLS_CC); test_start_end_discard(TSRMLS_C); test_unwind(TSRMLS_C); diff --git a/agent/tests/test_php_wrapper.c b/agent/tests/test_php_wrapper.c index 975a46904..ecef228ab 100644 --- a/agent/tests/test_php_wrapper.c +++ b/agent/tests/test_php_wrapper.c @@ -751,9 +751,6 @@ static void test_add_arg(TSRMLS_D) { } void test_main(void* p NRUNUSED) { -#if defined(ZTS) && !defined(PHP7) - void*** tsrm_ls = NULL; -#endif /* ZTS && !PHP7 */ tlib_php_engine_create("" PTSRMLS_CC); test_add_arg(); diff --git a/agent/tests/test_predis.c b/agent/tests/test_predis.c index d04c03e8c..63defbf16 100644 --- a/agent/tests/test_predis.c +++ b/agent/tests/test_predis.c @@ -828,9 +828,6 @@ static void test_save_datastore_instance(TSRMLS_D) { } void test_main(void* p NRUNUSED) { -#if defined(ZTS) && !defined(PHP7) - void*** tsrm_ls = NULL; -#endif /* ZTS && !PHP7 */ default_database = nr_formatf("%ld", (long)nr_predis_default_database); default_port = nr_formatf("%ld", (long)nr_predis_default_port); diff --git a/agent/tests/test_redis.c b/agent/tests/test_redis.c index 3d5cabf42..13a095e59 100644 --- a/agent/tests/test_redis.c +++ b/agent/tests/test_redis.c @@ -216,9 +216,6 @@ static void test_save_datastore_instance(TSRMLS_D) { } void test_main(void* p NRUNUSED) { -#if defined(ZTS) && !defined(PHP7) - void*** tsrm_ls = NULL; -#endif /* ZTS && !PHP7 */ default_database = nr_strdup(nr_php_redis_default_database); system_host_name = nr_system_get_hostname(); diff --git a/agent/tests/test_txn.c b/agent/tests/test_txn.c index 4edfc56bd..a2fffacc9 100644 --- a/agent/tests/test_txn.c +++ b/agent/tests/test_txn.c @@ -361,9 +361,6 @@ static void test_create_log_forwarding_labels(TSRMLS_D) { tlib_parallel_info_t parallel_info = {.suggested_nthreads = 1, .state_size = 0}; void test_main(void* p NRUNUSED) { -#if defined(ZTS) && !defined(PHP7) - void*** tsrm_ls = NULL; -#endif /* ZTS && !PHP7 */ /* * We're setting up our own engine instance because we need to control the diff --git a/agent/tests/test_user_instrument.c b/agent/tests/test_user_instrument.c index 74b5638f6..cd8bb8a6f 100644 --- a/agent/tests/test_user_instrument.c +++ b/agent/tests/test_user_instrument.c @@ -181,9 +181,6 @@ static void test_add_custom_tracer_named() { } void test_main(void* p NRUNUSED) { -#if defined(ZTS) && !defined(PHP7) - void*** tsrm_ls = NULL; -#endif /* ZTS && !PHP7 */ tlib_php_engine_create("" PTSRMLS_CC); diff --git a/agent/tests/test_user_instrument_hashmap.c b/agent/tests/test_user_instrument_hashmap.c index d5ee22ddb..b43bdc27d 100644 --- a/agent/tests/test_user_instrument_hashmap.c +++ b/agent/tests/test_user_instrument_hashmap.c @@ -573,9 +573,6 @@ static void test_wraprec_hashmap_two_functions() { #endif void test_main(void* p NRUNUSED) { -#if defined(ZTS) && !defined(PHP7) - void*** tsrm_ls = NULL; -#endif /* ZTS && !PHP7 */ tlib_php_engine_create("" PTSRMLS_CC); diff --git a/agent/tests/test_user_instrument_wraprec_hashmap.c b/agent/tests/test_user_instrument_wraprec_hashmap.c index c23bc4f8e..fbc7d609b 100644 --- a/agent/tests/test_user_instrument_wraprec_hashmap.c +++ b/agent/tests/test_user_instrument_wraprec_hashmap.c @@ -72,9 +72,6 @@ static void test_wraprecs_hashmap() { // clang-format on void test_main(void* p NRUNUSED) { -#if defined(ZTS) && !defined(PHP7) - void*** tsrm_ls = NULL; -#endif /* ZTS && !PHP7 */ tlib_php_engine_create("" PTSRMLS_CC); diff --git a/agent/tests/test_zval.c b/agent/tests/test_zval.c index 630cdd258..88d37fa1d 100644 --- a/agent/tests/test_zval.c +++ b/agent/tests/test_zval.c @@ -101,18 +101,12 @@ static void test_is_zval_valid_callable(TSRMLS_D) { test_valid_callable("'ReflectionFunction::export'" TSRMLS_CC); #endif test_valid_callable("function () {}" TSRMLS_CC); - -#if ZEND_MODULE_API_NO >= ZEND_7_0_X_API_NO /* PHP 7.0+ */ test_valid_callable("new class { function __invoke() {} }" TSRMLS_CC); -#endif /* PHP 7.0+ */ tlib_php_request_end(); } void test_main(void* p NRUNUSED) { -#if defined(ZTS) && !defined(PHP7) - void*** tsrm_ls = NULL; -#endif /* ZTS && !PHP7 */ tlib_php_engine_create("" PTSRMLS_CC); diff --git a/agent/tests/tlib_php.c b/agent/tests/tlib_php.c index 203f5c0de..ab85e0da3 100644 --- a/agent/tests/tlib_php.c +++ b/agent/tests/tlib_php.c @@ -83,22 +83,14 @@ static char* tlib_php_create_output_filename(const char* ext) { * A replacement unbuffered write callback to capture any script output for * further examination. */ -#if ZEND_MODULE_API_NO >= ZEND_7_0_X_API_NO static size_t tlib_php_engine_ub_write(const char* str, size_t len) -#else -static int tlib_php_engine_ub_write(const char* str, uint len TSRMLS_DC) -#endif /* PHP >= 7.0 */ { NR_UNUSED_TSRMLS; assert(NULL != out); fwrite(str, (size_t)len, 1, out); -#if ZEND_MODULE_API_NO >= ZEND_7_0_X_API_NO return len; -#else - return NRSAFELEN(len); -#endif /* PHP >= 7.0 */ } /* @@ -111,18 +103,10 @@ static zend_string* ZEND_FASTCALL tlib_php_new_interned_string(zend_string* str) { return str; } -#elif defined PHP7 +#else static zend_string* tlib_php_new_interned_string(zend_string* str) { return str; } -#elif ZEND_MODULE_API_NO >= ZEND_5_4_X_API_NO -static const char* tlib_php_new_interned_string(const char* key, - int len NRUNUSED, - int free_src NRUNUSED - TSRMLS_DC) { - NR_UNUSED_TSRMLS; - return key; -} #endif #if ZEND_MODULE_API_NO >= ZEND_8_0_X_API_NO @@ -138,17 +122,6 @@ static zend_string* ZEND_FASTCALL tlib_php_init_interned_string(const char* str, } #endif /* PHP >= 7.3 */ -#if ZEND_MODULE_API_NO >= ZEND_5_4_X_API_NO \ - && ZEND_MODULE_API_NO < ZEND_7_2_X_API_NO -static void tlib_php_interned_strings_restore(TSRMLS_D) { - NR_UNUSED_TSRMLS; -} - -static void tlib_php_interned_strings_snapshot(TSRMLS_D) { - NR_UNUSED_TSRMLS; -} -#endif /* PHP >= 5.4 && PHP < 7.2 */ - /* }}} */ static nr_status_t stub_cmd_appinfo_tx(int daemon_fd, nrapp_t* app); @@ -175,9 +148,6 @@ nr_status_t tlib_php_engine_create(const char* extra_ini PTSRMLS_DC) { fake_daemon_fd = nr_dup(1); nr_set_daemon_fd(fake_daemon_fd); -#if defined(ZTS) && !defined(PHP7) - void*** tsrm_ls = NULL; -#endif /* ZTS && !PHP7 */ sapi_module_struct tlib_module; /* @@ -197,20 +167,16 @@ nr_status_t tlib_php_engine_create(const char* extra_ini PTSRMLS_DC) { #if ZEND_MODULE_API_NO >= ZEND_7_4_X_API_NO php_tsrm_startup(); ZEND_TSRMLS_CACHE_UPDATE(); -#elif defined PHP7 +#else tsrm_startup(1, 1, 0, NULL); ts_resource(0); ZEND_TSRMLS_CACHE_UPDATE(); -#else - tsrm_startup(1, 1, 0, NULL); - tsrm_ls = ts_resource(0); - *ptsrm_ls = tsrm_ls; #endif /* PHP version */ #endif /* ZTS */ -#if defined(PHP7) && defined(ZEND_SIGNALS) +#if defined(ZEND_SIGNALS) zend_signal_startup(); -#endif /* PHP7 && ZEND_SIGNALS */ +#endif /* ZEND_SIGNALS */ /* * This currently creates real files for the agent log and output that are @@ -311,18 +277,6 @@ nr_status_t tlib_php_engine_create(const char* extra_ini PTSRMLS_DC) { } #endif - /* - * As noted above, we now replace the interned string callbacks on PHP - * 5.4-7.1, inclusive. The effect of these replacements is to disable - * interned strings. - */ -#if ZEND_MODULE_API_NO >= ZEND_5_4_X_API_NO \ - && ZEND_MODULE_API_NO < ZEND_7_2_X_API_NO - zend_new_interned_string = tlib_php_new_interned_string; - zend_interned_strings_restore = tlib_php_interned_strings_restore; - zend_interned_strings_snapshot = tlib_php_interned_strings_snapshot; -#endif /* PHP >= 5.4 && PHP < 7.2 */ - /* * Register the resource type we use to fake resources. We are module 0 * because we're the SAPI. @@ -600,16 +554,7 @@ tlib_php_internal_function_handler_t tlib_php_replace_internal_function( zend_class_entry* ce = NULL; char* lcclass = nr_string_to_lowercase(klass); -#ifdef PHP7 ce = (zend_class_entry*)nr_php_zend_hash_find_ptr(CG(class_table), lcclass); -#else - zend_class_entry** ce_ptr - = nr_php_zend_hash_find_ptr(CG(class_table), lcclass); - - if (ce_ptr) { - ce = *ce_ptr; - } -#endif /* PHP7 */ nr_free(lcclass); if (NULL == ce) { @@ -670,7 +615,6 @@ zval* tlib_php_zval_create_default(zend_uchar type TSRMLS_DC) { nr_php_zval_str(zv, ""); break; -#ifdef PHP7 case IS_UNDEF: ZVAL_UNDEF(zv); break; @@ -732,15 +676,6 @@ zval* tlib_php_zval_create_default(zend_uchar type TSRMLS_DC) { ZVAL_NEW_REF(zv, &refval); } break; -#else - case IS_BOOL: - ZVAL_BOOL(zv, 0); - break; - - case IS_RESOURCE: - ZEND_REGISTER_RESOURCE(zv, NULL, le_tlib); - break; -#endif /* PHP7 */ default: nr_php_zval_free(&zv); @@ -750,17 +685,10 @@ zval* tlib_php_zval_create_default(zend_uchar type TSRMLS_DC) { return zv; } -#ifdef PHP7 static const zend_uchar default_zval_types[] = { IS_UNDEF, IS_NULL, IS_FALSE, IS_TRUE, IS_LONG, IS_DOUBLE, IS_STRING, IS_ARRAY, IS_OBJECT, IS_RESOURCE, IS_REFERENCE, }; -#else -static const zend_uchar default_zval_types[] = { - IS_NULL, IS_LONG, IS_DOUBLE, IS_BOOL, - IS_ARRAY, IS_OBJECT, IS_STRING, IS_RESOURCE, -}; -#endif zval** tlib_php_zvals_of_all_types(TSRMLS_D) { zval** arr; @@ -829,11 +757,7 @@ char* tlib_php_zval_dump(zval* zv TSRMLS_DC) { } tlib_php_request_eval("ob_start();" TSRMLS_CC); -#ifdef PHP7 php_var_dump(zv, 0); -#else - php_var_dump(&zv, 0 TSRMLS_CC); -#endif result = tlib_php_request_eval_expr("ob_get_clean()" TSRMLS_CC); if (nr_php_is_zval_valid_string(result)) { dump = nr_strndup(Z_STRVAL_P(result), Z_STRLEN_P(result)); diff --git a/tests/integration/errors/test_E_DEPRECATED_1.php b/tests/integration/errors/test_E_DEPRECATED_1.php deleted file mode 100644 index cfff7c785..000000000 --- a/tests/integration/errors/test_E_DEPRECATED_1.php +++ /dev/null @@ -1,75 +0,0 @@ -=')) { - die("skip: requires PHP 5.3 or 5.4\n"); -} -*/ - -/*INI -error_reporting = E_ALL | E_STRICT -*/ - -/*EXPECT_SCRUBBED - -Deprecated: Function split() is deprecated in __FILE__ on line ?? -*/ - -/*EXPECT_TRACED_ERRORS -[ - "?? agent run id", - [ - [ - "??", - "OtherTransaction/php__FILE__", - "Function split() is deprecated", - "Error", - { - "stack_trace": [ - " in split called at __FILE__ (??)" - ], - "agentAttributes": "??", - "intrinsics": "??" - }, - "?? transaction ID" - ] - ] -] -*/ - -/*EXPECT_ERROR_EVENTS -[ - "?? agent run id", - { - "reservoir_size": "??", - "events_seen": 1 - }, - [ - [ - { - "type": "TransactionError", - "timestamp": "??", - "error.class": "Error", - "error.message": "Function split() is deprecated", - "transactionName": "OtherTransaction\/php__FILE__", - "duration": "??", - "nr.transactionGuid": "??" - }, - {}, - {} - ] - ] -] -*/ - -list($month, $day, $year) = split('[/.-]', '01/01/1970'); diff --git a/tests/integration/errors/test_E_DEPRECATED_2.php5.php b/tests/integration/errors/test_E_DEPRECATED_2.php5.php deleted file mode 100644 index cf40c6d7f..000000000 --- a/tests/integration/errors/test_E_DEPRECATED_2.php5.php +++ /dev/null @@ -1,78 +0,0 @@ -=')) { - die("skip: requires PHP 5.5+ or HHVM\n"); -} -*/ - -/*INI -error_reporting = E_ALL | E_STRICT -*/ - -/*EXPECT_SCRUBBED - -Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in __FILE__ on line ?? -*/ - -/*EXPECT_TRACED_ERRORS -[ - "?? agent run id", - [ - [ - "?? when", - "OtherTransaction/php__FILE__", - "preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead", - "Error", - { - "stack_trace": [ - " in preg_replace called at __FILE__ (??)" - ], - "agentAttributes": "??", - "intrinsics": "??" - } - ] - ] -] -*/ - -/*EXPECT_ERROR_EVENTS -[ - "?? agent run id", - { - "reservoir_size": "??", - "events_seen": 1 - }, - [ - [ - { - "type": "TransactionError", - "timestamp": "??", - "error.class": "Error", - "error.message": "preg_replace(): The \/e modifier is deprecated, use preg_replace_callback instead", - "transactionName": "OtherTransaction\/php__FILE__", - "duration": "??", - "nr.transactionGuid": "??", - "guid": "??", - "sampled": true, - "priority": "??", - "traceId": "??", - "spanId": "??" - }, - {}, - {} - ] - ] -] -*/ - -preg_replace('(pattern)e', 'strtoupper("$1")', 'subject with pattern in it'); diff --git a/tests/integration/errors/test_E_ERROR.php5.php b/tests/integration/errors/test_E_ERROR.php5.php deleted file mode 100644 index 32f517b99..000000000 --- a/tests/integration/errors/test_E_ERROR.php5.php +++ /dev/null @@ -1,75 +0,0 @@ -=")) { - die("skip: PHP 7 not supported\n"); -} -*/ - -/*EXPECT_TRACED_ERRORS -[ - "?? agent run id", - [ - [ - "?? when", - "OtherTransaction/php__FILE__", - "Call to undefined function not_a_function()", - "E_ERROR", - { - "stack_trace": [ - " in call_not_a_function called at __FILE__ (??)", - " in call_not_a_function called at __FILE__ (??)" - ], - "agentAttributes": "??", - "intrinsics": "??" - }, - "?? transaction ID" - ] - ] -] -*/ - -/*EXPECT_ERROR_EVENTS -[ - "?? agent run id", - { - "reservoir_size": "??", - "events_seen": 1 - }, - [ - [ - { - "type": "TransactionError", - "timestamp": "??", - "error.class": "E_ERROR", - "error.message": "Call to undefined function not_a_function()", - "transactionName": "OtherTransaction\/php__FILE__", - "duration": "??", - "nr.transactionGuid": "??", - "guid": "??", - "sampled": true, - "priority": "??", - "traceId": "??", - "spanId": "??" - }, - {}, - {} - ] - ] -] -*/ - -function call_not_a_function() { - not_a_function(); -} - -call_not_a_function(); diff --git a/tests/integration/errors/test_E_ERROR.php7.0.0.php b/tests/integration/errors/test_E_ERROR.php7.0.0.php deleted file mode 100644 index 4d0727478..000000000 --- a/tests/integration/errors/test_E_ERROR.php7.0.0.php +++ /dev/null @@ -1,79 +0,0 @@ -")) { - die("skip: test is for PHP 7.0.0 only\n"); -} -*/ - -/*EXPECT_TRACED_ERRORS -[ - "?? agent run id", - [ - [ - "?? when", - "OtherTransaction/php__FILE__", - "Method C::__toString() must not throw an exception", - "E_ERROR", - { - "stack_trace": [ - ], - "agentAttributes": "??", - "intrinsics": "??" - }, - "?? transaction ID" - ] - ] -] -*/ - -/*EXPECT_ERROR_EVENTS -[ - "?? agent run id", - { - "reservoir_size": "??", - "events_seen": 1 - }, - [ - [ - { - "type": "TransactionError", - "timestamp": "??", - "error.class": "E_ERROR", - "error.message": "Method C::__toString() must not throw an exception", - "transactionName": "OtherTransaction\/php__FILE__", - "duration": "??", - "nr.transactionGuid": "??", - "guid": "??", - "sampled": true, - "priority": "??", - "traceId": "??", - "spanId": "??" - }, - {}, - {} - ] - ] -] -*/ - -class C { - public function __toString(): string { - throw new Exception; - } -} - -(string) (new C); diff --git a/tests/integration/errors/test_E_RECOVERABLE.php5.php b/tests/integration/errors/test_E_RECOVERABLE.php5.php deleted file mode 100644 index 967badb76..000000000 --- a/tests/integration/errors/test_E_RECOVERABLE.php5.php +++ /dev/null @@ -1,80 +0,0 @@ -=")) { - die("skip: PHP 7 not supported\n"); -} -*/ - -/*EXPECT_SCRUBBED -Catchable fatal error: Object of class stdClass could not be converted to string in __FILE__ on line ?? -*/ - -/*EXPECT_TRACED_ERRORS -[ - "?? agent run id", - [ - [ - "?? when", - "OtherTransaction/php__FILE__", - "Object of class stdClass could not be converted to string", - "Error", - { - "stack_trace": [ - " in run_test_in_a_function called at __FILE__ (??)", - " in run_test_in_a_function called at __FILE__ (??)" - ], - "agentAttributes": "??", - "intrinsics": "??" - }, - "?? transaction ID" - ] - ] -] -*/ - -/*EXPECT_ERROR_EVENTS -[ - "?? agent run id", - { - "reservoir_size": "??", - "events_seen": 1 - }, - [ - [ - { - "type": "TransactionError", - "timestamp": "??", - "error.class": "Error", - "error.message": "Object of class stdClass could not be converted to string", - "transactionName": "OtherTransaction\/php__FILE__", - "duration": "??", - "nr.transactionGuid": "??", - "guid": "??", - "sampled": true, - "priority": "??", - "traceId": "??", - "spanId": "??" - }, - {}, - {} - ] - ] -] -*/ - -function run_test_in_a_function() { - $cls = new stdClass(); - echo (string)$cls; -} - -run_test_in_a_function(); diff --git a/tests/integration/errors/test_E_STRICT.php5.php b/tests/integration/errors/test_E_STRICT.php5.php deleted file mode 100644 index c60121bc2..000000000 --- a/tests/integration/errors/test_E_STRICT.php5.php +++ /dev/null @@ -1,81 +0,0 @@ -=")) { - die("skip: PHP 7 not supported\n"); -} -*/ - -/*INI -date.timezone = America/Los_Angeles -error_reporting = E_ALL | E_STRICT -*/ - -/*EXPECT_SCRUBBED - -Strict Standards: mktime(): You should be using the time() function instead in __FILE__ on line ?? -*/ - -/*EXPECT_TRACED_ERRORS -[ - "?? agent run id", - [ - [ - "?? when", - "OtherTransaction/php__FILE__", - "mktime(): You should be using the time() function instead", - "Error", - { - "stack_trace": [ - " in mktime called at __FILE__ (??)" - ], - "agentAttributes": "??", - "intrinsics": "??" - }, - "?? transaction ID" - ] - ] -] -*/ - -/*EXPECT_ERROR_EVENTS -[ - "?? agent run id", - { - "reservoir_size": "??", - "events_seen": 1 - }, - [ - [ - { - "type": "TransactionError", - "timestamp": "??", - "error.class": "Error", - "error.message": "mktime(): You should be using the time() function instead", - "transactionName": "OtherTransaction\/php__FILE__", - "duration": "??", - "nr.transactionGuid": "??", - "guid": "??", - "sampled": true, - "priority": "??", - "traceId": "??", - "spanId": "??" - }, - {}, - {} - ] - ] -] -*/ - -/* Calling mktime() with no arguments causes E_STRICT. */ -$current_time = mktime(); diff --git a/tests/integration/errors/test_E_WARNING.php5.php b/tests/integration/errors/test_E_WARNING.php5.php deleted file mode 100644 index f119a845d..000000000 --- a/tests/integration/errors/test_E_WARNING.php5.php +++ /dev/null @@ -1,79 +0,0 @@ -=")) { - die("skip: PHP 7 not supported\n"); -} -*/ - -/*EXPECT_SCRUBBED -Warning: Division by zero in __FILE__ on line ?? -*/ - -/*EXPECT_TRACED_ERRORS -[ - "?? agent run id", - [ - [ - "?? when", - "OtherTransaction/php__FILE__", - "Division by zero", - "E_WARNING", - { - "stack_trace": [ - " in run_test called at __FILE__ (??)", - " in run_test called at __FILE__ (??)" - ], - "agentAttributes": "??", - "intrinsics": "??" - }, - "?? transaction ID" - ] - ] -] -*/ - -/*EXPECT_ERROR_EVENTS -[ - "?? agent run id", - { - "reservoir_size": "??", - "events_seen": 1 - }, - [ - [ - { - "type": "TransactionError", - "timestamp": "??", - "error.class": "E_WARNING", - "error.message": "Division by zero", - "transactionName": "OtherTransaction\/php__FILE__", - "duration": "??", - "nr.transactionGuid": "??", - "guid": "??", - "sampled": true, - "priority": "??", - "traceId": "??", - "spanId": "??" - }, - {}, - {} - ] - ] -] -*/ - -function run_test() { - echo 8 / 0; -} - -run_test(); diff --git a/tests/integration/errors/test_ignore_all_except_E_WARNING.php5.php b/tests/integration/errors/test_ignore_all_except_E_WARNING.php5.php deleted file mode 100644 index a0836a350..000000000 --- a/tests/integration/errors/test_ignore_all_except_E_WARNING.php5.php +++ /dev/null @@ -1,85 +0,0 @@ -=")) { - die("skip: PHP 7 not supported\n"); -} -*/ - -/*INI -error_reporting = E_ALL | E_STRICT -newrelic.error_collector.ignore_errors = E_ALL & ~E_WARNING -*/ - -/*EXPECT_SCRUBBED -Warning: Division by zero in __FILE__ on line ?? -*/ - -/*EXPECT_TRACED_ERRORS -[ - "?? agent run id", - [ - [ - "?? when", - "OtherTransaction/php__FILE__", - "Division by zero", - "E_WARNING", - { - "stack_trace": [ - " in run_test called at __FILE__ (??)", - " in run_test called at __FILE__ (??)" - ], - "agentAttributes": "??", - "intrinsics": "??" - }, - "?? transaction ID" - ] - ] -] -*/ - -/*EXPECT_ERROR_EVENTS -[ - "?? agent run id", - { - "reservoir_size": "??", - "events_seen": 1 - }, - [ - [ - { - "type": "TransactionError", - "timestamp": "??", - "error.class": "E_WARNING", - "error.message": "Division by zero", - "transactionName": "OtherTransaction\/php__FILE__", - "duration": "??", - "nr.transactionGuid": "??", - "guid": "??", - "sampled": true, - "priority": "??", - "traceId": "??", - "spanId": "??" - }, - {}, - {} - ] - ] -] -*/ - -function run_test() { - $x = 8 / 0; -} - -run_test(); diff --git a/tests/integration/frameworks/silex/Silex/Application.php b/tests/integration/frameworks/silex/Silex/Application.php deleted file mode 100644 index 71c5560d7..000000000 --- a/tests/integration/frameworks/silex/Silex/Application.php +++ /dev/null @@ -1,46 +0,0 @@ -_route) ? $this->_route : $default; - } - } - - class Request { - public $attributes; - } - - class Response {} -} - -namespace Symfony\Component\HttpKernel { - use Symfony\Component\HttpFoundation\Response; - - interface HttpKernelInterface { - const MASTER_REQUEST = 1; - const SUB_REQUEST = 2; - - public function handle($request, $type = self::MASTER_REQUEST, $catch = true); - } - - class HttpKernel implements HttpKernelInterface { - public function handle($request, $type = self::MASTER_REQUEST, $catch = true) { - return $this->handleRaw($request, $type); - } - - private function handleRaw($request, $type = self::MASTER_REQUEST) { - return new Response; - } - } -} diff --git a/tests/integration/frameworks/silex/skipif.inc b/tests/integration/frameworks/silex/skipif.inc deleted file mode 100644 index 9244a785a..000000000 --- a/tests/integration/frameworks/silex/skipif.inc +++ /dev/null @@ -1,10 +0,0 @@ -attributes = new ParameterBag; -$request->attributes->_route = 'GET_foo'; - -$kernel->handle($request); diff --git a/tests/integration/frameworks/silex/test_basic_logging_off.php b/tests/integration/frameworks/silex/test_basic_logging_off.php deleted file mode 100644 index 240450840..000000000 --- a/tests/integration/frameworks/silex/test_basic_logging_off.php +++ /dev/null @@ -1,54 +0,0 @@ -attributes = new ParameterBag; -$request->attributes->_route = 'GET_foo'; - -$kernel->handle($request); diff --git a/tests/integration/frameworks/silex/test_invalid_attributes.php b/tests/integration/frameworks/silex/test_invalid_attributes.php deleted file mode 100644 index cb4fcc153..000000000 --- a/tests/integration/frameworks/silex/test_invalid_attributes.php +++ /dev/null @@ -1,52 +0,0 @@ -attributes = new DateTime; - -$kernel->handle($request); diff --git a/tests/integration/frameworks/silex/test_invalid_request.php b/tests/integration/frameworks/silex/test_invalid_request.php deleted file mode 100644 index 3a428ae71..000000000 --- a/tests/integration/frameworks/silex/test_invalid_request.php +++ /dev/null @@ -1,48 +0,0 @@ -handle($request); diff --git a/tests/integration/lang/test_generator_5.6-7.0.php b/tests/integration/lang/test_generator_5.6-7.0.php deleted file mode 100644 index d709aba96..000000000 --- a/tests/integration/lang/test_generator_5.6-7.0.php +++ /dev/null @@ -1,91 +0,0 @@ -=')) { - die("skip: generator priming changed in PHP 7.1"); -} -*/ - -/*INI -*/ - -/*EXPECT -1,2,3,4,5,6,7,8,9,10, -*/ - -/*EXPECT_METRICS -[ - "?? agent run id", - "?? timeframe start", - "?? timeframe stop", - [ - [{"name":"DurationByCaller/Unknown/Unknown/Unknown/Unknown/all"}, [1, "??", "??", "??", "??", "??"]], - [{"name":"DurationByCaller/Unknown/Unknown/Unknown/Unknown/allOther"}, [1, "??", "??", "??", "??", "??"]], - [{"name":"Custom/xrange"}, [11, "??", "??", "??", "??", "??"]], - [{"name":"OtherTransaction/all"}, [1, "??", "??", "??", "??", "??"]], - [{"name":"OtherTransaction/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], - [{"name":"OtherTransactionTotalTime"}, [1, "??", "??", "??", "??", "??"]], - [{"name":"OtherTransactionTotalTime/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], - [{"name":"Custom/xrange", - "scope":"OtherTransaction/php__FILE__"}, [11, "??", "??", "??", "??", "??"]], - [{"name":"Supportability/InstrumentedFunction/xrange"}, [11, "??", "??", "??", "??", "??"]], - [{"name":"Supportability/api/add_custom_tracer"}, [1, "??", "??", "??", "??", "??"]], - [{"name":"Supportability/Logging/Forwarding/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]], - [{"name":"Supportability/Logging/Metrics/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]], - [{"name":"Supportability/Logging/LocalDecorating/PHP/disabled"}, [1, "??", "??", "??", "??", "??"]], - [{"name":"Supportability/Logging/Labels/PHP/disabled"}, [1, "??", "??", "??", "??", "??"]] - ] -] -*/ - - - - -function factorial($n) -{ - if ($n <= 0) { - return 1; - } else { - return $n * factorial($n-1); - } -} - -function defeat_inlining_and_tail_recursion() -{ - factorial((rand() >> 3) & 0x7); -} - -/* - * Generators are a new feature in PHP 5.5 - * http://php.net/manual/en/language.generators.overview.php - */ - -function xrange($start, $limit, $step = 1) { - for ($i = $start; $i <= $limit; $i += $step) { - defeat_inlining_and_tail_recursion(); - yield $i; - defeat_inlining_and_tail_recursion(); - } -} - -newrelic_add_custom_tracer("xrange"); - -foreach (xrange(1, 10, 1) as $number) { - echo "$number,"; -} - -echo "\n"; diff --git a/tests/integration/memcached/test_cas.php5.php b/tests/integration/memcached/test_cas.php5.php deleted file mode 100644 index 144cf6b82..000000000 --- a/tests/integration/memcached/test_cas.php5.php +++ /dev/null @@ -1,100 +0,0 @@ -=")) { - die("skip: PHP 5 only test\n"); -} -*/ - -/*INI -*/ - -/*EXPECT -ok - set -ok - get -ok - cas -ok - get -ok - delete -*/ - -/*EXPECT_METRICS -[ - "?? agent run id", - "?? start time", - "?? stop time", - [ - [{"name":"DurationByCaller/Unknown/Unknown/Unknown/Unknown/all"}, [1, "??", "??", "??", "??", "??"]], - [{"name":"DurationByCaller/Unknown/Unknown/Unknown/Unknown/allOther"}, [1, "??", "??", "??", "??", "??"]], - [{"name":"Datastore/all"}, [5, "??", "??", "??", "??", "??"]], - [{"name":"Datastore/allOther"}, [5, "??", "??", "??", "??", "??"]], - [{"name":"Datastore/Memcached/all"}, [5, "??", "??", "??", "??", "??"]], - [{"name":"Datastore/Memcached/allOther"}, [5, "??", "??", "??", "??", "??"]], - [{"name":"Datastore/operation/Memcached/delete"}, [1, "??", "??", "??", "??", "??"]], - [{"name":"Datastore/operation/Memcached/delete", - "scope":"OtherTransaction/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], - [{"name":"Datastore/operation/Memcached/get"}, [2, "??", "??", "??", "??", "??"]], - [{"name":"Datastore/operation/Memcached/get", - "scope":"OtherTransaction/php__FILE__"}, [2, "??", "??", "??", "??", "??"]], - [{"name":"Datastore/operation/Memcached/replace"}, [1, "??", "??", "??", "??", "??"]], - [{"name":"Datastore/operation/Memcached/replace", - "scope":"OtherTransaction/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], - [{"name":"Datastore/operation/Memcached/set"}, [1, "??", "??", "??", "??", "??"]], - [{"name":"Datastore/operation/Memcached/set", - "scope":"OtherTransaction/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], - [{"name":"OtherTransaction/all"}, [1, "??", "??", "??", "??", "??"]], - [{"name":"OtherTransaction/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], - [{"name":"OtherTransactionTotalTime"}, [1, "??", "??", "??", "??", "??"]], - [{"name":"OtherTransactionTotalTime/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], - [{"name":"Supportability/Logging/Forwarding/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]], - [{"name":"Supportability/Logging/Metrics/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]], - [{"name":"Supportability/Logging/LocalDecorating/PHP/disabled"}, [1, "??", "??", "??", "??", "??"]], - [{"name":"Supportability/Logging/Labels/PHP/disabled"}, [1, "??", "??", "??", "??", "??"]] - ] -] -*/ - - - - -/*EXPECT_TRACED_ERRORS -null -*/ - -require_once(realpath (dirname ( __FILE__ )) . '/../../include/helpers.php'); -require_once(realpath (dirname ( __FILE__ )) . '/../../include/tap.php'); -require_once(realpath (dirname ( __FILE__ )) . '/memcache.inc'); - -define('KEYLEN', 8); // should be long enough to prevent collisions. - -function main() -{ - global $MEMCACHE_HOST, $MEMCACHE_PORT; - - $memcached = new Memcached(); - $memcached->addServer($MEMCACHE_HOST, $MEMCACHE_PORT); - - $key = randstr(KEYLEN); - $token = 'foobar'; - - $test = new TestCase($memcached); - $test->set($key, 'hot potato'); - tap_equal('hot potato', $test->get($key, NULL, $token), 'get'); - $test->cas($token, $key, 'cold potato'); - tap_equal('cold potato', $test->get($key, NULL, $token), 'get'); - $test->delete($key); - - $memcached->quit(); -} - -main(); diff --git a/tests/integration/memcached/test_cas_by_key.php5.php b/tests/integration/memcached/test_cas_by_key.php5.php deleted file mode 100644 index c4daae66c..000000000 --- a/tests/integration/memcached/test_cas_by_key.php5.php +++ /dev/null @@ -1,106 +0,0 @@ -=")) { - die("skip: PHP 5 only test\n"); -} -*/ - -/*INI -*/ - -/*EXPECT -ok - setByKey -ok - getByKey -ok - casByKey -ok - getByKey -ok - deleteByKey -*/ - -/*EXPECT_METRICS -[ - "?? agent run id", - "?? start time", - "?? stop time", - [ - [{"name":"DurationByCaller/Unknown/Unknown/Unknown/Unknown/all"}, [1, "??", "??", "??", "??", "??"]], - [{"name":"DurationByCaller/Unknown/Unknown/Unknown/Unknown/allOther"}, [1, "??", "??", "??", "??", "??"]], - [{"name":"Datastore/all"}, [5, "??", "??", "??", "??", "??"]], - [{"name":"Datastore/allOther"}, [5, "??", "??", "??", "??", "??"]], - [{"name":"Datastore/Memcached/all"}, [5, "??", "??", "??", "??", "??"]], - [{"name":"Datastore/Memcached/allOther"}, [5, "??", "??", "??", "??", "??"]], - [{"name":"Datastore/operation/Memcached/delete"}, [1, "??", "??", "??", "??", "??"]], - [{"name":"Datastore/operation/Memcached/delete", - "scope":"OtherTransaction/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], - [{"name":"Datastore/operation/Memcached/get"}, [2, "??", "??", "??", "??", "??"]], - [{"name":"Datastore/operation/Memcached/get", - "scope":"OtherTransaction/php__FILE__"}, [2, "??", "??", "??", "??", "??"]], - [{"name":"Datastore/operation/Memcached/replace"}, [1, "??", "??", "??", "??", "??"]], - [{"name":"Datastore/operation/Memcached/replace", - "scope":"OtherTransaction/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], - [{"name":"Datastore/operation/Memcached/set"}, [1, "??", "??", "??", "??", "??"]], - [{"name":"Datastore/operation/Memcached/set", - "scope":"OtherTransaction/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], - [{"name":"OtherTransaction/all"}, [1, "??", "??", "??", "??", "??"]], - [{"name":"OtherTransaction/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], - [{"name":"OtherTransactionTotalTime"}, [1, "??", "??", "??", "??", "??"]], - [{"name":"OtherTransactionTotalTime/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], - [{"name":"Supportability/Logging/Forwarding/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]], - [{"name":"Supportability/Logging/Metrics/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]], - [{"name":"Supportability/Logging/LocalDecorating/PHP/disabled"}, [1, "??", "??", "??", "??", "??"]], - [{"name":"Supportability/Logging/Labels/PHP/disabled"}, [1, "??", "??", "??", "??", "??"]] - ] -] -*/ - - - - -/*EXPECT_TRACED_ERRORS -null -*/ - -require_once(realpath (dirname ( __FILE__ )) . '/../../include/helpers.php'); -require_once(realpath (dirname ( __FILE__ )) . '/../../include/tap.php'); -require_once(realpath (dirname ( __FILE__ )) . '/memcache.inc'); - -define('KEYLEN', 8); // should be long enough to prevent collisions. - -function main() -{ - global $MEMCACHE_HOST, $MEMCACHE_PORT; - - $memcached = new Memcached(); - $memcached->addServer($MEMCACHE_HOST, $MEMCACHE_PORT); - - $key = randstr(KEYLEN); - $token = 'foobar'; - $server_key = 'server key'; - - $test = new TestCase($memcached); - $test->setByKey($server_key, $key, 'hot potato'); - - $value = $test->getByKey($server_key, $key, NULL, $token); - tap_equal('hot potato', $value, 'getByKey'); - - $test->casByKey($token, $server_key, $key, 'cold potato'); - - $value = $test->getByKey($server_key, $key, NULL, $token); - tap_equal('cold potato', $value, 'getByKey'); - - $test->deleteByKey($server_key, $key); - $memcached->quit(); -} - -main(); diff --git a/tests/integration/output/test_clean_after_header_5.3.php b/tests/integration/output/test_clean_after_header_5.3.php deleted file mode 100644 index 34a147207..000000000 --- a/tests/integration/output/test_clean_after_header_5.3.php +++ /dev/null @@ -1,54 +0,0 @@ -=')) { - die("skip: requires PHP < 5.4\n"); -} -*/ - -/* - * We need output_buffering to be a non-zero value, but the exact value doesn't - * matter, as nr_php_install_output_buffer_handler() hardcodes 40960 as the - * internal buffer size. 4096 has been chosen simply because it matches most - * default distro configurations. - */ - -/*INI -output_buffering = 4096 -*/ - -/*ENVIRONMENT -REQUEST_METHOD=GET -*/ - -/* - * Match a partial HTML document that consists of an opening body - * tag, an opening script tag, script content starting with window.NREUM, then - * closing script, body and html tags. - */ - -/*EXPECT_REGEX -((?s)^\s*\s*\(?window\.NREUM(.*?)\s*\s*$) -*/ - -?> - - - - - - - - - From b6f1b202193a65ca2b7d6eb85c84fb63b4fbe9cf Mon Sep 17 00:00:00 2001 From: bduranleau-nr <106178551+bduranleau-nr@users.noreply.github.com> Date: Tue, 5 Aug 2025 12:34:25 -0500 Subject: [PATCH 4/7] feat(agent): clm off by default (#1049) --- agent/php_nrini.c | 2 +- agent/scripts/newrelic.ini.template | 4 +- ...stom_parameter_nested_caught_exception.php | 35 +- ...test_add_custom_parameter_nested_happy.php | 37 +- ...om_parameter_nested_uncaught_exception.php | 34 +- .../add_custom_parameter/test_span_event.php | 13 +- .../test_span_event.php5.php | 121 ------ .../test_span_event_parameter_duplicate.php | 13 +- ...st_span_event_parameter_duplicate.php5.php | 159 -------- ..._span_event_parameter_duplicate_te_off.php | 13 +- ..._event_parameter_duplicate_te_off.php5.php | 133 ------- .../test_span_event_parameter_filter.php | 13 +- .../test_span_event_parameter_filter.php5.php | 116 ------ ...pan_event_parameter_filter_logging_off.php | 13 +- ...vent_parameter_filter_logging_off.php5.php | 119 ------ .../test_span_event_parameter_max_key.php | 13 +- ...test_span_event_parameter_max_key.php5.php | 116 ------ ...st_span_event_parameter_max_key_te_off.php | 13 +- ...an_event_parameter_max_key_te_off.php5.php | 121 ------ ...st_span_event_parameter_max_parameters.php | 13 +- ...an_event_parameter_max_parameters.php5.php | 237 ----------- .../test_span_event_parameter_max_value.php | 13 +- ...st_span_event_parameter_max_value.php5.php | 116 ------ ..._span_event_parameter_max_value_te_off.php | 13 +- ..._event_parameter_max_value_te_off.php5.php | 126 ------ ...pan_event_parameter_maxplus_parameters.php | 13 +- ...vent_parameter_maxplus_parameters.php5.php | 237 ----------- ...nt_parameter_maxplus_parameters_te_off.php | 13 +- ...rameter_maxplus_parameters_te_off.php5.php | 244 ------------ ..._maxplus_parameters_te_off_logging_off.php | 13 +- ...lus_parameters_te_off_logging_off.php5.php | 247 ------------ ...an_event_parameter_maxplus_span_and_te.php | 13 +- ...ent_parameter_maxplus_span_and_te.php5.php | 367 ------------------ ...t_parameter_maxplus_span_and_te_te_off.php | 13 +- ...ameter_maxplus_span_and_te_te_off.php5.php | 281 -------------- ...vent_parameter_nested_caught_exception.php | 35 +- ...test_span_event_parameter_nested_happy.php | 37 +- ...nt_parameter_nested_uncaught_exception.php | 34 +- .../test_span_event_parameter_overwrite.php | 13 +- ...st_span_event_parameter_overwrite.php5.php | 120 ------ .../test_span_event_parameter_te_off.php | 13 +- .../test_span_event_parameter_te_off.php5.php | 118 ------ .../test_span_event_parameter_types.php | 13 +- .../test_span_event_parameter_types.php5.php | 117 ------ ...create_payload_nested_caught_exception.php | 24 +- .../test_create_payload_nested_happy.php | 23 +- ...eate_payload_nested_uncaught_exception.php | 36 +- .../newrelic/test_keep_span_with_payload.php | 13 +- .../test_keep_span_with_payload.php5.php | 84 ---- .../test_good_1_arg_exception.php | 5 +- .../test_good_1_arg_exception_handler.php | 5 +- .../notice_error/test_good_1_arg_string.php | 5 +- .../api/notice_error/test_good_2_args.php | 5 +- .../api/notice_error/test_good_4_args.php | 5 +- .../test_good_4_args_error_handler.php | 5 +- .../api/notice_error/test_good_5_args.php | 5 +- .../test_good_5_args_error_handler.php | 5 +- ...t_notice_error_nested_caught_exception.php | 37 +- .../test_notice_error_nested_happy.php | 39 +- ...notice_error_nested_uncaught_exception.php | 37 +- ...ser_attributes_nested_caught_exception.php | 39 +- .../test_set_user_attributes_nested_happy.php | 41 +- ...r_attributes_nested_uncaught_exception.php | 40 +- .../external/drupal6/test_span_externals.php | 6 +- .../external/drupal6/test_spans_post.php | 6 +- .../external/drupal7/test_spans_post.php | 10 +- ...est_spans_sets_external_span_correctly.php | 10 +- .../guzzle5/test_spans_external.php5.php | 114 ------ .../test_spans_are_created_correctly.php5.php | 81 ---- .../ini/test_dt_enabled_default.php | 13 +- .../ini/test_dt_enabled_default.php5.php | 76 ---- ...transaction_tracer_max_segments_nested.php | 61 +-- ...action_tracer_max_segments_nested.php5.php | 145 ------- ...ion_tracer_max_segments_with_datastore.php | 15 +- ...racer_max_segments_with_datastore.php5.php | 151 ------- .../jit/function/test_span_class_function.php | 53 +-- ..._span_events_are_created_from_segments.php | 6 +- ...n_events_are_created_upon_caught_error.php | 11 +- ...ts_are_created_upon_caught_error.php84.php | 11 +- ...test_span_events_are_created_upon_exit.php | 6 +- ...events_are_created_upon_uncaught_error.php | 5 +- ..._are_created_upon_uncaught_error.php84.php | 5 +- ...reated_upon_uncaught_handled_exception.php | 11 +- ..._upon_uncaught_handled_exception.php84.php | 11 +- ...ught_handled_exception_invalid_handler.php | 11 +- ...ated_upon_uncaught_unhandled_exception.php | 5 +- ...t_span_events_error_collector_disabled.php | 6 +- ...st_span_events_exception_caught_nested.php | 28 +- ...vents_exception_caught_nested_rethrown.php | 15 +- ...n_events_exception_caught_notice_error.php | 11 +- ...s_exception_caught_notice_error_nested.php | 26 +- ...span_events_exception_caught_same_span.php | 12 +- ..._span_events_exception_uncaught_nested.php | 15 +- .../function/test_span_events_hsm_error.php | 5 +- .../test_span_events_notice_error.php | 11 +- .../function/test_span_events_root_parent.php | 18 +- .../jit/tracing/test_span_class_function.php | 53 +-- ..._span_events_are_created_from_segments.php | 6 +- ...n_events_are_created_upon_caught_error.php | 11 +- ...ts_are_created_upon_caught_error.php84.php | 11 +- ...test_span_events_are_created_upon_exit.php | 6 +- ...events_are_created_upon_uncaught_error.php | 5 +- ..._are_created_upon_uncaught_error.php84.php | 5 +- ...reated_upon_uncaught_handled_exception.php | 11 +- ..._upon_uncaught_handled_exception.php84.php | 11 +- ...ught_handled_exception_invalid_handler.php | 11 +- ...ated_upon_uncaught_unhandled_exception.php | 5 +- ...t_span_events_error_collector_disabled.php | 6 +- ...st_span_events_exception_caught_nested.php | 28 +- ...vents_exception_caught_nested_rethrown.php | 15 +- ...n_events_exception_caught_notice_error.php | 11 +- ...s_exception_caught_notice_error_nested.php | 27 +- ...span_events_exception_caught_same_span.php | 12 +- ..._span_events_exception_uncaught_nested.php | 15 +- .../tracing/test_span_events_hsm_error.php | 5 +- .../tracing/test_span_events_notice_error.php | 11 +- .../tracing/test_span_events_root_parent.php | 18 +- .../disabled/test_span_class_function.php | 53 +-- ..._span_events_are_created_from_segments.php | 6 +- ...n_events_are_created_upon_caught_error.php | 11 +- ...ts_are_created_upon_caught_error.php84.php | 11 +- ...test_span_events_are_created_upon_exit.php | 6 +- ...events_are_created_upon_uncaught_error.php | 5 +- ..._are_created_upon_uncaught_error.php84.php | 5 +- ...reated_upon_uncaught_handled_exception.php | 11 +- ...d_upon_uncaught_handled_exception.php7.php | 11 +- ..._upon_uncaught_handled_exception.php84.php | 11 +- ...ated_upon_uncaught_unhandled_exception.php | 5 +- ...t_span_events_error_collector_disabled.php | 6 +- ...st_span_events_exception_caught_nested.php | 28 +- ...vents_exception_caught_nested_rethrown.php | 15 +- ...n_events_exception_caught_notice_error.php | 11 +- ...s_exception_caught_notice_error_nested.php | 26 +- ...span_events_exception_caught_same_span.php | 12 +- ..._span_events_exception_uncaught_nested.php | 15 +- .../disabled/test_span_events_hsm_error.php | 5 +- .../test_span_events_notice_error.php | 11 +- .../disabled/test_span_events_root_parent.php | 18 +- ..._span_events_are_created_from_segments.php | 13 +- ..._events_are_created_from_segments.php5.php | 98 ----- ...n_events_are_created_upon_caught_error.php | 14 +- ...ts_are_created_upon_caught_error.php84.php | 11 +- ...test_span_events_are_created_upon_exit.php | 13 +- ...span_events_are_created_upon_exit.php5.php | 103 ----- ...events_are_created_upon_uncaught_error.php | 8 +- ...s_are_created_upon_uncaught_error.php5.php | 121 ------ ..._are_created_upon_uncaught_error.php84.php | 5 +- ...reated_upon_uncaught_handled_exception.php | 11 +- ...d_upon_uncaught_handled_exception.php7.php | 14 +- ..._upon_uncaught_handled_exception.php84.php | 11 +- ...ated_upon_uncaught_unhandled_exception.php | 12 +- ...upon_uncaught_unhandled_exception.php5.php | 117 ------ ...t_span_events_error_collector_disabled.php | 13 +- ...n_events_error_collector_disabled.php5.php | 106 ----- ...st_span_events_exception_caught_nested.php | 35 +- ...an_events_exception_caught_nested.php5.php | 182 --------- ...vents_exception_caught_nested_rethrown.php | 22 +- ..._exception_caught_nested_rethrown.php5.php | 171 -------- ...n_events_exception_caught_notice_error.php | 18 +- ...nts_exception_caught_notice_error.php5.php | 146 ------- ...s_exception_caught_notice_error_nested.php | 34 +- ...eption_caught_notice_error_nested.php5.php | 213 ---------- ...span_events_exception_caught_same_span.php | 19 +- ...events_exception_caught_same_span.php5.php | 115 ------ ..._span_events_exception_uncaught_nested.php | 22 +- ..._events_exception_uncaught_nested.php5.php | 199 ---------- .../test_span_events_hsm_error.php | 12 +- .../test_span_events_hsm_error.php5.php | 117 ------ .../test_span_events_notice_error.php | 18 +- .../test_span_events_notice_error.php5.php | 134 ------- .../span_events/test_span_events_on_dt_on.php | 13 +- .../test_span_events_on_dt_on.php5.php | 75 ---- .../test_span_events_root_parent.php | 10 +- .../test_span_events_root_parent.php5.php | 94 ----- ..._tt_detail_off_with_custom_wrapper_api.php | 12 +- ..._detail_off_with_custom_wrapper_config.php | 12 +- .../test_tt_detail_on_with_custom_wrapper.php | 15 +- .../test_tt_detail_on_with_long_function.php | 15 +- 178 files changed, 341 insertions(+), 7567 deletions(-) delete mode 100644 tests/integration/api/add_custom_parameter/test_span_event.php5.php delete mode 100644 tests/integration/api/add_custom_span_parameter/test_span_event_parameter_duplicate.php5.php delete mode 100644 tests/integration/api/add_custom_span_parameter/test_span_event_parameter_duplicate_te_off.php5.php delete mode 100644 tests/integration/api/add_custom_span_parameter/test_span_event_parameter_filter.php5.php delete mode 100644 tests/integration/api/add_custom_span_parameter/test_span_event_parameter_filter_logging_off.php5.php delete mode 100644 tests/integration/api/add_custom_span_parameter/test_span_event_parameter_max_key.php5.php delete mode 100644 tests/integration/api/add_custom_span_parameter/test_span_event_parameter_max_key_te_off.php5.php delete mode 100644 tests/integration/api/add_custom_span_parameter/test_span_event_parameter_max_parameters.php5.php delete mode 100644 tests/integration/api/add_custom_span_parameter/test_span_event_parameter_max_value.php5.php delete mode 100644 tests/integration/api/add_custom_span_parameter/test_span_event_parameter_max_value_te_off.php5.php delete mode 100644 tests/integration/api/add_custom_span_parameter/test_span_event_parameter_maxplus_parameters.php5.php delete mode 100644 tests/integration/api/add_custom_span_parameter/test_span_event_parameter_maxplus_parameters_te_off.php5.php delete mode 100644 tests/integration/api/add_custom_span_parameter/test_span_event_parameter_maxplus_parameters_te_off_logging_off.php5.php delete mode 100644 tests/integration/api/add_custom_span_parameter/test_span_event_parameter_maxplus_span_and_te.php5.php delete mode 100644 tests/integration/api/add_custom_span_parameter/test_span_event_parameter_maxplus_span_and_te_te_off.php5.php delete mode 100644 tests/integration/api/add_custom_span_parameter/test_span_event_parameter_overwrite.php5.php delete mode 100644 tests/integration/api/add_custom_span_parameter/test_span_event_parameter_te_off.php5.php delete mode 100644 tests/integration/api/add_custom_span_parameter/test_span_event_parameter_types.php5.php delete mode 100644 tests/integration/api/distributed_trace/newrelic/test_keep_span_with_payload.php5.php delete mode 100644 tests/integration/external/guzzle5/test_spans_external.php5.php delete mode 100644 tests/integration/external/guzzle6/test_spans_are_created_correctly.php5.php delete mode 100644 tests/integration/ini/test_dt_enabled_default.php5.php delete mode 100644 tests/integration/ini/test_transaction_tracer_max_segments_nested.php5.php delete mode 100644 tests/integration/ini/test_transaction_tracer_max_segments_with_datastore.php5.php delete mode 100644 tests/integration/span_events/test_span_events_are_created_from_segments.php5.php delete mode 100644 tests/integration/span_events/test_span_events_are_created_upon_exit.php5.php delete mode 100644 tests/integration/span_events/test_span_events_are_created_upon_uncaught_error.php5.php delete mode 100644 tests/integration/span_events/test_span_events_are_created_upon_uncaught_unhandled_exception.php5.php delete mode 100644 tests/integration/span_events/test_span_events_error_collector_disabled.php5.php delete mode 100644 tests/integration/span_events/test_span_events_exception_caught_nested.php5.php delete mode 100644 tests/integration/span_events/test_span_events_exception_caught_nested_rethrown.php5.php delete mode 100644 tests/integration/span_events/test_span_events_exception_caught_notice_error.php5.php delete mode 100644 tests/integration/span_events/test_span_events_exception_caught_notice_error_nested.php5.php delete mode 100644 tests/integration/span_events/test_span_events_exception_caught_same_span.php5.php delete mode 100644 tests/integration/span_events/test_span_events_exception_uncaught_nested.php5.php delete mode 100644 tests/integration/span_events/test_span_events_hsm_error.php5.php delete mode 100644 tests/integration/span_events/test_span_events_notice_error.php5.php delete mode 100644 tests/integration/span_events/test_span_events_on_dt_on.php5.php delete mode 100644 tests/integration/span_events/test_span_events_root_parent.php5.php diff --git a/agent/php_nrini.c b/agent/php_nrini.c index d586a2bf3..37da5a820 100644 --- a/agent/php_nrini.c +++ b/agent/php_nrini.c @@ -3046,7 +3046,7 @@ STD_PHP_INI_ENTRY_EX( * Code Level Metrics */ STD_PHP_INI_ENTRY_EX("newrelic.code_level_metrics.enabled", - "1", + "0", NR_PHP_REQUEST, nr_boolean_mh, code_level_metrics_enabled, diff --git a/agent/scripts/newrelic.ini.template b/agent/scripts/newrelic.ini.template index 945b2672e..4c199f00b 100644 --- a/agent/scripts/newrelic.ini.template +++ b/agent/scripts/newrelic.ini.template @@ -1334,7 +1334,7 @@ newrelic.daemon.logfile = "/var/log/newrelic/newrelic-daemon.log" ; Setting: newrelic.code_level_metrics.enabled ; Type : boolean ; Scope : per-directory -; Default: true +; Default: false ; Info : Toggles whether the agent provides function name, function ; filepath, function namespace, and function lineno as ; attributes on reported spans @@ -1348,7 +1348,7 @@ newrelic.daemon.logfile = "/var/log/newrelic/newrelic-daemon.log" ; entirely ; c) lower the value for newrelic.span_events.max_samples_stored ; -;newrelic.code_level_metrics.enabled = true +;newrelic.code_level_metrics.enabled = false ; Setting: newrelic.vulnerability_management.package_detection.enabled ; Type : boolean diff --git a/tests/integration/api/add_custom_parameter/test_add_custom_parameter_nested_caught_exception.php b/tests/integration/api/add_custom_parameter/test_add_custom_parameter_nested_caught_exception.php index f66452c15..217fc10b2 100644 --- a/tests/integration/api/add_custom_parameter/test_add_custom_parameter_nested_caught_exception.php +++ b/tests/integration/api/add_custom_parameter/test_add_custom_parameter_nested_caught_exception.php @@ -7,13 +7,6 @@ Tests newrelic_add_custom_parameter() on a nested path that includes a caught exception. */ -/*SKIPIF - -get($url); -echo $response->getBody(); - -$response = $client->post($url, [ - 'headers' => [ - 'zip' => ' zap']]); -echo $response->getBody(); diff --git a/tests/integration/external/guzzle6/test_spans_are_created_correctly.php5.php b/tests/integration/external/guzzle6/test_spans_are_created_correctly.php5.php deleted file mode 100644 index 82b9b9911..000000000 --- a/tests/integration/external/guzzle6/test_spans_are_created_correctly.php5.php +++ /dev/null @@ -1,81 +0,0 @@ -get($url); -echo $response->getBody(); diff --git a/tests/integration/ini/test_dt_enabled_default.php b/tests/integration/ini/test_dt_enabled_default.php index 53506b04d..1fc6a8895 100644 --- a/tests/integration/ini/test_dt_enabled_default.php +++ b/tests/integration/ini/test_dt_enabled_default.php @@ -10,13 +10,6 @@ configuration is given. */ -/*SKIPIF - 'mysql', - 'collection' => 'table', - 'operation' => 'select', - 'host' => 'host.name', - 'portPathOrId' => 2222, - 'databaseName' => 'db', - 'query' => 'SELECT * FROM table WHERE foo = 42', -)); diff --git a/tests/integration/jit/function/test_span_class_function.php b/tests/integration/jit/function/test_span_class_function.php index fe8e38d1c..7da8161b5 100644 --- a/tests/integration/jit/function/test_span_class_function.php +++ b/tests/integration/jit/function/test_span_class_function.php @@ -74,11 +74,7 @@ "timestamp": "??" }, {}, - { - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "??" - } + {} ], [ { @@ -95,11 +91,7 @@ "timestamp": "??" }, {}, - { - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "??" - } + {} ], [ { @@ -116,11 +108,7 @@ "timestamp": "??" }, {}, - { - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "??" - } + {} ], [ { @@ -137,12 +125,7 @@ "timestamp": "??" }, {}, - { - "code.lineno": "??", - "code.namespace": "Classname", - "code.filepath": "__FILE__", - "code.function": "??" - } + {} ], [ { @@ -159,12 +142,7 @@ "timestamp": "??" }, {}, - { - "code.lineno": "??", - "code.namespace": "Classname", - "code.filepath": "__FILE__", - "code.function": "??" - } + {} ], [ { @@ -181,12 +159,7 @@ "timestamp": "??" }, {}, - { - "code.lineno": "??", - "code.namespace": "Classname", - "code.filepath": "__FILE__", - "code.function": "??" - } + {} ], [ { @@ -203,12 +176,7 @@ "timestamp": "??" }, {}, - { - "code.lineno": "??", - "code.namespace": "Classname", - "code.filepath": "__FILE__", - "code.function": "??" - } + {} ], [ { @@ -225,12 +193,7 @@ "timestamp": "??" }, {}, - { - "code.lineno": "??", - "code.namespace": "Classname", - "code.filepath": "__FILE__", - "code.function": "??" - } + {} ] ] ] diff --git a/tests/integration/jit/function/test_span_events_are_created_from_segments.php b/tests/integration/jit/function/test_span_events_are_created_from_segments.php index b543794bd..c4c7daff7 100644 --- a/tests/integration/jit/function/test_span_events_are_created_from_segments.php +++ b/tests/integration/jit/function/test_span_events_are_created_from_segments.php @@ -73,11 +73,7 @@ "parentId": "??" }, {}, - { - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "??" - } + {} ], [ { diff --git a/tests/integration/jit/function/test_span_events_are_created_upon_caught_error.php b/tests/integration/jit/function/test_span_events_are_created_upon_caught_error.php index 0c113528a..29c7d66fc 100644 --- a/tests/integration/jit/function/test_span_events_are_created_upon_caught_error.php +++ b/tests/integration/jit/function/test_span_events_are_created_upon_caught_error.php @@ -137,10 +137,7 @@ {}, { "error.message": "foo", - "error.class": "E_USER_ERROR", - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "??" + "error.class": "E_USER_ERROR" } ], [ @@ -158,11 +155,7 @@ "parentId": "??" }, {}, - { - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "??" - } + {} ] ] ] diff --git a/tests/integration/jit/function/test_span_events_are_created_upon_caught_error.php84.php b/tests/integration/jit/function/test_span_events_are_created_upon_caught_error.php84.php index f5ef9e41e..0b3a702f2 100644 --- a/tests/integration/jit/function/test_span_events_are_created_upon_caught_error.php84.php +++ b/tests/integration/jit/function/test_span_events_are_created_upon_caught_error.php84.php @@ -138,10 +138,7 @@ {}, { "error.message": "foo", - "error.class": "E_USER_WARNING", - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "??" + "error.class": "E_USER_WARNING" } ], [ @@ -159,11 +156,7 @@ "parentId": "??" }, {}, - { - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "??" - } + {} ] ] ] diff --git a/tests/integration/jit/function/test_span_events_are_created_upon_exit.php b/tests/integration/jit/function/test_span_events_are_created_upon_exit.php index 3274bf154..c5a278ab2 100644 --- a/tests/integration/jit/function/test_span_events_are_created_upon_exit.php +++ b/tests/integration/jit/function/test_span_events_are_created_upon_exit.php @@ -97,11 +97,7 @@ "parentId": "??" }, {}, - { - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "??" - } + {} ] ] ] diff --git a/tests/integration/jit/function/test_span_events_are_created_upon_uncaught_error.php b/tests/integration/jit/function/test_span_events_are_created_upon_uncaught_error.php index cc1fc14b3..c12ab112a 100644 --- a/tests/integration/jit/function/test_span_events_are_created_upon_uncaught_error.php +++ b/tests/integration/jit/function/test_span_events_are_created_upon_uncaught_error.php @@ -104,10 +104,7 @@ {}, { "error.message": "foo", - "error.class": "E_USER_WARNING", - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "??" + "error.class": "E_USER_WARNING" } ] ] diff --git a/tests/integration/jit/function/test_span_events_are_created_upon_uncaught_error.php84.php b/tests/integration/jit/function/test_span_events_are_created_upon_uncaught_error.php84.php index dfb8e1de2..f9feb38d5 100644 --- a/tests/integration/jit/function/test_span_events_are_created_upon_uncaught_error.php84.php +++ b/tests/integration/jit/function/test_span_events_are_created_upon_uncaught_error.php84.php @@ -105,10 +105,7 @@ {}, { "error.message": "foo", - "error.class": "E_USER_ERROR", - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "??" + "error.class": "E_USER_ERROR" } ] ] diff --git a/tests/integration/jit/function/test_span_events_are_created_upon_uncaught_handled_exception.php b/tests/integration/jit/function/test_span_events_are_created_upon_uncaught_handled_exception.php index 7624a2a4b..d22403b50 100644 --- a/tests/integration/jit/function/test_span_events_are_created_upon_uncaught_handled_exception.php +++ b/tests/integration/jit/function/test_span_events_are_created_upon_uncaught_handled_exception.php @@ -140,10 +140,7 @@ {}, { "error.message": "Uncaught exception 'RuntimeException' with message 'oops' in __FILE__:??", - "error.class": "RuntimeException", - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "a" + "error.class": "RuntimeException" } ], [ @@ -161,11 +158,7 @@ "parentId": "??" }, {}, - { - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "{closure}" - } + {} ] ] ] diff --git a/tests/integration/jit/function/test_span_events_are_created_upon_uncaught_handled_exception.php84.php b/tests/integration/jit/function/test_span_events_are_created_upon_uncaught_handled_exception.php84.php index 28099b17c..d8ba88fde 100644 --- a/tests/integration/jit/function/test_span_events_are_created_upon_uncaught_handled_exception.php84.php +++ b/tests/integration/jit/function/test_span_events_are_created_upon_uncaught_handled_exception.php84.php @@ -141,10 +141,7 @@ {}, { "error.message": "Uncaught exception 'RuntimeException' with message 'oops' in __FILE__:??", - "error.class": "RuntimeException", - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "a" + "error.class": "RuntimeException" } ], [ @@ -162,11 +159,7 @@ "parentId": "??" }, {}, - { - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "{closure:__FILE__:??}" - } + {} ] ] ] diff --git a/tests/integration/jit/function/test_span_events_are_created_upon_uncaught_handled_exception_invalid_handler.php b/tests/integration/jit/function/test_span_events_are_created_upon_uncaught_handled_exception_invalid_handler.php index fd00e971c..f62dcb4a0 100644 --- a/tests/integration/jit/function/test_span_events_are_created_upon_uncaught_handled_exception_invalid_handler.php +++ b/tests/integration/jit/function/test_span_events_are_created_upon_uncaught_handled_exception_invalid_handler.php @@ -151,10 +151,7 @@ {}, { "error.message": "Uncaught exception 'RuntimeException' with message 'oops' in __FILE__:??", - "error.class": "RuntimeException", - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "a" + "error.class": "RuntimeException" } ], [ @@ -172,11 +169,7 @@ "parentId": "??" }, {}, - { - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "{closure}" - } + {} ] ] ] diff --git a/tests/integration/jit/function/test_span_events_are_created_upon_uncaught_unhandled_exception.php b/tests/integration/jit/function/test_span_events_are_created_upon_uncaught_unhandled_exception.php index f619cab45..074113479 100644 --- a/tests/integration/jit/function/test_span_events_are_created_upon_uncaught_unhandled_exception.php +++ b/tests/integration/jit/function/test_span_events_are_created_upon_uncaught_unhandled_exception.php @@ -138,10 +138,7 @@ {}, { "error.message": "Uncaught exception 'RuntimeException' with message 'oops' in __FILE__:??", - "error.class": "RuntimeException", - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "??" + "error.class": "RuntimeException" } ] ] diff --git a/tests/integration/jit/function/test_span_events_error_collector_disabled.php b/tests/integration/jit/function/test_span_events_error_collector_disabled.php index 09a26cd9c..f57e27027 100644 --- a/tests/integration/jit/function/test_span_events_error_collector_disabled.php +++ b/tests/integration/jit/function/test_span_events_error_collector_disabled.php @@ -102,11 +102,7 @@ "parentId": "??" }, {}, - { - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "??" - } + {} ] ] ] diff --git a/tests/integration/jit/function/test_span_events_exception_caught_nested.php b/tests/integration/jit/function/test_span_events_exception_caught_nested.php index 2433f1289..5f5fb0175 100644 --- a/tests/integration/jit/function/test_span_events_exception_caught_nested.php +++ b/tests/integration/jit/function/test_span_events_exception_caught_nested.php @@ -78,11 +78,7 @@ "parentId": "??" }, {}, - { - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "??" - } + {} ], [ { @@ -99,11 +95,7 @@ "parentId": "??" }, {}, - { - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "??" - } + {} ], [ { @@ -122,10 +114,7 @@ {}, { "error.message": "Uncaught exception 'RuntimeException' with message 'Division by zero' in __FILE__:??", - "error.class": "RuntimeException", - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "??" + "error.class": "RuntimeException" } ], [ @@ -143,11 +132,7 @@ "parentId": "??" }, {}, - { - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "??" - } + {} ], [ { @@ -166,10 +151,7 @@ {}, { "error.message": "Uncaught exception 'RuntimeException' with message 'Division by zero' in __FILE__:??", - "error.class": "RuntimeException", - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "??" + "error.class": "RuntimeException" } ] ] diff --git a/tests/integration/jit/function/test_span_events_exception_caught_nested_rethrown.php b/tests/integration/jit/function/test_span_events_exception_caught_nested_rethrown.php index 036b6a55e..cbdbad0a0 100644 --- a/tests/integration/jit/function/test_span_events_exception_caught_nested_rethrown.php +++ b/tests/integration/jit/function/test_span_events_exception_caught_nested_rethrown.php @@ -109,10 +109,7 @@ {}, { "error.message": "Uncaught exception 'RuntimeException' with message 'Rethrown caught exception: Division by zero' in __FILE__:??", - "error.class": "RuntimeException", - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "??" + "error.class": "RuntimeException" } ], [ @@ -132,10 +129,7 @@ {}, { "error.message": "Uncaught exception 'RuntimeException' with message 'Division by zero' in __FILE__:??", - "error.class": "RuntimeException", - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "??" + "error.class": "RuntimeException" } ], [ @@ -155,10 +149,7 @@ {}, { "error.message": "Uncaught exception 'RuntimeException' with message 'Division by zero' in __FILE__:??", - "error.class": "RuntimeException", - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "??" + "error.class": "RuntimeException" } ] ] diff --git a/tests/integration/jit/function/test_span_events_exception_caught_notice_error.php b/tests/integration/jit/function/test_span_events_exception_caught_notice_error.php index 202479b19..c80a51370 100644 --- a/tests/integration/jit/function/test_span_events_exception_caught_notice_error.php +++ b/tests/integration/jit/function/test_span_events_exception_caught_notice_error.php @@ -104,11 +104,7 @@ "parentId": "??" }, {}, - { - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "??" - } + {} ], [ { @@ -127,10 +123,7 @@ {}, { "error.message": "Noticed exception 'Exception' with message 'Notice me' in __FILE__:??", - "error.class": "Exception", - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "??" + "error.class": "Exception" } ] ] diff --git a/tests/integration/jit/function/test_span_events_exception_caught_notice_error_nested.php b/tests/integration/jit/function/test_span_events_exception_caught_notice_error_nested.php index f182090d3..49ad17caf 100644 --- a/tests/integration/jit/function/test_span_events_exception_caught_notice_error_nested.php +++ b/tests/integration/jit/function/test_span_events_exception_caught_notice_error_nested.php @@ -104,11 +104,7 @@ "parentId": "??" }, {}, - { - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "??" - } + {} ], [ { @@ -127,10 +123,7 @@ {}, { "error.message": "Noticed exception 'Exception' with message 'Notice me' in __FILE__:??", - "error.class": "Exception", - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "??" + "error.class": "Exception" } ], [ @@ -150,10 +143,7 @@ {}, { "error.message": "Uncaught exception 'RuntimeException' with message 'Division by zero' in __FILE__:??", - "error.class": "RuntimeException", - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "??" + "error.class": "RuntimeException" } ], [ @@ -171,10 +161,7 @@ "parentId": "??" }, {}, - { - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "??"} + {} ], [ { @@ -193,10 +180,7 @@ {}, { "error.message": "Uncaught exception 'RuntimeException' with message 'Division by zero' in __FILE__:??", - "error.class": "RuntimeException", - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "??" + "error.class": "RuntimeException" } ] ] diff --git a/tests/integration/jit/function/test_span_events_exception_caught_same_span.php b/tests/integration/jit/function/test_span_events_exception_caught_same_span.php index 943b908ba..18034a3e4 100644 --- a/tests/integration/jit/function/test_span_events_exception_caught_same_span.php +++ b/tests/integration/jit/function/test_span_events_exception_caught_same_span.php @@ -77,11 +77,7 @@ "parentId": "??" }, {}, - { - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "??" - } + {} ], [ { @@ -98,11 +94,7 @@ "parentId": "??" }, {}, - { - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "??" - } + {} ] ] ] diff --git a/tests/integration/jit/function/test_span_events_exception_uncaught_nested.php b/tests/integration/jit/function/test_span_events_exception_uncaught_nested.php index d3c317994..e88794445 100644 --- a/tests/integration/jit/function/test_span_events_exception_uncaught_nested.php +++ b/tests/integration/jit/function/test_span_events_exception_uncaught_nested.php @@ -134,10 +134,7 @@ {}, { "error.message": "Uncaught exception 'RuntimeException' with message 'oops' in __FILE__:??", - "error.class": "RuntimeException", - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "??" + "error.class": "RuntimeException" } ], [ @@ -157,10 +154,7 @@ {}, { "error.message": "Uncaught exception 'RuntimeException' with message 'oops' in __FILE__:??", - "error.class": "RuntimeException", - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "??" + "error.class": "RuntimeException" } ], [ @@ -180,10 +174,7 @@ {}, { "error.message": "Uncaught exception 'RuntimeException' with message 'oops' in __FILE__:??", - "error.class": "RuntimeException", - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "??" + "error.class": "RuntimeException" } ] ] diff --git a/tests/integration/jit/function/test_span_events_hsm_error.php b/tests/integration/jit/function/test_span_events_hsm_error.php index d4814dbc0..f4be3eb32 100644 --- a/tests/integration/jit/function/test_span_events_hsm_error.php +++ b/tests/integration/jit/function/test_span_events_hsm_error.php @@ -112,10 +112,7 @@ {}, { "error.message": "Message removed by New Relic high_security setting", - "error.class": "RuntimeException", - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "??" + "error.class": "RuntimeException" } ] ] diff --git a/tests/integration/jit/function/test_span_events_notice_error.php b/tests/integration/jit/function/test_span_events_notice_error.php index adfa8b40b..22a7b1bba 100644 --- a/tests/integration/jit/function/test_span_events_notice_error.php +++ b/tests/integration/jit/function/test_span_events_notice_error.php @@ -103,11 +103,7 @@ "parentId": "??" }, {}, - { - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "??" - } + {} ], [ { @@ -126,10 +122,7 @@ {}, { "error.message": "Noticed exception 'Exception' with message 'Notice me' in __FILE__:??", - "error.class": "Exception", - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "??" + "error.class": "Exception" } ] ] diff --git a/tests/integration/jit/function/test_span_events_root_parent.php b/tests/integration/jit/function/test_span_events_root_parent.php index 1dc531ec9..15e165bbe 100644 --- a/tests/integration/jit/function/test_span_events_root_parent.php +++ b/tests/integration/jit/function/test_span_events_root_parent.php @@ -72,11 +72,7 @@ "timestamp": "??" }, {}, - { - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "??" - } + {} ], [ { @@ -93,11 +89,7 @@ "timestamp": "??" }, {}, - { - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "??" - } + {} ], [ { @@ -114,11 +106,7 @@ "timestamp": "??" }, {}, - { - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "??" - } + {} ] ] ] diff --git a/tests/integration/jit/tracing/test_span_class_function.php b/tests/integration/jit/tracing/test_span_class_function.php index 5a520f211..fbc7d6bff 100644 --- a/tests/integration/jit/tracing/test_span_class_function.php +++ b/tests/integration/jit/tracing/test_span_class_function.php @@ -73,11 +73,7 @@ "timestamp": "??" }, {}, - { - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "??" - } + {} ], [ { @@ -94,11 +90,7 @@ "timestamp": "??" }, {}, - { - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "??" - } + {} ], [ { @@ -115,11 +107,7 @@ "timestamp": "??" }, {}, - { - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "??" - } + {} ], [ { @@ -136,12 +124,7 @@ "timestamp": "??" }, {}, - { - "code.lineno": "??", - "code.namespace": "Classname", - "code.filepath": "__FILE__", - "code.function": "??" - } + {} ], [ { @@ -158,12 +141,7 @@ "timestamp": "??" }, {}, - { - "code.lineno": "??", - "code.namespace": "Classname", - "code.filepath": "__FILE__", - "code.function": "??" - } + {} ], [ { @@ -180,12 +158,7 @@ "timestamp": "??" }, {}, - { - "code.lineno": "??", - "code.namespace": "Classname", - "code.filepath": "__FILE__", - "code.function": "??" - } + {} ], [ { @@ -202,12 +175,7 @@ "timestamp": "??" }, {}, - { - "code.lineno": "??", - "code.namespace": "Classname", - "code.filepath": "__FILE__", - "code.function": "??" - } + {} ], [ { @@ -224,12 +192,7 @@ "timestamp": "??" }, {}, - { - "code.lineno": "??", - "code.namespace": "Classname", - "code.filepath": "__FILE__", - "code.function": "??" - } + {} ] ] ] diff --git a/tests/integration/jit/tracing/test_span_events_are_created_from_segments.php b/tests/integration/jit/tracing/test_span_events_are_created_from_segments.php index cc2a52753..c2c6ad491 100644 --- a/tests/integration/jit/tracing/test_span_events_are_created_from_segments.php +++ b/tests/integration/jit/tracing/test_span_events_are_created_from_segments.php @@ -73,11 +73,7 @@ "parentId": "??" }, {}, - { - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "??" - } + {} ], [ { diff --git a/tests/integration/jit/tracing/test_span_events_are_created_upon_caught_error.php b/tests/integration/jit/tracing/test_span_events_are_created_upon_caught_error.php index 74e03bf46..3b8b71ba1 100644 --- a/tests/integration/jit/tracing/test_span_events_are_created_upon_caught_error.php +++ b/tests/integration/jit/tracing/test_span_events_are_created_upon_caught_error.php @@ -136,10 +136,7 @@ {}, { "error.message": "foo", - "error.class": "E_USER_ERROR", - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "??" + "error.class": "E_USER_ERROR" } ], [ @@ -157,11 +154,7 @@ "parentId": "??" }, {}, - { - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "??" - } + {} ] ] ] diff --git a/tests/integration/jit/tracing/test_span_events_are_created_upon_caught_error.php84.php b/tests/integration/jit/tracing/test_span_events_are_created_upon_caught_error.php84.php index eeb18dc14..ef8dc18f8 100644 --- a/tests/integration/jit/tracing/test_span_events_are_created_upon_caught_error.php84.php +++ b/tests/integration/jit/tracing/test_span_events_are_created_upon_caught_error.php84.php @@ -137,10 +137,7 @@ {}, { "error.message": "foo", - "error.class": "E_USER_WARNING", - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "??" + "error.class": "E_USER_WARNING" } ], [ @@ -158,11 +155,7 @@ "parentId": "??" }, {}, - { - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "??" - } + {} ] ] ] diff --git a/tests/integration/jit/tracing/test_span_events_are_created_upon_exit.php b/tests/integration/jit/tracing/test_span_events_are_created_upon_exit.php index 176730a7f..a5fc5578c 100644 --- a/tests/integration/jit/tracing/test_span_events_are_created_upon_exit.php +++ b/tests/integration/jit/tracing/test_span_events_are_created_upon_exit.php @@ -97,11 +97,7 @@ "parentId": "??" }, {}, - { - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "??" - } + {} ] ] ] diff --git a/tests/integration/jit/tracing/test_span_events_are_created_upon_uncaught_error.php b/tests/integration/jit/tracing/test_span_events_are_created_upon_uncaught_error.php index 51f8b899a..54a5fab5e 100644 --- a/tests/integration/jit/tracing/test_span_events_are_created_upon_uncaught_error.php +++ b/tests/integration/jit/tracing/test_span_events_are_created_upon_uncaught_error.php @@ -104,10 +104,7 @@ {}, { "error.message": "foo", - "error.class": "E_USER_ERROR", - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "??" + "error.class": "E_USER_ERROR" } ] ] diff --git a/tests/integration/jit/tracing/test_span_events_are_created_upon_uncaught_error.php84.php b/tests/integration/jit/tracing/test_span_events_are_created_upon_uncaught_error.php84.php index 54660f8a3..0226a3e05 100644 --- a/tests/integration/jit/tracing/test_span_events_are_created_upon_uncaught_error.php84.php +++ b/tests/integration/jit/tracing/test_span_events_are_created_upon_uncaught_error.php84.php @@ -105,10 +105,7 @@ {}, { "error.message": "foo", - "error.class": "E_USER_WARNING", - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "??" + "error.class": "E_USER_WARNING" } ] ] diff --git a/tests/integration/jit/tracing/test_span_events_are_created_upon_uncaught_handled_exception.php b/tests/integration/jit/tracing/test_span_events_are_created_upon_uncaught_handled_exception.php index 7444c28e7..c9574865e 100644 --- a/tests/integration/jit/tracing/test_span_events_are_created_upon_uncaught_handled_exception.php +++ b/tests/integration/jit/tracing/test_span_events_are_created_upon_uncaught_handled_exception.php @@ -137,10 +137,7 @@ {}, { "error.message": "Uncaught exception 'RuntimeException' with message 'oops' in __FILE__:??", - "error.class": "RuntimeException", - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "a" + "error.class": "RuntimeException" } ], [ @@ -158,11 +155,7 @@ "parentId": "??" }, {}, - { - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "{closure}" - } + {} ] ] ] diff --git a/tests/integration/jit/tracing/test_span_events_are_created_upon_uncaught_handled_exception.php84.php b/tests/integration/jit/tracing/test_span_events_are_created_upon_uncaught_handled_exception.php84.php index 922a0c5a7..ad6affcbd 100644 --- a/tests/integration/jit/tracing/test_span_events_are_created_upon_uncaught_handled_exception.php84.php +++ b/tests/integration/jit/tracing/test_span_events_are_created_upon_uncaught_handled_exception.php84.php @@ -138,10 +138,7 @@ {}, { "error.message": "Uncaught exception 'RuntimeException' with message 'oops' in __FILE__:??", - "error.class": "RuntimeException", - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "a" + "error.class": "RuntimeException" } ], [ @@ -159,11 +156,7 @@ "parentId": "??" }, {}, - { - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "{closure:__FILE__:??}" - } + {} ] ] ] diff --git a/tests/integration/jit/tracing/test_span_events_are_created_upon_uncaught_handled_exception_invalid_handler.php b/tests/integration/jit/tracing/test_span_events_are_created_upon_uncaught_handled_exception_invalid_handler.php index bd99855b8..ddce55565 100644 --- a/tests/integration/jit/tracing/test_span_events_are_created_upon_uncaught_handled_exception_invalid_handler.php +++ b/tests/integration/jit/tracing/test_span_events_are_created_upon_uncaught_handled_exception_invalid_handler.php @@ -146,10 +146,7 @@ {}, { "error.message": "Uncaught exception 'RuntimeException' with message 'oops' in __FILE__:??", - "error.class": "RuntimeException", - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "a" + "error.class": "RuntimeException" } ], [ @@ -167,11 +164,7 @@ "parentId": "??" }, {}, - { - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "{closure}" - } + {} ] ] ] diff --git a/tests/integration/jit/tracing/test_span_events_are_created_upon_uncaught_unhandled_exception.php b/tests/integration/jit/tracing/test_span_events_are_created_upon_uncaught_unhandled_exception.php index 54269f072..00abae00d 100644 --- a/tests/integration/jit/tracing/test_span_events_are_created_upon_uncaught_unhandled_exception.php +++ b/tests/integration/jit/tracing/test_span_events_are_created_upon_uncaught_unhandled_exception.php @@ -138,10 +138,7 @@ {}, { "error.message": "Uncaught exception 'RuntimeException' with message 'oops' in __FILE__:??", - "error.class": "RuntimeException", - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "??" + "error.class": "RuntimeException" } ] ] diff --git a/tests/integration/jit/tracing/test_span_events_error_collector_disabled.php b/tests/integration/jit/tracing/test_span_events_error_collector_disabled.php index 0e6fb6db1..142b300a2 100644 --- a/tests/integration/jit/tracing/test_span_events_error_collector_disabled.php +++ b/tests/integration/jit/tracing/test_span_events_error_collector_disabled.php @@ -103,11 +103,7 @@ "parentId": "??" }, {}, - { - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "??" - } + {} ] ] ] diff --git a/tests/integration/jit/tracing/test_span_events_exception_caught_nested.php b/tests/integration/jit/tracing/test_span_events_exception_caught_nested.php index 4ff854cf2..dab7c3411 100644 --- a/tests/integration/jit/tracing/test_span_events_exception_caught_nested.php +++ b/tests/integration/jit/tracing/test_span_events_exception_caught_nested.php @@ -78,11 +78,7 @@ "parentId": "??" }, {}, - { - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "??" - } + {} ], [ { @@ -99,11 +95,7 @@ "parentId": "??" }, {}, - { - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "??" - } + {} ], [ { @@ -122,10 +114,7 @@ {}, { "error.message": "Uncaught exception 'RuntimeException' with message 'Division by zero' in __FILE__:??", - "error.class": "RuntimeException", - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "??" + "error.class": "RuntimeException" } ], [ @@ -143,11 +132,7 @@ "parentId": "??" }, {}, - { - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "??" - } + {} ], [ { @@ -166,10 +151,7 @@ {}, { "error.message": "Uncaught exception 'RuntimeException' with message 'Division by zero' in __FILE__:??", - "error.class": "RuntimeException", - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "??" + "error.class": "RuntimeException" } ] ] diff --git a/tests/integration/jit/tracing/test_span_events_exception_caught_nested_rethrown.php b/tests/integration/jit/tracing/test_span_events_exception_caught_nested_rethrown.php index 1ec6df51b..28c743e7d 100644 --- a/tests/integration/jit/tracing/test_span_events_exception_caught_nested_rethrown.php +++ b/tests/integration/jit/tracing/test_span_events_exception_caught_nested_rethrown.php @@ -109,10 +109,7 @@ {}, { "error.message": "Uncaught exception 'RuntimeException' with message 'Rethrown caught exception: Division by zero' in __FILE__:??", - "error.class": "RuntimeException", - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "??" + "error.class": "RuntimeException" } ], [ @@ -132,10 +129,7 @@ {}, { "error.message": "Uncaught exception 'RuntimeException' with message 'Division by zero' in __FILE__:??", - "error.class": "RuntimeException", - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "??" + "error.class": "RuntimeException" } ], [ @@ -155,10 +149,7 @@ {}, { "error.message": "Uncaught exception 'RuntimeException' with message 'Division by zero' in __FILE__:??", - "error.class": "RuntimeException", - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "??" + "error.class": "RuntimeException" } ] ] diff --git a/tests/integration/jit/tracing/test_span_events_exception_caught_notice_error.php b/tests/integration/jit/tracing/test_span_events_exception_caught_notice_error.php index 5b42d5280..42b75850f 100644 --- a/tests/integration/jit/tracing/test_span_events_exception_caught_notice_error.php +++ b/tests/integration/jit/tracing/test_span_events_exception_caught_notice_error.php @@ -104,11 +104,7 @@ "parentId": "??" }, {}, - { - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "??" - } + {} ], [ { @@ -127,10 +123,7 @@ {}, { "error.message": "Noticed exception 'Exception' with message 'Notice me' in __FILE__:??", - "error.class": "Exception", - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "??" + "error.class": "Exception" } ] ] diff --git a/tests/integration/jit/tracing/test_span_events_exception_caught_notice_error_nested.php b/tests/integration/jit/tracing/test_span_events_exception_caught_notice_error_nested.php index aaeb5a278..eeab19a43 100644 --- a/tests/integration/jit/tracing/test_span_events_exception_caught_notice_error_nested.php +++ b/tests/integration/jit/tracing/test_span_events_exception_caught_notice_error_nested.php @@ -104,11 +104,7 @@ "parentId": "??" }, {}, - { - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "??" - } + {} ], [ { @@ -127,10 +123,7 @@ {}, { "error.message": "Noticed exception 'Exception' with message 'Notice me' in __FILE__:??", - "error.class": "Exception", - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "??" + "error.class": "Exception" } ], [ @@ -150,10 +143,7 @@ {}, { "error.message": "Uncaught exception 'RuntimeException' with message 'Division by zero' in __FILE__:??", - "error.class": "RuntimeException", - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "??" + "error.class": "RuntimeException" } ], [ @@ -171,11 +161,7 @@ "parentId": "??" }, {}, - { - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "??" - } + {} ], [ { @@ -194,10 +180,7 @@ {}, { "error.message": "Uncaught exception 'RuntimeException' with message 'Division by zero' in __FILE__:??", - "error.class": "RuntimeException", - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "??" + "error.class": "RuntimeException" } ] ] diff --git a/tests/integration/jit/tracing/test_span_events_exception_caught_same_span.php b/tests/integration/jit/tracing/test_span_events_exception_caught_same_span.php index d92e22d16..37c5316c0 100644 --- a/tests/integration/jit/tracing/test_span_events_exception_caught_same_span.php +++ b/tests/integration/jit/tracing/test_span_events_exception_caught_same_span.php @@ -77,11 +77,7 @@ "parentId": "??" }, {}, - { - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "??" - } + {} ], [ { @@ -98,11 +94,7 @@ "parentId": "??" }, {}, - { - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "??" - } + {} ] ] ] diff --git a/tests/integration/jit/tracing/test_span_events_exception_uncaught_nested.php b/tests/integration/jit/tracing/test_span_events_exception_uncaught_nested.php index d352b174e..533b4ba62 100644 --- a/tests/integration/jit/tracing/test_span_events_exception_uncaught_nested.php +++ b/tests/integration/jit/tracing/test_span_events_exception_uncaught_nested.php @@ -135,10 +135,7 @@ {}, { "error.message": "Uncaught exception 'RuntimeException' with message 'oops' in __FILE__:??", - "error.class": "RuntimeException", - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "??" + "error.class": "RuntimeException" } ], [ @@ -158,10 +155,7 @@ {}, { "error.message": "Uncaught exception 'RuntimeException' with message 'oops' in __FILE__:??", - "error.class": "RuntimeException", - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "??" + "error.class": "RuntimeException" } ], [ @@ -181,10 +175,7 @@ {}, { "error.message": "Uncaught exception 'RuntimeException' with message 'oops' in __FILE__:??", - "error.class": "RuntimeException", - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "??" + "error.class": "RuntimeException" } ] ] diff --git a/tests/integration/jit/tracing/test_span_events_hsm_error.php b/tests/integration/jit/tracing/test_span_events_hsm_error.php index 9f75d20cb..8e31b2713 100644 --- a/tests/integration/jit/tracing/test_span_events_hsm_error.php +++ b/tests/integration/jit/tracing/test_span_events_hsm_error.php @@ -112,10 +112,7 @@ {}, { "error.message": "Message removed by New Relic high_security setting", - "error.class": "RuntimeException", - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "??" + "error.class": "RuntimeException" } ] ] diff --git a/tests/integration/jit/tracing/test_span_events_notice_error.php b/tests/integration/jit/tracing/test_span_events_notice_error.php index a626285d5..1cb17e028 100644 --- a/tests/integration/jit/tracing/test_span_events_notice_error.php +++ b/tests/integration/jit/tracing/test_span_events_notice_error.php @@ -103,11 +103,7 @@ "parentId": "??" }, {}, - { - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "??" - } + {} ], [ { @@ -126,10 +122,7 @@ {}, { "error.message": "Noticed exception 'Exception' with message 'Notice me' in __FILE__:??", - "error.class": "Exception", - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "??" + "error.class": "Exception" } ] ] diff --git a/tests/integration/jit/tracing/test_span_events_root_parent.php b/tests/integration/jit/tracing/test_span_events_root_parent.php index 1dc531ec9..15e165bbe 100644 --- a/tests/integration/jit/tracing/test_span_events_root_parent.php +++ b/tests/integration/jit/tracing/test_span_events_root_parent.php @@ -72,11 +72,7 @@ "timestamp": "??" }, {}, - { - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "??" - } + {} ], [ { @@ -93,11 +89,7 @@ "timestamp": "??" }, {}, - { - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "??" - } + {} ], [ { @@ -114,11 +106,7 @@ "timestamp": "??" }, {}, - { - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "??" - } + {} ] ] ] diff --git a/tests/integration/opcache/disabled/test_span_class_function.php b/tests/integration/opcache/disabled/test_span_class_function.php index d3438f6ec..fd81edaea 100644 --- a/tests/integration/opcache/disabled/test_span_class_function.php +++ b/tests/integration/opcache/disabled/test_span_class_function.php @@ -74,11 +74,7 @@ "timestamp": "??" }, {}, - { - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "??" - } + {} ], [ { @@ -95,11 +91,7 @@ "timestamp": "??" }, {}, - { - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "??" - } + {} ], [ { @@ -116,11 +108,7 @@ "timestamp": "??" }, {}, - { - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "??" - } + {} ], [ { @@ -137,12 +125,7 @@ "timestamp": "??" }, {}, - { - "code.lineno": "??", - "code.namespace": "Classname", - "code.filepath": "__FILE__", - "code.function": "??" - } + {} ], [ { @@ -159,12 +142,7 @@ "timestamp": "??" }, {}, - { - "code.lineno": "??", - "code.namespace": "Classname", - "code.filepath": "__FILE__", - "code.function": "??" - } + {} ], [ { @@ -181,12 +159,7 @@ "timestamp": "??" }, {}, - { - "code.lineno": "??", - "code.namespace": "Classname", - "code.filepath": "__FILE__", - "code.function": "??" - } + {} ], [ { @@ -203,12 +176,7 @@ "timestamp": "??" }, {}, - { - "code.lineno": "??", - "code.namespace": "Classname", - "code.filepath": "__FILE__", - "code.function": "??" - } + {} ], [ { @@ -225,12 +193,7 @@ "timestamp": "??" }, {}, - { - "code.lineno": "??", - "code.namespace": "Classname", - "code.filepath": "__FILE__", - "code.function": "??" - } + {} ] ] ] diff --git a/tests/integration/opcache/disabled/test_span_events_are_created_from_segments.php b/tests/integration/opcache/disabled/test_span_events_are_created_from_segments.php index 232c68835..fe780a7a3 100644 --- a/tests/integration/opcache/disabled/test_span_events_are_created_from_segments.php +++ b/tests/integration/opcache/disabled/test_span_events_are_created_from_segments.php @@ -69,11 +69,7 @@ "parentId": "??" }, {}, - { - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "??" - } + {} ], [ { diff --git a/tests/integration/opcache/disabled/test_span_events_are_created_upon_caught_error.php b/tests/integration/opcache/disabled/test_span_events_are_created_upon_caught_error.php index ce62bfc12..6ad5cc504 100644 --- a/tests/integration/opcache/disabled/test_span_events_are_created_upon_caught_error.php +++ b/tests/integration/opcache/disabled/test_span_events_are_created_upon_caught_error.php @@ -134,10 +134,7 @@ {}, { "error.message": "foo", - "error.class": "E_USER_ERROR", - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "??" + "error.class": "E_USER_ERROR" } ], [ @@ -155,11 +152,7 @@ "parentId": "??" }, {}, - { - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "??" - } + {} ] ] ] diff --git a/tests/integration/opcache/disabled/test_span_events_are_created_upon_caught_error.php84.php b/tests/integration/opcache/disabled/test_span_events_are_created_upon_caught_error.php84.php index 86c24a776..28e6ba7bf 100644 --- a/tests/integration/opcache/disabled/test_span_events_are_created_upon_caught_error.php84.php +++ b/tests/integration/opcache/disabled/test_span_events_are_created_upon_caught_error.php84.php @@ -134,10 +134,7 @@ {}, { "error.message": "foo", - "error.class": "E_USER_WARNING", - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "??" + "error.class": "E_USER_WARNING" } ], [ @@ -155,11 +152,7 @@ "parentId": "??" }, {}, - { - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "??" - } + {} ] ] ] diff --git a/tests/integration/opcache/disabled/test_span_events_are_created_upon_exit.php b/tests/integration/opcache/disabled/test_span_events_are_created_upon_exit.php index 633ce880d..131c7856f 100644 --- a/tests/integration/opcache/disabled/test_span_events_are_created_upon_exit.php +++ b/tests/integration/opcache/disabled/test_span_events_are_created_upon_exit.php @@ -93,11 +93,7 @@ "parentId": "??" }, {}, - { - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "??" - } + {} ] ] ] diff --git a/tests/integration/opcache/disabled/test_span_events_are_created_upon_uncaught_error.php b/tests/integration/opcache/disabled/test_span_events_are_created_upon_uncaught_error.php index 49320f19b..f5246a586 100644 --- a/tests/integration/opcache/disabled/test_span_events_are_created_upon_uncaught_error.php +++ b/tests/integration/opcache/disabled/test_span_events_are_created_upon_uncaught_error.php @@ -100,10 +100,7 @@ {}, { "error.message": "foo", - "error.class": "E_USER_ERROR", - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "??" + "error.class": "E_USER_ERROR" } ] ] diff --git a/tests/integration/opcache/disabled/test_span_events_are_created_upon_uncaught_error.php84.php b/tests/integration/opcache/disabled/test_span_events_are_created_upon_uncaught_error.php84.php index 35014d54f..73ba574d9 100644 --- a/tests/integration/opcache/disabled/test_span_events_are_created_upon_uncaught_error.php84.php +++ b/tests/integration/opcache/disabled/test_span_events_are_created_upon_uncaught_error.php84.php @@ -101,10 +101,7 @@ {}, { "error.message": "foo", - "error.class": "E_USER_WARNING", - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "??" + "error.class": "E_USER_WARNING" } ] ] diff --git a/tests/integration/opcache/disabled/test_span_events_are_created_upon_uncaught_handled_exception.php b/tests/integration/opcache/disabled/test_span_events_are_created_upon_uncaught_handled_exception.php index 76dd4fe41..2cdc6168d 100644 --- a/tests/integration/opcache/disabled/test_span_events_are_created_upon_uncaught_handled_exception.php +++ b/tests/integration/opcache/disabled/test_span_events_are_created_upon_uncaught_handled_exception.php @@ -139,10 +139,7 @@ {}, { "error.message": "Uncaught exception 'RuntimeException' with message 'oops' in __FILE__:??", - "error.class": "RuntimeException", - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "a" + "error.class": "RuntimeException" } ], [ @@ -160,11 +157,7 @@ "parentId": "??" }, {}, - { - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "{closure}" - } + {} ] ] ] diff --git a/tests/integration/opcache/disabled/test_span_events_are_created_upon_uncaught_handled_exception.php7.php b/tests/integration/opcache/disabled/test_span_events_are_created_upon_uncaught_handled_exception.php7.php index 67bc1b428..a6a7107d9 100644 --- a/tests/integration/opcache/disabled/test_span_events_are_created_upon_uncaught_handled_exception.php7.php +++ b/tests/integration/opcache/disabled/test_span_events_are_created_upon_uncaught_handled_exception.php7.php @@ -107,10 +107,7 @@ {}, { "error.message": "Uncaught exception 'RuntimeException' with message 'oops' in __FILE__:??", - "error.class": "RuntimeException", - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "a" + "error.class": "RuntimeException" } ], [ @@ -128,11 +125,7 @@ "parentId": "??" }, {}, - { - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "{closure}" - } + {} ] ] ] diff --git a/tests/integration/opcache/disabled/test_span_events_are_created_upon_uncaught_handled_exception.php84.php b/tests/integration/opcache/disabled/test_span_events_are_created_upon_uncaught_handled_exception.php84.php index e4be687b9..623591904 100644 --- a/tests/integration/opcache/disabled/test_span_events_are_created_upon_uncaught_handled_exception.php84.php +++ b/tests/integration/opcache/disabled/test_span_events_are_created_upon_uncaught_handled_exception.php84.php @@ -137,10 +137,7 @@ {}, { "error.message": "Uncaught exception 'RuntimeException' with message 'oops' in __FILE__:??", - "error.class": "RuntimeException", - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "a" + "error.class": "RuntimeException" } ], [ @@ -158,11 +155,7 @@ "parentId": "??" }, {}, - { - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "{closure:__FILE__:??}" - } + {} ] ] ] diff --git a/tests/integration/opcache/disabled/test_span_events_are_created_upon_uncaught_unhandled_exception.php b/tests/integration/opcache/disabled/test_span_events_are_created_upon_uncaught_unhandled_exception.php index 94b69f7a8..7c790ca39 100644 --- a/tests/integration/opcache/disabled/test_span_events_are_created_upon_uncaught_unhandled_exception.php +++ b/tests/integration/opcache/disabled/test_span_events_are_created_upon_uncaught_unhandled_exception.php @@ -134,10 +134,7 @@ {}, { "error.message": "Uncaught exception 'RuntimeException' with message 'oops' in __FILE__:??", - "error.class": "RuntimeException", - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "??" + "error.class": "RuntimeException" } ] ] diff --git a/tests/integration/opcache/disabled/test_span_events_error_collector_disabled.php b/tests/integration/opcache/disabled/test_span_events_error_collector_disabled.php index b8d5584dc..6f2f5dcdf 100644 --- a/tests/integration/opcache/disabled/test_span_events_error_collector_disabled.php +++ b/tests/integration/opcache/disabled/test_span_events_error_collector_disabled.php @@ -99,11 +99,7 @@ "parentId": "??" }, {}, - { - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "??" - } + {} ] ] ] diff --git a/tests/integration/opcache/disabled/test_span_events_exception_caught_nested.php b/tests/integration/opcache/disabled/test_span_events_exception_caught_nested.php index 41d3db2b6..710233dc9 100644 --- a/tests/integration/opcache/disabled/test_span_events_exception_caught_nested.php +++ b/tests/integration/opcache/disabled/test_span_events_exception_caught_nested.php @@ -74,11 +74,7 @@ "parentId": "??" }, {}, - { - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "??" - } + {} ], [ { @@ -95,11 +91,7 @@ "parentId": "??" }, {}, - { - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "??" - } + {} ], [ { @@ -118,10 +110,7 @@ {}, { "error.message": "Uncaught exception 'RuntimeException' with message 'Division by zero' in __FILE__:??", - "error.class": "RuntimeException", - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "??" + "error.class": "RuntimeException" } ], [ @@ -139,11 +128,7 @@ "parentId": "??" }, {}, - { - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "??" - } + {} ], [ { @@ -162,10 +147,7 @@ {}, { "error.message": "Uncaught exception 'RuntimeException' with message 'Division by zero' in __FILE__:??", - "error.class": "RuntimeException", - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "??" + "error.class": "RuntimeException" } ] ] diff --git a/tests/integration/opcache/disabled/test_span_events_exception_caught_nested_rethrown.php b/tests/integration/opcache/disabled/test_span_events_exception_caught_nested_rethrown.php index 5b5729498..921e07f8d 100644 --- a/tests/integration/opcache/disabled/test_span_events_exception_caught_nested_rethrown.php +++ b/tests/integration/opcache/disabled/test_span_events_exception_caught_nested_rethrown.php @@ -105,10 +105,7 @@ {}, { "error.message": "Uncaught exception 'RuntimeException' with message 'Rethrown caught exception: Division by zero' in __FILE__:??", - "error.class": "RuntimeException", - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "??" + "error.class": "RuntimeException" } ], [ @@ -128,10 +125,7 @@ {}, { "error.message": "Uncaught exception 'RuntimeException' with message 'Division by zero' in __FILE__:??", - "error.class": "RuntimeException", - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "??" + "error.class": "RuntimeException" } ], [ @@ -151,10 +145,7 @@ {}, { "error.message": "Uncaught exception 'RuntimeException' with message 'Division by zero' in __FILE__:??", - "error.class": "RuntimeException", - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "??" + "error.class": "RuntimeException" } ] ] diff --git a/tests/integration/opcache/disabled/test_span_events_exception_caught_notice_error.php b/tests/integration/opcache/disabled/test_span_events_exception_caught_notice_error.php index d51e9e210..552322715 100644 --- a/tests/integration/opcache/disabled/test_span_events_exception_caught_notice_error.php +++ b/tests/integration/opcache/disabled/test_span_events_exception_caught_notice_error.php @@ -100,11 +100,7 @@ "parentId": "??" }, {}, - { - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "??" - } + {} ], [ { @@ -123,10 +119,7 @@ {}, { "error.message": "Noticed exception 'Exception' with message 'Notice me' in __FILE__:??", - "error.class": "Exception", - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "??" + "error.class": "Exception" } ] ] diff --git a/tests/integration/opcache/disabled/test_span_events_exception_caught_notice_error_nested.php b/tests/integration/opcache/disabled/test_span_events_exception_caught_notice_error_nested.php index 7a3586e22..18589d6ff 100644 --- a/tests/integration/opcache/disabled/test_span_events_exception_caught_notice_error_nested.php +++ b/tests/integration/opcache/disabled/test_span_events_exception_caught_notice_error_nested.php @@ -100,11 +100,7 @@ "parentId": "??" }, {}, - { - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "??" - } + {} ], [ { @@ -123,10 +119,7 @@ {}, { "error.message": "Noticed exception 'Exception' with message 'Notice me' in __FILE__:??", - "error.class": "Exception", - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "??" + "error.class": "Exception" } ], [ @@ -146,10 +139,7 @@ {}, { "error.message": "Uncaught exception 'RuntimeException' with message 'Division by zero' in __FILE__:??", - "error.class": "RuntimeException", - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "??" + "error.class": "RuntimeException" } ], [ @@ -167,10 +157,7 @@ "parentId": "??" }, {}, - { - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "??"} + {} ], [ { @@ -189,10 +176,7 @@ {}, { "error.message": "Uncaught exception 'RuntimeException' with message 'Division by zero' in __FILE__:??", - "error.class": "RuntimeException", - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "??" + "error.class": "RuntimeException" } ] ] diff --git a/tests/integration/opcache/disabled/test_span_events_exception_caught_same_span.php b/tests/integration/opcache/disabled/test_span_events_exception_caught_same_span.php index 6de5a0aaf..580cd0db9 100644 --- a/tests/integration/opcache/disabled/test_span_events_exception_caught_same_span.php +++ b/tests/integration/opcache/disabled/test_span_events_exception_caught_same_span.php @@ -73,11 +73,7 @@ "parentId": "??" }, {}, - { - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "??" - } + {} ], [ { @@ -94,11 +90,7 @@ "parentId": "??" }, {}, - { - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "??" - } + {} ] ] ] diff --git a/tests/integration/opcache/disabled/test_span_events_exception_uncaught_nested.php b/tests/integration/opcache/disabled/test_span_events_exception_uncaught_nested.php index 658bcec9e..c9987bc5d 100644 --- a/tests/integration/opcache/disabled/test_span_events_exception_uncaught_nested.php +++ b/tests/integration/opcache/disabled/test_span_events_exception_uncaught_nested.php @@ -130,10 +130,7 @@ {}, { "error.message": "Uncaught exception 'RuntimeException' with message 'oops' in __FILE__:??", - "error.class": "RuntimeException", - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "??" + "error.class": "RuntimeException" } ], [ @@ -153,10 +150,7 @@ {}, { "error.message": "Uncaught exception 'RuntimeException' with message 'oops' in __FILE__:??", - "error.class": "RuntimeException", - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "??" + "error.class": "RuntimeException" } ], [ @@ -176,10 +170,7 @@ {}, { "error.message": "Uncaught exception 'RuntimeException' with message 'oops' in __FILE__:??", - "error.class": "RuntimeException", - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "??" + "error.class": "RuntimeException" } ] ] diff --git a/tests/integration/opcache/disabled/test_span_events_hsm_error.php b/tests/integration/opcache/disabled/test_span_events_hsm_error.php index 96fbe17e0..7589e0305 100644 --- a/tests/integration/opcache/disabled/test_span_events_hsm_error.php +++ b/tests/integration/opcache/disabled/test_span_events_hsm_error.php @@ -108,10 +108,7 @@ {}, { "error.message": "Message removed by New Relic high_security setting", - "error.class": "RuntimeException", - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "??" + "error.class": "RuntimeException" } ] ] diff --git a/tests/integration/opcache/disabled/test_span_events_notice_error.php b/tests/integration/opcache/disabled/test_span_events_notice_error.php index a5378ce38..8efdc5579 100644 --- a/tests/integration/opcache/disabled/test_span_events_notice_error.php +++ b/tests/integration/opcache/disabled/test_span_events_notice_error.php @@ -99,11 +99,7 @@ "parentId": "??" }, {}, - { - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "??" - } + {} ], [ { @@ -122,10 +118,7 @@ {}, { "error.message": "Noticed exception 'Exception' with message 'Notice me' in __FILE__:??", - "error.class": "Exception", - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "??" + "error.class": "Exception" } ] ] diff --git a/tests/integration/opcache/disabled/test_span_events_root_parent.php b/tests/integration/opcache/disabled/test_span_events_root_parent.php index 0f9a68af7..0d7f11d7d 100644 --- a/tests/integration/opcache/disabled/test_span_events_root_parent.php +++ b/tests/integration/opcache/disabled/test_span_events_root_parent.php @@ -68,11 +68,7 @@ "timestamp": "??" }, {}, - { - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "??" - } + {} ], [ { @@ -89,11 +85,7 @@ "timestamp": "??" }, {}, - { - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "??" - } + {} ], [ { @@ -110,11 +102,7 @@ "timestamp": "??" }, {}, - { - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "??" - } + {} ] ] ] diff --git a/tests/integration/span_events/test_span_events_are_created_from_segments.php b/tests/integration/span_events/test_span_events_are_created_from_segments.php index 4457d1ff4..43bbc0aa4 100644 --- a/tests/integration/span_events/test_span_events_are_created_from_segments.php +++ b/tests/integration/span_events/test_span_events_are_created_from_segments.php @@ -8,13 +8,6 @@ Test that span events are correctly created from any eligible segment. */ -/*SKIPIF - 'FakeDB', -)); diff --git a/tests/integration/span_events/test_span_events_are_created_upon_caught_error.php b/tests/integration/span_events/test_span_events_are_created_upon_caught_error.php index 56e161179..0c9b15c1d 100644 --- a/tests/integration/span_events/test_span_events_are_created_upon_caught_error.php +++ b/tests/integration/span_events/test_span_events_are_created_upon_caught_error.php @@ -11,9 +11,6 @@ /*SKIPIF =")) { die("skip: newer test for PHP 8.4+\n"); } @@ -94,10 +91,7 @@ {}, { "error.message": "foo", - "error.class": "E_USER_ERROR", - "code.lineno": 139, - "code.filepath": "__FILE__", - "code.function": "a" + "error.class": "E_USER_ERROR" } ], [ @@ -115,11 +109,7 @@ "parentId": "??" }, {}, - { - "code.lineno": 133, - "code.filepath": "__FILE__", - "code.function": "{closure}" - } + {} ] ] ] diff --git a/tests/integration/span_events/test_span_events_are_created_upon_caught_error.php84.php b/tests/integration/span_events/test_span_events_are_created_upon_caught_error.php84.php index fabe4bddd..8e621eae4 100644 --- a/tests/integration/span_events/test_span_events_are_created_upon_caught_error.php84.php +++ b/tests/integration/span_events/test_span_events_are_created_upon_caught_error.php84.php @@ -92,10 +92,7 @@ {}, { "error.message": "foo", - "error.class": "E_USER_WARNING", - "code.lineno": 137, - "code.filepath": "__FILE__", - "code.function": "a" + "error.class": "E_USER_WARNING" } ], [ @@ -113,11 +110,7 @@ "parentId": "??" }, {}, - { - "code.lineno": 131, - "code.filepath": "__FILE__", - "code.function": "{closure:__FILE__:??}" - } + {} ] ] ] diff --git a/tests/integration/span_events/test_span_events_are_created_upon_exit.php b/tests/integration/span_events/test_span_events_are_created_upon_exit.php index 9e47469eb..30c291f72 100644 --- a/tests/integration/span_events/test_span_events_are_created_upon_exit.php +++ b/tests/integration/span_events/test_span_events_are_created_upon_exit.php @@ -9,13 +9,6 @@ when exit() is called. */ -/*SKIPIF - 'FakeDB', - ) -); -a(); diff --git a/tests/integration/span_events/test_span_events_are_created_upon_uncaught_error.php b/tests/integration/span_events/test_span_events_are_created_upon_uncaught_error.php index a41838d3e..cd5284b69 100644 --- a/tests/integration/span_events/test_span_events_are_created_upon_uncaught_error.php +++ b/tests/integration/span_events/test_span_events_are_created_upon_uncaught_error.php @@ -11,9 +11,6 @@ /*SKIPIF =")) { die("skip: newer test for PHP 8.4\n"); } @@ -94,10 +91,7 @@ {}, { "error.message": "foo", - "error.class": "E_USER_ERROR", - "code.lineno": 111, - "code.filepath": "__FILE__", - "code.function": "a" + "error.class": "E_USER_ERROR" } ] ] diff --git a/tests/integration/span_events/test_span_events_are_created_upon_uncaught_error.php5.php b/tests/integration/span_events/test_span_events_are_created_upon_uncaught_error.php5.php deleted file mode 100644 index 3e17f5371..000000000 --- a/tests/integration/span_events/test_span_events_are_created_upon_uncaught_error.php5.php +++ /dev/null @@ -1,121 +0,0 @@ -=")) { - die("skip: newer test for PHP 8.4\n"); -} -*/ - -/*EXPECT_SPAN_EVENTS -[ - "?? agent run id", - { - "reservoir_size": 10000, - "events_seen": 3 - }, - [ - [ - { - "traceId": "??", - "duration": "??", - "transactionId": "??", - "name": "OtherTransaction\/php__FILE__", - "guid": "??", - "type": "Span", - "category": "generic", - "priority": "??", - "sampled": true, - "nr.entryPoint": true, - "timestamp": "??", - "transaction.name": "OtherTransaction\/php__FILE__" - }, - {}, - {} - ], - [ - { - "type": "Span", - "traceId": "??", - "transactionId": "??", - "sampled": true, - "priority": "??", - "name": "Datastore\/statement\/FakeDB\/other\/other", - "guid": "??", - "timestamp": "??", - "duration": "??", - "category": "datastore", - "parentId": "??", - "span.kind": "client", - "component": "FakeDB" - }, - {}, - { - "db.instance": "unknown", - "peer.hostname": "unknown", - "peer.address": "unknown:unknown" - } - ], - [ - { - "type": "Span", - "traceId": "??", - "transactionId": "??", - "sampled": true, - "priority": "??", - "name": "Custom\/a", - "guid": "??", - "timestamp": "??", - "duration": "??", - "category": "generic", - "parentId": "??" - }, - {}, - { - "error.message": "foo", - "error.class": "E_USER_ERROR" - } - ] - ] -] -*/ - -/*EXPECT_REGEX -^\s*(PHP )?Fatal error:\s*foo in .*? on line [0-9]+\s*$ -*/ - -function a() -{ - time_nanosleep(0, 100000000); - trigger_error('foo', E_USER_ERROR); -} - -newrelic_record_datastore_segment( - function () { - time_nanosleep(0, 100000000); - }, array( - 'product' => 'FakeDB', - ) -); -a(); - -echo 'this should never be printed'; diff --git a/tests/integration/span_events/test_span_events_are_created_upon_uncaught_error.php84.php b/tests/integration/span_events/test_span_events_are_created_upon_uncaught_error.php84.php index b56ef56a2..cf5c9fc4e 100644 --- a/tests/integration/span_events/test_span_events_are_created_upon_uncaught_error.php84.php +++ b/tests/integration/span_events/test_span_events_are_created_upon_uncaught_error.php84.php @@ -92,10 +92,7 @@ {}, { "error.message": "foo", - "error.class": "E_USER_WARNING", - "code.lineno": 109, - "code.filepath": "__FILE__", - "code.function": "a" + "error.class": "E_USER_WARNING" } ] ] diff --git a/tests/integration/span_events/test_span_events_are_created_upon_uncaught_handled_exception.php b/tests/integration/span_events/test_span_events_are_created_upon_uncaught_handled_exception.php index 24d3e6da2..3e0b2bcfa 100644 --- a/tests/integration/span_events/test_span_events_are_created_upon_uncaught_handled_exception.php +++ b/tests/integration/span_events/test_span_events_are_created_upon_uncaught_handled_exception.php @@ -126,10 +126,7 @@ {}, { "error.message": "Uncaught exception 'RuntimeException' with message 'oops' in __FILE__:??", - "error.class": "RuntimeException", - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "a" + "error.class": "RuntimeException" } ], [ @@ -147,11 +144,7 @@ "parentId": "??" }, {}, - { - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "{closure}" - } + {} ] ] ] diff --git a/tests/integration/span_events/test_span_events_are_created_upon_uncaught_handled_exception.php7.php b/tests/integration/span_events/test_span_events_are_created_upon_uncaught_handled_exception.php7.php index 24c64e436..79a4db1ef 100644 --- a/tests/integration/span_events/test_span_events_are_created_upon_uncaught_handled_exception.php7.php +++ b/tests/integration/span_events/test_span_events_are_created_upon_uncaught_handled_exception.php7.php @@ -11,9 +11,6 @@ /*SKIPIF =")) { die("skip: test for non-oapi agent only\n"); } @@ -96,10 +93,7 @@ {}, { "error.message": "Uncaught exception 'RuntimeException' with message 'oops' in __FILE__:??", - "error.class": "RuntimeException", - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "a" + "error.class": "RuntimeException" } ], [ @@ -117,11 +111,7 @@ "parentId": "??" }, {}, - { - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "{closure}" - } + {} ] ] ] diff --git a/tests/integration/span_events/test_span_events_are_created_upon_uncaught_handled_exception.php84.php b/tests/integration/span_events/test_span_events_are_created_upon_uncaught_handled_exception.php84.php index c9e6a3455..3210bb36c 100644 --- a/tests/integration/span_events/test_span_events_are_created_upon_uncaught_handled_exception.php84.php +++ b/tests/integration/span_events/test_span_events_are_created_upon_uncaught_handled_exception.php84.php @@ -124,10 +124,7 @@ {}, { "error.message": "Uncaught exception 'RuntimeException' with message 'oops' in __FILE__:??", - "error.class": "RuntimeException", - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "a" + "error.class": "RuntimeException" } ], [ @@ -145,11 +142,7 @@ "parentId": "??" }, {}, - { - "code.lineno": "??", - "code.filepath": "__FILE__", - "code.function": "{closure:__FILE__:??}" - } + {} ] ] ] diff --git a/tests/integration/span_events/test_span_events_are_created_upon_uncaught_unhandled_exception.php b/tests/integration/span_events/test_span_events_are_created_upon_uncaught_unhandled_exception.php index 9c5063753..1427a8f3f 100644 --- a/tests/integration/span_events/test_span_events_are_created_upon_uncaught_unhandled_exception.php +++ b/tests/integration/span_events/test_span_events_are_created_upon_uncaught_unhandled_exception.php @@ -9,13 +9,6 @@ when an uncaught exception is thrown. */ -/*SKIPIF - 'FakeDB', - ) -); -a(); - -echo 'this should never be printed'; diff --git a/tests/integration/span_events/test_span_events_error_collector_disabled.php b/tests/integration/span_events/test_span_events_error_collector_disabled.php index 9ecadc228..e9cc70123 100644 --- a/tests/integration/span_events/test_span_events_error_collector_disabled.php +++ b/tests/integration/span_events/test_span_events_error_collector_disabled.php @@ -7,13 +7,6 @@ Test that no span events error attributes are captured when error_collector is disabled */ -/*SKIPIF - 'FakeDB', - ) -); -a(); - -echo 'this should never be printed'; diff --git a/tests/integration/span_events/test_span_events_exception_caught_nested.php b/tests/integration/span_events/test_span_events_exception_caught_nested.php index b5cde73bb..a1a68019a 100644 --- a/tests/integration/span_events/test_span_events_exception_caught_nested.php +++ b/tests/integration/span_events/test_span_events_exception_caught_nested.php @@ -8,13 +8,6 @@ correctly handled. */ -/*SKIPIF -getMessage() . "\n"); - } -} - -function fraction($x) { - time_nanosleep(0, 100000000); - if (!$x) { - throw new RuntimeException('Division by zero'); - } - return 1/$x; -} - -function a() -{ - time_nanosleep(0, 100000000); - echo "Hello\n"; -}; - -a(); -b(); diff --git a/tests/integration/span_events/test_span_events_exception_caught_nested_rethrown.php b/tests/integration/span_events/test_span_events_exception_caught_nested_rethrown.php index c488afeaf..3b925e563 100644 --- a/tests/integration/span_events/test_span_events_exception_caught_nested_rethrown.php +++ b/tests/integration/span_events/test_span_events_exception_caught_nested_rethrown.php @@ -9,13 +9,6 @@ is "rethrown" is correctly handled. */ -/*SKIPIF -getMessage()); - } -} - -function fraction($x) { - time_nanosleep(0, 100000000); - if (!$x) { - throw new RuntimeException('Division by zero'); - } - return 1/$x; -} - -b(); diff --git a/tests/integration/span_events/test_span_events_exception_caught_notice_error.php b/tests/integration/span_events/test_span_events_exception_caught_notice_error.php index c9bb5bf01..6c2e569c4 100644 --- a/tests/integration/span_events/test_span_events_exception_caught_notice_error.php +++ b/tests/integration/span_events/test_span_events_exception_caught_notice_error.php @@ -9,13 +9,6 @@ called. */ -/*SKIPIF -getMessage() . "\n"); - } - newrelic_notice_error(new Exception('Notice me')); -} - -function a() -{ - time_nanosleep(0, 100000000); - echo "Hello\n"; -}; - -a(); -fraction(); diff --git a/tests/integration/span_events/test_span_events_exception_caught_notice_error_nested.php b/tests/integration/span_events/test_span_events_exception_caught_notice_error_nested.php index 58a16af17..029b5d946 100644 --- a/tests/integration/span_events/test_span_events_exception_caught_notice_error_nested.php +++ b/tests/integration/span_events/test_span_events_exception_caught_notice_error_nested.php @@ -9,13 +9,6 @@ handled when a notice error is also called. */ -/*SKIPIF -getMessage() . "\n"); - } - newrelic_notice_error(new Exception('Notice me')); -} - -function fraction($x) { - time_nanosleep(0, 100000000); - if (!$x) { - throw new RuntimeException('Division by zero'); - } - return 1/$x; -} - -function a() -{ - time_nanosleep(0, 100000000); - echo "Hello\n"; -}; - -a(); -b(); diff --git a/tests/integration/span_events/test_span_events_exception_caught_same_span.php b/tests/integration/span_events/test_span_events_exception_caught_same_span.php index 66b8e62af..c054eb746 100644 --- a/tests/integration/span_events/test_span_events_exception_caught_same_span.php +++ b/tests/integration/span_events/test_span_events_exception_caught_same_span.php @@ -8,13 +8,6 @@ Test that a caught exception is correctly handled in the same span. */ -/*SKIPIF -getMessage() . "\n"); - } -} - -function a() -{ - time_nanosleep(0, 100000000); - echo "Hello\n"; -}; - -a(); -fraction(); diff --git a/tests/integration/span_events/test_span_events_exception_uncaught_nested.php b/tests/integration/span_events/test_span_events_exception_uncaught_nested.php index 0752d1fb6..d920264c8 100644 --- a/tests/integration/span_events/test_span_events_exception_uncaught_nested.php +++ b/tests/integration/span_events/test_span_events_exception_uncaught_nested.php @@ -7,13 +7,6 @@ Test that an uncaught exception that originated from a child span is correctly handled. */ -/*SKIPIF - 'FakeDB', - ) -); -a(); - -echo 'this should never be printed'; diff --git a/tests/integration/span_events/test_span_events_hsm_error.php b/tests/integration/span_events/test_span_events_hsm_error.php index 36be49682..1f722886b 100644 --- a/tests/integration/span_events/test_span_events_hsm_error.php +++ b/tests/integration/span_events/test_span_events_hsm_error.php @@ -7,13 +7,6 @@ Test that span events error attributes conform to high security mode. */ -/*SKIPIF - Date: Tue, 5 Aug 2025 12:34:49 -0500 Subject: [PATCH 5/7] refactor(agent): improve drupal hook map error logging (#1101) Addresses https://github.com/newrelic/newrelic-php-agent/issues/1099 Enhances https://github.com/newrelic/newrelic-php-agent/pull/1100 --- agent/fw_drupal8.c | 39 +++++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/agent/fw_drupal8.c b/agent/fw_drupal8.c index 66e449694..59c1c5bc8 100644 --- a/agent/fw_drupal8.c +++ b/agent/fw_drupal8.c @@ -605,14 +605,23 @@ NR_PHP_WRAPPER_END #endif // OAPI static bool nr_is_invalid_key_val_arr(nr_php_string_hash_key_t* key, - zval* val) { - if (NULL == key || 0 == ZEND_STRING_LEN(key) - || 0 == nr_php_is_zval_valid_array(val) + zval* val, + const char* key_ident) { + if (NULL == key || 0 == ZEND_STRING_LEN(key)) { + nrl_warning(NRL_FRAMEWORK, "hookImplementationsMap[%s]: invalid key", + key_ident); + return true; + } + + if (0 == nr_php_is_zval_valid_array(val) || 0 == zend_hash_num_elements(Z_ARRVAL_P(val))) { + nrl_warning(NRL_FRAMEWORK, + "hookImplementationsMap[%s]: invalid value for key '%s'", + key_ident, NRSAFESTR(ZEND_STRING_VALUE(key))); return true; - } else { - return false; } + + return false; } /* @@ -646,25 +655,27 @@ static bool nr_drupal_hook_attribute_instrument(zval* module_handler) { ZEND_HASH_FOREACH_STR_KEY_VAL(Z_ARRVAL_P(hook_implementation_map), hook_key, hook_val) { - if (nr_is_invalid_key_val_arr(hook_key, hook_val)) { - nrl_warning(NRL_FRAMEWORK, - "hookImplementationsMap[hook]: invalid key or value"); + if (nr_is_invalid_key_val_arr(hook_key, hook_val, "hook")) { return false; } ZEND_HASH_FOREACH_STR_KEY_VAL(Z_ARRVAL_P(hook_val), class_key, class_val) { - if (nr_is_invalid_key_val_arr(class_key, class_val)) { - nrl_warning(NRL_FRAMEWORK, - "hookImplementationsMap[class]: invalid key or value"); + if (nr_is_invalid_key_val_arr(class_key, class_val, "class")) { return false; } ZEND_HASH_FOREACH_STR_KEY_VAL(Z_ARRVAL_P(class_val), method_key, module_val) { - if (NULL == method_key - || 0 == nr_php_is_zval_valid_string(module_val)) { + if (NULL == method_key) { nrl_warning(NRL_FRAMEWORK, - "hookImplementationsMap[method]: invalid key or value"); + "hookImplementationsMap[method]: invalid key"); + return false; + } + if (0 == nr_php_is_zval_valid_string(module_val)) { + nrl_warning( + NRL_FRAMEWORK, + "hookImplementationsMap[method]: invalid value for key '%s'", + NRSAFESTR(ZEND_STRING_VALUE(method_key))); return false; } From b78ac2d04d081fa831184a266a95b960f94c3e73 Mon Sep 17 00:00:00 2001 From: Michal Nowacki Date: Fri, 8 Aug 2025 15:45:47 -0400 Subject: [PATCH 6/7] fix(agent): fix legacy package detection issues (#1107) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When Composer runtime API is used to get packages information, the agent should not generate packages information using legacy methods. This solves the problem of package data detected with the help of Composer's runtime API not to be sent to the backend in environments using “once-per-process” setting. The reason for is that the first request generates package information using Composer's runtime API but every next request only generates package information using legacy method. This in conjunction with the fact that daemon is only sending the last package information received from the daemon leads to a situation that package information returned by Composer runtime API is lost and never makes it to the backend. --- agent/lib_composer.c | 25 +++++++++++++------------ agent/php_execute.c | 9 +++++---- agent/php_globals.h | 4 +--- agent/php_minit.c | 2 +- agent/php_txn.c | 4 ++++ axiom/nr_txn.c | 8 ++++++++ axiom/nr_txn.h | 10 ++++++++++ axiom/tests/test_txn.c | 33 +++++++++++++++++++++++++++++++++ 8 files changed, 75 insertions(+), 20 deletions(-) diff --git a/agent/lib_composer.c b/agent/lib_composer.c index 674bff3c3..7f2c4eca9 100644 --- a/agent/lib_composer.c +++ b/agent/lib_composer.c @@ -69,23 +69,25 @@ static int nr_execute_handle_autoload_composer_init(const char* vendor_path) { return NR_SUCCESS; } -static void nr_execute_handle_autoload_composer_get_packages_information( +static nr_composer_api_status_t +nr_execute_handle_autoload_composer_get_packages_information( const char* vendor_path) { zval retval; // This is used as a return value for zend_eval_string. // It will only be set if the result of the eval is SUCCESS. int result = FAILURE; + nr_composer_api_status_t api_status = NR_COMPOSER_API_STATUS_UNSET; // nrunlikely because this should alredy be ensured by the caller if (nrunlikely(!NRINI(vulnerability_management_package_detection_enabled))) { // do nothing when collecting package information for vulnerability // management is disabled - return; + return NR_COMPOSER_API_STATUS_INVALID_USE; } // nrunlikely because this should alredy be ensured by the caller if (nrunlikely(!NRINI(vulnerability_management_composer_api_enabled))) { // do nothing when use of composer to collect package info is disabled - return; + return NR_COMPOSER_API_STATUS_INVALID_USE; } // clang-format off @@ -124,7 +126,7 @@ static void nr_execute_handle_autoload_composer_get_packages_information( "%s - unable to initialize Composer runtime API - package info " "unavailable", __func__); - return; + return NR_COMPOSER_API_STATUS_INIT_FAILURE; } nrl_verbosedebug(NRL_INSTRUMENT, "%s - Composer runtime API available", @@ -135,13 +137,7 @@ static void nr_execute_handle_autoload_composer_get_packages_information( if (SUCCESS != result) { nrl_verbosedebug(NRL_INSTRUMENT, "%s - composer_getallrawdata.php failed", __func__); - return; - } - - if (NR_PHP_PROCESS_GLOBALS(composer_api_per_process_detection)) { - // set the per-process flag to true to avoid re-running composer api - // detection when the per-process detection is enabled. - NR_PHP_PROCESS_GLOBALS(composer_packages_detected) = 1; + return NR_COMPOSER_API_STATUS_CALL_FAILURE; } if (IS_ARRAY == Z_TYPE(retval)) { @@ -162,14 +158,17 @@ static void nr_execute_handle_autoload_composer_get_packages_information( } } ZEND_HASH_FOREACH_END(); + api_status = NR_COMPOSER_API_STATUS_PACKAGES_COLLECTED; } else { char strbuf[80]; nr_format_zval_for_debug(&retval, strbuf, 0, sizeof(strbuf) - 1, 0); nrl_verbosedebug(NRL_INSTRUMENT, "%s - installed packages is: " NRP_FMT ", not an array", __func__, NRP_ARGSTR(strbuf)); + api_status = NR_COMPOSER_API_STATUS_INVALID_RESULT; } zval_dtor(&retval); + return api_status; } static char* nr_execute_handle_autoload_composer_get_vendor_path( @@ -274,7 +273,9 @@ void nr_composer_handle_autoload(const char* filename) { NRPRG(txn)->composer_info.composer_detected = true; nr_fw_support_add_library_supportability_metric(NRPRG(txn), "Composer"); - nr_execute_handle_autoload_composer_get_packages_information(vendor_path); + NRTXN(composer_info.api_status) + = nr_execute_handle_autoload_composer_get_packages_information( + vendor_path); leave: nr_free(vendor_path); } diff --git a/agent/php_execute.c b/agent/php_execute.c index 54a7d5a57..c654402d5 100644 --- a/agent/php_execute.c +++ b/agent/php_execute.c @@ -875,12 +875,13 @@ static void nr_execute_handle_autoload(const char* filename, return; } - if (NR_PHP_PROCESS_GLOBALS(composer_api_per_process_detection) - && NR_PHP_PROCESS_GLOBALS(composer_packages_detected)) { - // do nothing if per-process detection is enabled and the flag to track - // detection is true + // clang-format off + if (NR_PHP_PROCESS_GLOBALS(composer_api_per_process_detection) && + NR_COMPOSER_API_STATUS_UNSET != NR_PHP_PROCESS_GLOBALS(composer_api_status)) { + // do nothing if per-process detection is enabled and composer api status is set return; } + // clang-format on if (!nr_striendswith(STR_AND_LEN(filename), AUTOLOAD_MAGIC_FILE, AUTOLOAD_MAGIC_FILE_LEN)) { diff --git a/agent/php_globals.h b/agent/php_globals.h index 4d0a2fe24..ea345cfa0 100644 --- a/agent/php_globals.h +++ b/agent/php_globals.h @@ -78,9 +78,7 @@ typedef struct _nrphpglobals_t { int composer_api_per_process_detection; /* Enables per-process VM package detection when Composer API is also enabled */ - int composer_packages_detected; /* Flag to indicate that Composer package - detection has run. Used in conjunction with - composer_api_per_process_detection. */ + nr_composer_api_status_t composer_api_status; /* Composer API's status */ char* docker_id; /* 64 byte hex docker ID parsed from /proc/self/mountinfo */ /* Original PHP callback pointer contents */ diff --git a/agent/php_minit.c b/agent/php_minit.c index 7cd14bc59..67561e08d 100644 --- a/agent/php_minit.c +++ b/agent/php_minit.c @@ -456,7 +456,7 @@ PHP_MINIT_FUNCTION(newrelic) { = nr_php_check_for_upgrade_license_key(); NR_PHP_PROCESS_GLOBALS(high_security) = 0; NR_PHP_PROCESS_GLOBALS(preload_framework_library_detection) = 1; - NR_PHP_PROCESS_GLOBALS(composer_packages_detected) = 0; + NR_PHP_PROCESS_GLOBALS(composer_api_status) = NR_COMPOSER_API_STATUS_UNSET; nr_php_populate_apache_process_globals(); nr_php_api_distributed_trace_register_userland_class(TSRMLS_C); /* diff --git a/agent/php_txn.c b/agent/php_txn.c index 4b92f40c6..800cfb7f2 100644 --- a/agent/php_txn.c +++ b/agent/php_txn.c @@ -1151,6 +1151,8 @@ nr_status_t nr_php_txn_begin(const char* appnames, } } + NRTXN(composer_info.api_status) = NR_PHP_PROCESS_GLOBALS(composer_api_status); + return NR_SUCCESS; } @@ -1340,6 +1342,8 @@ nr_status_t nr_php_txn_end(int ignoretxn, int in_post_deactivate TSRMLS_DC) { if (NR_FAILURE == ret) { nrl_debug(NRL_TXN, "failed to send txn"); } + NR_PHP_PROCESS_GLOBALS(composer_api_status) + = NRTXN(composer_info.api_status); } } diff --git a/axiom/nr_txn.c b/axiom/nr_txn.c index 85e7739af..60e1ea5ee 100644 --- a/axiom/nr_txn.c +++ b/axiom/nr_txn.c @@ -3539,6 +3539,14 @@ nr_php_package_t* nr_txn_add_php_package_from_source( return NULL; } + if (NR_PHP_PACKAGE_SOURCE_LEGACY == source + && NR_COMPOSER_API_STATUS_PACKAGES_COLLECTED + == txn->composer_info.api_status) { + // don't add packages from legacy source if packages have been detected + // using composer runtime api + return NULL; + } + p = nr_php_package_create_with_source(package_name, package_version, source); return nr_php_packages_add_package(txn->php_packages, p); } diff --git a/axiom/nr_txn.h b/axiom/nr_txn.h index 02d45f65f..9a29fd878 100644 --- a/axiom/nr_txn.h +++ b/axiom/nr_txn.h @@ -207,9 +207,19 @@ typedef enum _nr_cpu_usage_t { NR_CPU_USAGE_COUNT = 2 } nr_cpu_usage_t; +typedef enum { + NR_COMPOSER_API_STATUS_UNSET = 0, + NR_COMPOSER_API_STATUS_INVALID_USE = 1, + NR_COMPOSER_API_STATUS_INIT_FAILURE = 2, + NR_COMPOSER_API_STATUS_CALL_FAILURE = 3, + NR_COMPOSER_API_STATUS_PACKAGES_COLLECTED = 4, + NR_COMPOSER_API_STATUS_INVALID_RESULT = 5, +} nr_composer_api_status_t; + typedef struct _nr_composer_info_t { bool autoload_detected; bool composer_detected; + nr_composer_api_status_t api_status; } nr_composer_info_t; /* diff --git a/axiom/tests/test_txn.c b/axiom/tests/test_txn.c index adac091d2..493213206 100644 --- a/axiom/tests/test_txn.c +++ b/axiom/tests/test_txn.c @@ -8665,6 +8665,16 @@ static void test_nr_txn_add_php_package(void) { tlib_pass_if_ptr_equal( "same package name, different version, add returns same pointer", p1, p2); nr_txn_destroy(&txn); + + txn = new_txn(0); + // simulate composer api was successfully used + txn->composer_info.api_status = NR_COMPOSER_API_STATUS_PACKAGES_COLLECTED; + p1 = nr_txn_add_php_package(txn, package_name1, package_version1); + tlib_pass_if_null( + "legacy package information not added to transaction after composer api " + "was called successfully", + p1); + nr_txn_destroy(&txn); } static void test_nr_txn_add_php_package_from_source(void) { @@ -8730,6 +8740,29 @@ static void test_nr_txn_add_php_package_from_source(void) { p2->package_version); nr_txn_destroy(&txn); + + txn = new_txn(0); + // simulate composer api was successfully used + txn->composer_info.api_status = NR_COMPOSER_API_STATUS_PACKAGES_COLLECTED; + p1 = nr_txn_add_php_package_from_source(txn, package_name1, package_version1, + NR_PHP_PACKAGE_SOURCE_LEGACY); + tlib_pass_if_null( + "legacy package information not added to transaction after composer api " + "was called successfully", + p1); + p1 = nr_txn_add_php_package_from_source(txn, package_name1, package_version1, + NR_PHP_PACKAGE_SOURCE_SUGGESTION); + tlib_pass_if_not_null( + "suggestion package information added to transaction even after composer " + "api was called successfully", + p1); + p1 = nr_txn_add_php_package_from_source(txn, package_name1, package_version1, + NR_PHP_PACKAGE_SOURCE_COMPOSER); + tlib_pass_if_not_null( + "composer package information added to transaction even after composer " + "api was called successfully", + p1); + nr_txn_destroy(&txn); } static void test_nr_txn_suggest_package_supportability_metric(void) { From eb011f0bb77104369a4d2a6d2d9c7efaccd64b47 Mon Sep 17 00:00:00 2001 From: Amber Sistla Date: Fri, 8 Aug 2025 14:22:25 -0700 Subject: [PATCH 7/7] chore: Update major version for next release (#1109) --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 4b8f58769..4044f9086 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -11.11.0 +12.0.0