Skip to content

Commit

Permalink
Merge pull request #579 from remicollet/issue-php82
Browse files Browse the repository at this point in the history
Fix PHP 8.2/8.3 compatibility
  • Loading branch information
laruence authored Jun 25, 2024
2 parents abd7bdf + cd933d8 commit d8191fb
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 4 deletions.
9 changes: 9 additions & 0 deletions php_yaf.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,11 @@ extern zend_module_entry yaf_module_entry;
#else
#define YAF_WRITE_HANDLER zval *
#define YAF_WHANDLER_RET(zv) return zv
#if PHP_VERSION_ID >= 80000
HashTable *yaf_fake_get_gc(zend_object *zobj, zval **table, int *n);
#else
HashTable *yaf_fake_get_gc(zval *zobj, zval **table, int *n);
#endif
#endif

#if PHP_VERSION_ID < 80000
Expand Down Expand Up @@ -260,6 +264,11 @@ static zend_always_inline uint32_t yaf_compose_2_pathes(char *buf, zend_string *
}
#endif

/* removed in 8.3 */
#ifndef ZEND_HOT
#define ZEND_HOT
#endif

/*
* Local variables:
* tab-width: 4
Expand Down
3 changes: 3 additions & 0 deletions requests/yaf_request_simple.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,9 @@ YAF_STARTUP_FUNCTION(request_simple){
zend_class_entry ce;
YAF_INIT_CLASS_ENTRY(ce, "Yaf_Request_Simple", "Yaf\\Request\\Simple", yaf_request_simple_methods);
yaf_request_simple_ce = zend_register_internal_class_ex(&ce, yaf_request_ce);
#if PHP_VERSION_ID >= 80200
yaf_request_simple_ce->ce_flags |= ZEND_ACC_ALLOW_DYNAMIC_PROPERTIES;
#endif

return SUCCESS;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/031.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Array
)
array (
'_default' =>
Yaf_Route_Map::__set_state(array(
%saf_Route_Map::__set_state(array(
'ctl_prefer:protected' => true,
'delimiter:protected' => '##',
)),
Expand Down
2 changes: 1 addition & 1 deletion tests/issue231.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Yaf_Request_Http Object
)

)
Yaf_Request_Http::__set_state(array(
%saf_Request_Http::__set_state(array(
'method' => 'POST',
'module' => NULL,
'controller' => NULL,
Expand Down
4 changes: 3 additions & 1 deletion views/yaf_view_simple.c
Original file line number Diff line number Diff line change
Expand Up @@ -388,8 +388,10 @@ static int yaf_view_simple_eval(yaf_view_t *view, zend_string *tpl, zval * vars,
ZVAL_STR(&phtml, strpprintf(0, "?>%s", ZSTR_VAL(tpl)));
#if PHP_VERSION_ID < 80000
op_array = zend_compile_string(&phtml, eval_desc);
#else
#elif PHP_VERSION_ID < 80200
op_array = zend_compile_string(Z_STR(phtml), eval_desc);
#else
op_array = zend_compile_string(Z_STR(phtml), eval_desc, ZEND_COMPILE_POSITION_AFTER_OPEN_TAG);
#endif
zval_dtor(&phtml);
efree(eval_desc);
Expand Down
4 changes: 4 additions & 0 deletions yaf.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,11 @@ void yaf_iterator_dtor(zend_object_iterator *iter) /* {{{ */ {
/* }}} */

#if PHP_VERSION_ID >= 70400
#if PHP_VERSION_ID >= 80000
HashTable *yaf_fake_get_gc(zend_object *zobj, zval **table, int *n) /* {{{ */ {
#else
HashTable *yaf_fake_get_gc(zval *zobj, zval **table, int *n) /* {{{ */ {
#endif
*n = 0;
*table = NULL;
return NULL;
Expand Down
4 changes: 3 additions & 1 deletion yaf_application.c
Original file line number Diff line number Diff line change
Expand Up @@ -1053,8 +1053,10 @@ YAF_STARTUP_FUNCTION(application) {
yaf_application_ce->ce_flags |= ZEND_ACC_FINAL;
yaf_application_ce->serialize = zend_class_serialize_deny;
yaf_application_ce->unserialize = zend_class_unserialize_deny;
#else
#elif PHP_VERSION_ID < 80200
yaf_application_ce->ce_flags |= ZEND_ACC_FINAL | ZEND_ACC_NOT_SERIALIZABLE;
#else
yaf_application_ce->ce_flags |= ZEND_ACC_FINAL | ZEND_ACC_NOT_SERIALIZABLE | ZEND_ACC_ALLOW_DYNAMIC_PROPERTIES;
#endif

memcpy(&yaf_application_obj_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
Expand Down

0 comments on commit d8191fb

Please sign in to comment.