summaryrefslogtreecommitdiffstats
path: root/yar-php82.patch
blob: 514acffe579cb52f1b8f315cc4401d63a30803a9 (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
From 15ece2444d614bac545b5d1cd7ea86a2881a9ddd Mon Sep 17 00:00:00 2001
From: Remi Collet <remi@remirepo.net>
Date: Mon, 19 Sep 2022 13:12:47 +0200
Subject: [PATCH 1/2] fix random seed check for PHP 8

---
 yar_request.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/yar_request.c b/yar_request.c
index be6a41b..59f527e 100644
--- a/yar_request.c
+++ b/yar_request.c
@@ -34,7 +34,11 @@
 yar_request_t *php_yar_request_instance(zend_string *method, zend_array *parameters, void **options) /* {{{ */ {
 	yar_request_t *request = emalloc(sizeof(yar_request_t));
 
+#if PHP_VERSION_ID < 80200
 	if (!BG(mt_rand_is_seeded)) {
+#else
+	if (!RANDOM_G(mt19937_seeded)) {
+#endif
 		php_mt_srand(GENERATE_SEED());
 	}
 

From 865d2e0615fcfb969db87f254792ec3844600280 Mon Sep 17 00:00:00 2001
From: Remi Collet <remi@remirepo.net>
Date: Mon, 19 Sep 2022 13:13:01 +0200
Subject: [PATCH 2/2] fix tests for PHP 8.2

---
 tests/yar.inc | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/tests/yar.inc b/tests/yar.inc
index d5c3693..d096f88 100644
--- a/tests/yar.inc
+++ b/tests/yar.inc
@@ -105,17 +105,19 @@ PHP;
 
 function yar_server_cleanup() {
 	$dir = dirname(__FILE__) . DIRECTORY_SEPARATOR . "htdocs";
-	$dp = opendir($dir);
-	while (($f = readdir($dp))) {
-		if (in_array($f, array('.', '..'))) {
-			continue;
-		}
-		$path = $dir . DIRECTORY_SEPARATOR . $f;
-		if (is_file($path)) {
-			unlink($path);
+	if (is_dir($dir)) {
+		$dp = opendir($dir);
+		while (($f = readdir($dp))) {
+			if (in_array($f, array('.', '..'))) {
+				continue;
+			}
+			$path = $dir . DIRECTORY_SEPARATOR . $f;
+			if (is_file($path)) {
+				unlink($path);
+			}
 		}
+		rmdir($dir);
 	}
-	rmdir($dir);
 }
 
 /* For TCP */