summaryrefslogtreecommitdiffstats
path: root/build.patch
blob: b24db12716a52cb8c4a5579ed4b9169b87b45d26 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
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"