summaryrefslogtreecommitdiffstats
path: root/build.patch
diff options
context:
space:
mode:
Diffstat (limited to 'build.patch')
-rw-r--r--build.patch110
1 files changed, 110 insertions, 0 deletions
diff --git a/build.patch b/build.patch
new file mode 100644
index 0000000..b24db12
--- /dev/null
+++ b/build.patch
@@ -0,0 +1,110 @@
+From cbadc2e10829d02b45a7f94de3cf21b88e032bfc Mon Sep 17 00:00:00 2001
+From: James Titcumb <james@asgrim.com>
+Date: Tue, 17 Sep 2019 12:25:23 +0100
+Subject: [PATCH 3/3] Use PHP_VERSION_ID to check for existence of zif_handler
+
+---
+ zend_scoutapm.h | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/zend_scoutapm.h b/zend_scoutapm.h
+index 2d3500b..1c0bc12 100644
+--- a/zend_scoutapm.h
++++ b/zend_scoutapm.h
+@@ -50,7 +50,7 @@ ZEND_END_MODULE_GLOBALS(scoutapm)
+ #endif
+
+ /* zif_handler is not always defined, so define this roughly equivalent */
+-#ifndef zif_handler
++#if PHP_VERSION_ID < 70200
+ typedef void (*zif_handler)(INTERNAL_FUNCTION_PARAMETERS);
+ #endif
+
+
+diff --git a/zend_scoutapm.c b/zend_scoutapm.c
+index 96117c4..e32e2f9 100644
+--- a/zend_scoutapm.c
++++ b/zend_scoutapm.c
+@@ -174,10 +174,12 @@ static PHP_RINIT_FUNCTION(scoutapm)
+ */
+ static PHP_RSHUTDOWN_FUNCTION(scoutapm)
+ {
++ int i, j;
++
+ SCOUTAPM_DEBUG_MESSAGE("Freeing stacks... ");
+
+- for (int i = 0; i < SCOUTAPM_G(observed_stack_frames_count); i++) {
+- for (int j = 0; j < SCOUTAPM_G(observed_stack_frames)[i].argc; j++) {
++ for (i = 0; i < SCOUTAPM_G(observed_stack_frames_count); i++) {
++ for (j = 0; j < SCOUTAPM_G(observed_stack_frames)[i].argc; j++) {
+ zval_ptr_dtor(&(SCOUTAPM_G(observed_stack_frames)[i].argv[j]));
+ }
+ free(SCOUTAPM_G(observed_stack_frames)[i].argv);
+@@ -264,6 +266,8 @@ static double scoutapm_microtime()
+ */
+ static void record_observed_stack_frame(const char *function_name, double microtime_entered, double microtime_exited, int argc, zval *argv)
+ {
++ int i;
++
+ if (argc > 0) {
+ SCOUTAPM_DEBUG_MESSAGE("Adding observed stack frame for %s (%s) ... ", function_name, Z_STRVAL(argv[0]));
+ } else {
+@@ -280,7 +284,7 @@ static void record_observed_stack_frame(const char *function_name, double microt
+ SCOUTAPM_G(observed_stack_frames)[SCOUTAPM_G(observed_stack_frames_count)].argc = argc;
+ SCOUTAPM_G(observed_stack_frames)[SCOUTAPM_G(observed_stack_frames_count)].argv = calloc(argc, sizeof(zval));
+
+- for (int i = 0; i < argc; i++) {
++ for (i = 0; i < argc; i++) {
+ ZVAL_COPY(
+ &(SCOUTAPM_G(observed_stack_frames)[SCOUTAPM_G(observed_stack_frames_count)].argv[i]),
+ &(argv[i])
+@@ -295,6 +299,7 @@ static void record_observed_stack_frame(const char *function_name, double microt
+ Fetch all the recorded function or method calls recorded by the ScoutAPM extension. */
+ PHP_FUNCTION(scoutapm_get_calls)
+ {
++ int i, j;
+ zval item, arg_items, arg_item;
+ ZEND_PARSE_PARAMETERS_NONE();
+
+@@ -302,7 +307,7 @@ PHP_FUNCTION(scoutapm_get_calls)
+
+ array_init(return_value);
+
+- for (int i = 0; i < SCOUTAPM_G(observed_stack_frames_count); i++) {
++ for (i = 0; i < SCOUTAPM_G(observed_stack_frames_count); i++) {
+ array_init(&item);
+
+ add_assoc_str_ex(
+@@ -331,7 +336,7 @@ PHP_FUNCTION(scoutapm_get_calls)
+ );
+
+ array_init(&arg_items);
+- for (int j = 0; j < SCOUTAPM_G(observed_stack_frames)[i].argc; j++) {
++ for (j = 0; j < SCOUTAPM_G(observed_stack_frames)[i].argc; j++) {
+ /* Must copy the argument to a new zval, otherwise it gets freed and we get segfault. */
+ ZVAL_COPY(&arg_item, &(SCOUTAPM_G(observed_stack_frames)[i].argv[j]));
+ add_next_index_zval(&arg_items, &arg_item);
+diff --git a/tests/011-pdo-exec.phpt b/tests/011-pdo-exec.phpt
+index 178e18d..6f48a56 100644
+--- a/tests/011-pdo-exec.phpt
++++ b/tests/011-pdo-exec.phpt
+@@ -7,9 +7,8 @@ Calls to PDO::exec are logged
+ --FILE--
+ <?php
+ $dbh = new PDO('sqlite::memory:');
+-echo $dbh->exec("CREATE TABLE foo (col INT PRIMARY KEY)");
+-echo $dbh->exec("INSERT INTO foo (col) VALUES (1), (2) ");
+-echo "\n";
++$dbh->exec("CREATE TABLE foo (col INT PRIMARY KEY)");
++$dbh->exec("INSERT INTO foo (col) VALUES (1), (2) ");
+
+ $calls = scoutapm_get_calls();
+ var_dump($calls[0]['function']);
+@@ -18,7 +17,6 @@ var_dump($calls[1]['function']);
+ var_dump($calls[1]['argv'][0]);
+ ?>
+ --EXPECTF--
+-02
+ string(9) "PDO->exec"
+ string(38) "CREATE TABLE foo (col INT PRIMARY KEY)"
+ string(9) "PDO->exec"