Skip to content

Commit 362a30c

Browse files
authored
Merge pull request #42 from remicollet/issue-php84
fix for PHP 8.4
2 parents abbe7cb + 5eec12d commit 362a30c

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

crypto.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,11 @@ PHP_MINIT_FUNCTION(crypto)
7676
zend_class_entry ce;
7777

7878
/* Register base exception */
79+
#if PHP_VERSION_ID < 70000
7980
PHP_CRYPTO_EXCEPTION_REGISTER_CE(ce, Crypto, zend_exception_get_default(TSRMLS_C));
81+
#else
82+
PHP_CRYPTO_EXCEPTION_REGISTER_CE(ce, Crypto, zend_ce_exception);
83+
#endif
8084

8185
/* Init OpenSSL algorithms */
8286
OpenSSL_add_all_algorithms();

crypto_cipher.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,11 @@ PHP_MINIT_FUNCTION(crypto_cipher)
497497
static inline void php_crypto_cipher_set_algorithm_name(zval *object,
498498
char *algorithm, phpc_str_size_t algorithm_len TSRMLS_DC)
499499
{
500+
#if PHP_VERSION_ID < 80200
500501
php_strtoupper(algorithm, algorithm_len);
502+
#else
503+
zend_str_toupper(algorithm, algorithm_len);
504+
#endif
501505
zend_update_property_stringl(php_crypto_cipher_ce, PHPC_OBJ_FOR_PROP(object),
502506
"algorithm", sizeof("algorithm")-1, algorithm, algorithm_len TSRMLS_CC);
503507
}
@@ -513,10 +517,14 @@ PHP_CRYPTO_API const EVP_CIPHER *php_crypto_get_cipher_algorithm(
513517
return NULL;
514518
}
515519

520+
#if PHP_VERSION_ID < 80200
516521
php_strtoupper(algorithm, algorithm_len);
522+
#else
523+
zend_str_toupper(algorithm, algorithm_len);
524+
#endif
517525
cipher = EVP_get_cipherbyname(algorithm);
518526
if (!cipher) {
519-
php_strtolower(algorithm, algorithm_len);
527+
zend_str_tolower(algorithm, algorithm_len);
520528
cipher = EVP_get_cipherbyname(algorithm);
521529
}
522530
return cipher;

crypto_hash.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,11 @@ PHP_MINIT_FUNCTION(crypto_hash)
319319
static inline void php_crypto_hash_set_algorithm_name(zval *object,
320320
char *algorithm, phpc_str_size_t algorithm_len TSRMLS_DC)
321321
{
322+
#if PHP_VERSION_ID < 80200
322323
php_strtoupper(algorithm, algorithm_len);
324+
#else
325+
zend_str_toupper(algorithm, algorithm_len);
326+
#endif
323327
zend_update_property_stringl(php_crypto_hash_ce, PHPC_OBJ_FOR_PROP(object),
324328
"algorithm", sizeof("algorithm")-1, algorithm, algorithm_len TSRMLS_CC);
325329
}

0 commit comments

Comments
 (0)