From 65eac8673014317289aab3c887d99fd7239d5ceb Mon Sep 17 00:00:00 2001 From: Peter Kokot Date: Fri, 2 Feb 2024 16:33:08 +0100 Subject: [PATCH] The ext/json is always available since PHP 8.0 The HAVE_JSON symbol is removed with PHP 8.4.0+. --- build/config/config.m4 | 19 +------------------ build/phalcon/config.m4 | 19 +------------------ build/phalcon/phalcon.zep.c | 38 ------------------------------------- composer.json | 1 - composer.lock | 3 +-- ext/config.m4 | 17 ----------------- ext/config.w32 | 4 ---- ext/kernel/string.c | 36 ----------------------------------- 8 files changed, 3 insertions(+), 134 deletions(-) diff --git a/build/config/config.m4 b/build/config/config.m4 index da9383d12b9..2d225109f6b 100644 --- a/build/config/config.m4 +++ b/build/config/config.m4 @@ -7,7 +7,7 @@ if test "$PHP_PHALCON" = "yes"; then PHP_STRING=$($PHP_CONFIG --version) AC_MSG_CHECKING(PHP version) - if test $PHP_VERSION -lt 70401; then + if test $PHP_VERSION -lt 80000; then AC_MSG_ERROR(PHP version $PHP_STRING is not supported) fi @@ -39,23 +39,6 @@ if test "$PHP_PHALCON" = "yes"; then [[#include "php_config.h"]] ) - AC_CHECK_DECL( - [HAVE_JSON], - [ - AC_CHECK_HEADERS( - [ext/json/php_json.h], - [ - PHP_ADD_EXTENSION_DEP([phalcon], [json]) - AC_DEFINE([ZEPHIR_USE_PHP_JSON], [1], [Whether PHP json extension is present at compile time]) - ], - , - [[#include "main/php.h"]] - ) - ], - , - [[#include "php_config.h"]] - ) - CPPFLAGS=$old_CPPFLAGS PHP_INSTALL_HEADERS([ext/phalcon], [php_phalcon.h]) diff --git a/build/phalcon/config.m4 b/build/phalcon/config.m4 index da9383d12b9..2d225109f6b 100644 --- a/build/phalcon/config.m4 +++ b/build/phalcon/config.m4 @@ -7,7 +7,7 @@ if test "$PHP_PHALCON" = "yes"; then PHP_STRING=$($PHP_CONFIG --version) AC_MSG_CHECKING(PHP version) - if test $PHP_VERSION -lt 70401; then + if test $PHP_VERSION -lt 80000; then AC_MSG_ERROR(PHP version $PHP_STRING is not supported) fi @@ -39,23 +39,6 @@ if test "$PHP_PHALCON" = "yes"; then [[#include "php_config.h"]] ) - AC_CHECK_DECL( - [HAVE_JSON], - [ - AC_CHECK_HEADERS( - [ext/json/php_json.h], - [ - PHP_ADD_EXTENSION_DEP([phalcon], [json]) - AC_DEFINE([ZEPHIR_USE_PHP_JSON], [1], [Whether PHP json extension is present at compile time]) - ], - , - [[#include "main/php.h"]] - ) - ], - , - [[#include "php_config.h"]] - ) - CPPFLAGS=$old_CPPFLAGS PHP_INSTALL_HEADERS([ext/phalcon], [php_phalcon.h]) diff --git a/build/phalcon/phalcon.zep.c b/build/phalcon/phalcon.zep.c index 919baaac5f0..99f785b0ccc 100644 --- a/build/phalcon/phalcon.zep.c +++ b/build/phalcon/phalcon.zep.c @@ -6928,10 +6928,6 @@ static void zephir_fast_array_merge(zval *return_value, zval *array1, zval *arra #if defined ZEPHIR_USE_PHP_PCRE && ZEPHIR_USE_PHP_PCRE #endif -#if defined ZEPHIR_USE_PHP_JSON && ZEPHIR_USE_PHP_JSON -#endif - - #define PH_RANDOM_ALNUM 0 #define PH_RANDOM_ALPHA 1 #define PH_RANDOM_HEXDEC 2 @@ -7934,8 +7930,6 @@ static void zephir_preg_match(zval *return_value, zval *regex, zval *subject, zv #endif /* ZEPHIR_USE_PHP_PCRE */ -#if defined ZEPHIR_USE_PHP_JSON && ZEPHIR_USE_PHP_JSON - static int zephir_json_encode(zval *return_value, zval *v, int opts) { smart_str buf = { 0 }; @@ -7968,38 +7962,6 @@ static int zephir_json_decode(zval *return_value, zval *v, zend_bool assoc) return SUCCESS; } -#else - -static int zephir_json_encode(zval *return_value, zval *v, int opts) -{ - zval zopts; - zval *params[2]; - - ZVAL_NULL(&zopts); - ZVAL_LONG(&zopts, opts); - - params[0] = v; - params[1] = &zopts; - - return zephir_return_call_function(return_value, SL("json_encode"), NULL, 0, 2, params); -} - -static int zephir_json_decode(zval *return_value, zval *v, zend_bool assoc) -{ - zval zassoc; - zval *params[2]; - - ZVAL_NULL(&zassoc); - ZVAL_BOOL(&zassoc, assoc); - - params[0] = v; - params[1] = &zassoc; - - return zephir_return_call_function(return_value, SL("json_decode"), NULL, 0, 2, params); -} - -#endif /* ZEPHIR_USE_PHP_JSON */ - static void zephir_md5(zval *return_value, zval *str) { PHP_MD5_CTX ctx; diff --git a/composer.json b/composer.json index 48aad511f2f..4a1bbc79e42 100644 --- a/composer.json +++ b/composer.json @@ -31,7 +31,6 @@ "ext-igbinary": "*", "ext-imagick": "*", "ext-intl": "*", - "ext-json": "*", "ext-libxml": "*", "ext-mbstring": "*", "ext-msgpack": "*", diff --git a/composer.lock b/composer.lock index 88604068286..f02b7968c2f 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "b72d11dba93423cc6d6c77c01c90896e", + "content-hash": "99f80ef25314b9904f4b2ca3a94b392d", "packages": [], "packages-dev": [ { @@ -6924,7 +6924,6 @@ "ext-igbinary": "*", "ext-imagick": "*", "ext-intl": "*", - "ext-json": "*", "ext-libxml": "*", "ext-mbstring": "*", "ext-msgpack": "*", diff --git a/ext/config.m4 b/ext/config.m4 index c6c7ce5736a..6d7f13072e8 100644 --- a/ext/config.m4 +++ b/ext/config.m4 @@ -660,23 +660,6 @@ if test "$PHP_PHALCON" = "yes"; then [[#include "php_config.h"]] ) - AC_CHECK_DECL( - [HAVE_JSON], - [ - AC_CHECK_HEADERS( - [ext/json/php_json.h], - [ - PHP_ADD_EXTENSION_DEP([phalcon], [json]) - AC_DEFINE([ZEPHIR_USE_PHP_JSON], [1], [Whether PHP json extension is present at compile time]) - ], - , - [[#include "main/php.h"]] - ) - ], - , - [[#include "php_config.h"]] - ) - CPPFLAGS=$old_CPPFLAGS PHP_INSTALL_HEADERS([ext/phalcon], [php_PHALCON.h]) diff --git a/ext/config.w32 b/ext/config.w32 index 5631be52d98..a627bb04e48 100644 --- a/ext/config.w32 +++ b/ext/config.w32 @@ -5,10 +5,6 @@ if (PHP_PHALCON != "no") { ADD_SOURCES(configure_module_dirname + "/kernel", "main.c memory.c exception.c debug.c backtrace.c object.c array.c string.c fcall.c require.c file.c operators.c math.c concat.c variables.c filter.c iterator.c exit.c time.c", "phalcon"); /* PCRE is always included on WIN32 */ AC_DEFINE("ZEPHIR_USE_PHP_PCRE", 1, "Whether PHP pcre extension is present at compile time"); - if (PHP_JSON != "no") { - ADD_EXTENSION_DEP("phalcon", "json"); - AC_DEFINE("ZEPHIR_USE_PHP_JSON", 1, "Whether PHP json extension is present at compile time"); - } ADD_SOURCES(configure_module_dirname + "/phalcon/annotations", "scanner.c parser.c", "phalcon"); ADD_SOURCES(configure_module_dirname + "/phalcon/mvc/model", "orm.c", "phalcon"); ADD_SOURCES(configure_module_dirname + "/phalcon/mvc/model/query", "scanner.c parser.c", "phalcon"); diff --git a/ext/kernel/string.c b/ext/kernel/string.c index 96a49a42541..d6e0bbeafc0 100644 --- a/ext/kernel/string.c +++ b/ext/kernel/string.c @@ -35,9 +35,7 @@ #include #endif -#if defined ZEPHIR_USE_PHP_JSON && ZEPHIR_USE_PHP_JSON #include -#endif #include "kernel/main.h" #include "kernel/memory.h" @@ -1128,8 +1126,6 @@ void zephir_preg_match(zval *return_value, zval *regex, zval *subject, zval *mat #endif /* ZEPHIR_USE_PHP_PCRE */ -#if defined ZEPHIR_USE_PHP_JSON && ZEPHIR_USE_PHP_JSON - int zephir_json_encode(zval *return_value, zval *v, int opts) { smart_str buf = { 0 }; @@ -1162,38 +1158,6 @@ int zephir_json_decode(zval *return_value, zval *v, zend_bool assoc) return SUCCESS; } -#else - -int zephir_json_encode(zval *return_value, zval *v, int opts) -{ - zval zopts; - zval *params[2]; - - ZVAL_NULL(&zopts); - ZVAL_LONG(&zopts, opts); - - params[0] = v; - params[1] = &zopts; - - return zephir_return_call_function(return_value, SL("json_encode"), NULL, 0, 2, params); -} - -int zephir_json_decode(zval *return_value, zval *v, zend_bool assoc) -{ - zval zassoc; - zval *params[2]; - - ZVAL_NULL(&zassoc); - ZVAL_BOOL(&zassoc, assoc); - - params[0] = v; - params[1] = &zassoc; - - return zephir_return_call_function(return_value, SL("json_decode"), NULL, 0, 2, params); -} - -#endif /* ZEPHIR_USE_PHP_JSON */ - void zephir_md5(zval *return_value, zval *str) { PHP_MD5_CTX ctx;