Skip to content

Commit

Permalink
#2440 - Fix compatibility with PHP 8.4 in kernel
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeckerson committed Nov 23, 2024
1 parent a6c7963 commit 0ddf620
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
2 changes: 2 additions & 0 deletions kernel/math.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
#include <php.h>
#include <ext/standard/php_string.h>
#include <ext/standard/php_math.h>
#if PHP_VERSION_ID < 80400
#include <ext/standard/php_rand.h>
#endif

#include "php_ext.h"
#include "kernel/main.h"
Expand Down
23 changes: 20 additions & 3 deletions kernel/string.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@

#include <ext/standard/php_smart_string.h>
#include <ext/standard/php_string.h>
#if PHP_VERSION_ID < 80400
#include <ext/standard/php_rand.h>
#include <ext/standard/php_lcg.h>
#endif
#include <ext/standard/php_http.h>
#include <ext/standard/base64.h>
#include <ext/standard/md5.h>
Expand Down Expand Up @@ -107,7 +109,11 @@ void zephir_fast_strtolower(zval *return_value, zval *str)

length = Z_STRLEN_P(str);
lower_str = estrndup(Z_STRVAL_P(str), length);
#if PHP_VERSION_ID < 80400
php_strtolower(lower_str, length);
#else
zend_str_tolower(lower_str, length);
#endif

if (use_copy) {
zval_dtor(str);
Expand Down Expand Up @@ -136,7 +142,11 @@ void zephir_fast_strtoupper(zval *return_value, zval *str)

length = Z_STRLEN_P(str);
lower_str = estrndup(Z_STRVAL_P(str), length);
#if PHP_VERSION_ID < 80400
php_strtoupper(lower_str, length);
#else
zend_str_toupper(lower_str, length);
#endif

if (use_copy) {
zval_dtor(str);
Expand Down Expand Up @@ -1052,7 +1062,6 @@ void zephir_preg_match(zval *return_value, zval *regex, zval *subject, zval *mat

/* Compile regex or get it from cache */
if ((pce = pcre_get_compiled_regex_cache(Z_STR_P(regex))) == NULL) {

if (use_copy) {
zval_dtor(subject);
}
Expand All @@ -1063,9 +1072,17 @@ void zephir_preg_match(zval *return_value, zval *regex, zval *subject, zval *mat
ZVAL_UNDEF(&tmp_matches);

if (flags != 0 || offset != 0) {
#if PHP_VERSION_ID < 80400
php_pcre_match_impl(pce, Z_STR_P(subject), return_value, &tmp_matches, global, 1, flags, offset);
#else
php_pcre_match_impl(pce, Z_STR_P(subject), return_value, &tmp_matches, global, flags, offset);
#endif
} else {
#if PHP_VERSION_ID < 80400
php_pcre_match_impl(pce, Z_STR_P(subject), return_value, &tmp_matches, global, 0, 0, 0);
#else
php_pcre_match_impl(pce, Z_STR_P(subject), return_value, &tmp_matches, global, 0, 0);
#endif
}

if (matches) {
Expand Down Expand Up @@ -1223,8 +1240,8 @@ void zephir_crc32(zval *return_value, zval *str)
int use_copy = 0;
size_t nr;
char *p;
php_uint32 crc;
php_uint32 crcinit = 0;
uint32_t crc;
uint32_t crcinit = 0;

if (Z_TYPE_P(str) != IS_STRING) {
use_copy = zend_make_printable_zval(str, &copy);
Expand Down

0 comments on commit 0ddf620

Please sign in to comment.