From 1e1c11462f04a1b84c9c4654b3ba8c46a746ab4e Mon Sep 17 00:00:00 2001 From: Riccardo Magliocchetti Date: Sun, 21 Feb 2021 18:09:56 +0100 Subject: [PATCH] plugins/php: drop PHP < 7 code Not supported upstream since years. --- plugins/php/common.h | 5 ----- plugins/php/php_plugin.c | 28 ---------------------------- plugins/php/session.c | 21 --------------------- 3 files changed, 54 deletions(-) diff --git a/plugins/php/common.h b/plugins/php/common.h index 9bf1c0690b..061b0b597a 100644 --- a/plugins/php/common.h +++ b/plugins/php/common.h @@ -3,11 +3,6 @@ #include "php_main.h" #include "php_variables.h" -#if (PHP_MAJOR_VERSION < 7) -#include "ext/standard/php_smart_str.h" -#else -#define UWSGI_PHP7 -#endif #include "ext/standard/info.h" #include "ext/session/php_session.h" diff --git a/plugins/php/php_plugin.c b/plugins/php/php_plugin.c index 16d495c004..16a0faa7d8 100644 --- a/plugins/php/php_plugin.c +++ b/plugins/php/php_plugin.c @@ -6,13 +6,8 @@ static sapi_module_struct uwsgi_sapi_module; static int uwsgi_php_init(void); -#ifdef UWSGI_PHP7 typedef size_t php_strlen_size; typedef zend_long php_long_size; -#else -typedef int php_strlen_size; -typedef uint64_t php_long_size; -#endif struct uwsgi_php { struct uwsgi_string_list *allowed_docroot; @@ -93,11 +88,7 @@ struct uwsgi_option uwsgi_php_options[] = { }; -#ifdef UWSGI_PHP7 static size_t sapi_uwsgi_ub_write(const char *str, size_t str_length TSRMLS_DC) -#else -static int sapi_uwsgi_ub_write(const char *str, uint str_length TSRMLS_DC) -#endif { struct wsgi_request *wsgi_req = (struct wsgi_request *) SG(server_context); @@ -143,11 +134,7 @@ static int sapi_uwsgi_send_headers(sapi_headers_struct *sapi_headers TSRMLS_DC) return SAPI_HEADER_SENT_SUCCESSFULLY; } -#ifdef UWSGI_PHP7 static size_t sapi_uwsgi_read_post(char *buffer, size_t count_bytes TSRMLS_DC) -#else -static int sapi_uwsgi_read_post(char *buffer, uint count_bytes TSRMLS_DC) -#endif { uint read_bytes = 0; @@ -273,9 +260,6 @@ PHP_MINIT_FUNCTION(uwsgi_php_minit) { char *name = usl->value; char *strval = equal + 1; equal = NULL; -#ifndef UWSGI_PHP7 - name_len = name_len + 1; -#endif zend_register_string_constant(name, name_len, strval, CONST_CS | CONST_PERSISTENT, module_number TSRMLS_CC); } usl = usl->next; @@ -284,11 +268,7 @@ PHP_MINIT_FUNCTION(uwsgi_php_minit) { } PHP_FUNCTION(uwsgi_version) { -#ifdef UWSGI_PHP7 RETURN_STRING(UWSGI_VERSION); -#else - RETURN_STRING(UWSGI_VERSION, 1); -#endif } PHP_FUNCTION(uwsgi_worker_id) { @@ -374,11 +354,7 @@ PHP_FUNCTION(uwsgi_cache_get) { if (value) { char *ret = estrndup(value, valsize); free(value); -#ifdef UWSGI_PHP7 RETURN_STRING(ret); -#else - RETURN_STRING(ret, 0); -#endif } RETURN_NULL(); } @@ -482,11 +458,7 @@ PHP_FUNCTION(uwsgi_rpc) { // here we do not free varargs for performance reasons char *ret = estrndup(response, size); free(response); -#ifdef UWSGI_PHP7 RETURN_STRING(ret); -#else - RETURN_STRING(ret, 0); -#endif } clear: diff --git a/plugins/php/session.c b/plugins/php/session.c index ddc375797f..cce0698559 100644 --- a/plugins/php/session.c +++ b/plugins/php/session.c @@ -12,37 +12,20 @@ PS_CLOSE_FUNC(uwsgi) { PS_READ_FUNC(uwsgi) { char *cache = PS_GET_MOD_DATA(); uint64_t valsize = 0; -#ifdef UWSGI_PHP7 char *value = uwsgi_cache_magic_get(key->val, key->len , &valsize, NULL, cache); -#else - char *value = uwsgi_cache_magic_get((char *)key, strlen((char *)key), &valsize, NULL, cache); -#endif if (!value) { *val = STR_EMPTY_ALLOC(); return SUCCESS; } -#ifdef UWSGI_PHP7 *val = zend_string_init(value, valsize, 0); -#else - char *new_val = emalloc(valsize); - memcpy(new_val, value, valsize); - free(value); - *val = new_val; - *vallen = valsize; -#endif return SUCCESS; } PS_WRITE_FUNC(uwsgi) { char *cache = PS_GET_MOD_DATA(); -#ifdef UWSGI_PHP7 if (val->len == 0) return SUCCESS; if (!uwsgi_cache_magic_set(key->val, key->len, val->val, val->len, 0, UWSGI_CACHE_FLAG_UPDATE, cache)) { -#else - if (vallen == 0) return SUCCESS; - if (!uwsgi_cache_magic_set((char *)key, strlen(key), (char *)val, vallen, 0, UWSGI_CACHE_FLAG_UPDATE, cache)) { -#endif return SUCCESS; } return FAILURE; @@ -50,14 +33,10 @@ PS_WRITE_FUNC(uwsgi) { PS_DESTROY_FUNC(uwsgi) { char *cache = PS_GET_MOD_DATA(); -#ifdef UWSGI_PHP7 if (!uwsgi_cache_magic_exists(key->val, key->len, cache)) return SUCCESS; if (!uwsgi_cache_magic_del(key->val, key->len, cache)) { -#else - if (!uwsgi_cache_magic_del((char *)key, strlen(key), cache)) { -#endif return SUCCESS; } return FAILURE;