summaryrefslogtreecommitdiffstats
path: root/79.patch
blob: 4f5bb8f5193eb71f664fccf2688a5a1433dbe4f7 (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
From 31cd3a52fd658b857364f4afd0ca0f6ea2bfffcd Mon Sep 17 00:00:00 2001
From: Remi Collet <remi@remirepo.net>
Date: Tue, 21 Jul 2026 11:21:04 +0200
Subject: [PATCH] Fix build with PHP 8.6.0alpha2

  . The zend_parse_parameters_none_throw(), zend_parse_parameters_throw(),
    and ZEND_PARSE_PARAMS_THROW have been removed due to being misleading,
    since ZPP always throws, unless ZEND_PARSE_PARAMS_QUIET is given. Use
    the non-throw versions.

  . Added zend_bin2hex() and zend_bin2hex_str() as helper functions to remove
    dependencies on /ext/hash in various extensions.

And remove dependency on hash extension
---
 php_scrypt.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/php_scrypt.c b/php_scrypt.c
index 86c804d..f058f85 100644
--- a/php_scrypt.c
+++ b/php_scrypt.c
@@ -36,7 +36,9 @@
 #include "zend_config.w32.h"
 #endif
 
+#if PHP_VERSION_ID < 80600
 #include "ext/hash/php_hash.h"
+#endif
 #include "php_scrypt_utils.h"
 #include "php_scrypt.h"
 #include "crypto/crypto_scrypt.h"
@@ -56,7 +58,9 @@
 typedef size_t strsize_t;
 
 static const zend_module_dep scrypt_deps[] = {
+#if PHP_VERSION_ID < 80600
 	ZEND_MOD_REQUIRED("hash")
+#endif
 	ZEND_MOD_END
 };
 
@@ -134,7 +138,7 @@ PHP_FUNCTION(scrypt)
 
 	/* Get the parameters for this call */
 	raw_output = 0;
-	if (zend_parse_parameters_throw(
+	if (zend_parse_parameters(
 			ZEND_NUM_ARGS(), "ssllll|b",
 			&password, &password_len, &salt, &salt_len,
 			&phpN, &phpR, &phpP, &keyLength, &raw_output
@@ -204,7 +208,11 @@ PHP_FUNCTION(scrypt)
 	if (!raw_output) {
 		/* Encode the output in hex */
 		hex = (char*) safe_emalloc(2, keyLength, 1);
+#if PHP_VERSION_ID < 80600
 		php_hash_bin2hex(hex, buf, keyLength);
+#else
+		zend_bin2hex(hex, buf, keyLength);
+#endif
 		efree(buf);
 		hex[keyLength*2] = '\0';
 		RETVAL_STRINGL(hex, keyLength * 2);
@@ -238,7 +246,7 @@ PHP_FUNCTION(scrypt_pickparams)
 	int rc;
 
 	/* Get the parameters for this call */
-	if (zend_parse_parameters_throw(
+	if (zend_parse_parameters(
 			ZEND_NUM_ARGS(), "ldd",
 			&maxmem, &memfrac, &maxtime
 		) == FAILURE)