Skip to content

Commit 93dc91b

Browse files
committed
Remove version checks
PHP_VERSION_ID PHP_API_VERSION ZEND_MODULE_API_NO PHP_MAJOR_VERSION, PHP_MINOR_VERSION ZEND_ENGINE_2 I've left litespeed alone, as it seems to genuinely maintain support for many PHP versions.
1 parent 2eb4728 commit 93dc91b

31 files changed

+19
-475
lines changed

ext/enchant/enchant.c

-4
Original file line numberDiff line numberDiff line change
@@ -587,11 +587,7 @@ PHP_FUNCTION(enchant_broker_request_pwl_dict)
587587
RETURN_FALSE;
588588
}
589589

590-
#if PHP_API_VERSION < 20100412
591-
if ((PG(safe_mode) && (!php_checkuid(pwl, NULL, CHECKUID_CHECK_FILE_AND_DIR))) || php_check_open_basedir(pwl)) {
592-
#else
593590
if (php_check_open_basedir(pwl)) {
594-
#endif
595591
RETURN_FALSE;
596592
}
597593

ext/fileinfo/fileinfo.c

-4
Original file line numberDiff line numberDiff line change
@@ -548,11 +548,7 @@ static void _php_finfo_get_type(INTERNAL_FUNCTION_PARAMETERS, int mode, int mime
548548
}
549549
#endif
550550

551-
#if PHP_API_VERSION < 20100412
552-
stream = php_stream_open_wrapper_ex(buffer, "rb", ENFORCE_SAFE_MODE | REPORT_ERRORS, NULL, context);
553-
#else
554551
stream = php_stream_open_wrapper_ex(buffer, "rb", REPORT_ERRORS, NULL, context);
555-
#endif
556552

557553
if (!stream) {
558554
RETVAL_FALSE;

ext/hash/hash.c

+2-8
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,6 @@
3131
static int php_hash_le_hash;
3232
HashTable php_hash_hashtable;
3333

34-
#if (PHP_MAJOR_VERSION >= 5)
35-
# define DEFAULT_CONTEXT FG(default_context)
36-
#else
37-
# define DEFAULT_CONTEXT NULL
38-
#endif
39-
4034
#ifdef PHP_MHASH_BC
4135
struct mhash_bc_entry {
4236
char *mhash_name;
@@ -140,7 +134,7 @@ static void php_hash_do_hash(INTERNAL_FUNCTION_PARAMETERS, int isfilename, zend_
140134
php_error_docref(NULL, E_WARNING, "Invalid path");
141135
RETURN_FALSE;
142136
}
143-
stream = php_stream_open_wrapper_ex(data, "rb", REPORT_ERRORS, NULL, DEFAULT_CONTEXT);
137+
stream = php_stream_open_wrapper_ex(data, "rb", REPORT_ERRORS, NULL, FG(default_context));
144138
if (!stream) {
145139
/* Stream will report errors opening file */
146140
RETURN_FALSE;
@@ -259,7 +253,7 @@ static void php_hash_do_hash_hmac(INTERNAL_FUNCTION_PARAMETERS, int isfilename,
259253
php_error_docref(NULL, E_WARNING, "Invalid path");
260254
RETURN_FALSE;
261255
}
262-
stream = php_stream_open_wrapper_ex(data, "rb", REPORT_ERRORS, NULL, DEFAULT_CONTEXT);
256+
stream = php_stream_open_wrapper_ex(data, "rb", REPORT_ERRORS, NULL, FG(default_context));
263257
if (!stream) {
264258
/* Stream will report errors opening file */
265259
RETURN_FALSE;

ext/intl/collator/collator_convert.c

+1-7
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,6 @@
2828
#include <unicode/ustring.h>
2929
#include <php.h>
3030

31-
#if PHP_VERSION_ID <= 50100
32-
#define CAST_OBJECT_SHOULD_FREE ,0
33-
#else
34-
#define CAST_OBJECT_SHOULD_FREE
35-
#endif
36-
3731
#define COLLATOR_CONVERT_RETURN_FAILED(retval) { \
3832
Z_TRY_ADDREF_P(retval); \
3933
return retval; \
@@ -258,7 +252,7 @@ zval* collator_convert_object_to_string( zval* obj, zval *rv )
258252
{
259253
zstr = rv;
260254

261-
if( Z_OBJ_HT_P(obj)->cast_object( obj, zstr, IS_STRING CAST_OBJECT_SHOULD_FREE ) == FAILURE )
255+
if( Z_OBJ_HT_P(obj)->cast_object( obj, zstr, IS_STRING ) == FAILURE )
262256
{
263257
/* cast_object failed => bail out. */
264258
zval_ptr_dtor( zstr );

ext/intl/collator/collator_is_numeric.c

+2-13
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,6 @@
1717

1818
#include "collator_is_numeric.h"
1919

20-
#if ZEND_MODULE_API_NO < 20071006
21-
/* not 5.3 */
22-
#ifndef ALLOCA_FLAG
23-
#define ALLOCA_FLAG(use_heap)
24-
#endif
25-
#define _do_alloca(x, y) do_alloca((x))
26-
#define _free_alloca(x, y) free_alloca((x))
27-
#else
28-
#define _do_alloca do_alloca
29-
#define _free_alloca free_alloca
30-
#endif
3120
/* {{{ collator_u_strtod
3221
* Taken from PHP6:zend_u_strtod()
3322
*/
@@ -87,7 +76,7 @@ static double collator_u_strtod(const UChar *nptr, UChar **endptr) /* {{{ */
8776
if (length < sizeof(buf)) {
8877
numbuf = buf;
8978
} else {
90-
numbuf = (char *) _do_alloca(length + 1, use_heap);
79+
numbuf = (char *) do_alloca(length + 1, use_heap);
9180
}
9281

9382
bufpos = numbuf;
@@ -100,7 +89,7 @@ static double collator_u_strtod(const UChar *nptr, UChar **endptr) /* {{{ */
10089
value = zend_strtod(numbuf, NULL);
10190

10291
if (numbuf != buf) {
103-
_free_alloca(numbuf, use_heap);
92+
free_alloca(numbuf, use_heap);
10493
}
10594

10695
if (endptr != NULL) {

ext/mysqli/mysqli.c

-2
Original file line numberDiff line numberDiff line change
@@ -583,9 +583,7 @@ PHP_MINIT_FUNCTION(mysqli)
583583
mysqli_object_handlers.write_property = mysqli_write_property;
584584
mysqli_object_handlers.get_property_ptr_ptr = std_hnd->get_property_ptr_ptr;
585585
mysqli_object_handlers.has_property = mysqli_object_has_property;
586-
#if PHP_VERSION_ID >= 50300
587586
mysqli_object_handlers.get_debug_info = mysqli_object_get_debug_info;
588-
#endif
589587
memcpy(&mysqli_object_driver_handlers, &mysqli_object_handlers, sizeof(zend_object_handlers));
590588
mysqli_object_driver_handlers.free_obj = mysqli_driver_free_storage;
591589
memcpy(&mysqli_object_link_handlers, &mysqli_object_handlers, sizeof(zend_object_handlers));

ext/mysqli/mysqli_api.c

-8
Original file line numberDiff line numberDiff line change
@@ -1697,10 +1697,6 @@ static int mysqli_options_get_option_zval_type(int option)
16971697
{
16981698
switch (option) {
16991699
#ifdef MYSQLI_USE_MYSQLND
1700-
#if PHP_MAJOR_VERSION == 6
1701-
/* PHP-7 doesn't supprt unicode */
1702-
case MYSQLND_OPT_NUMERIC_AND_DATETIME_AS_UNICODE:
1703-
#endif
17041700
case MYSQLND_OPT_NET_CMD_BUFFER_SIZE:
17051701
case MYSQLND_OPT_NET_READ_BUFFER_SIZE:
17061702
#ifdef MYSQLND_STRING_TO_INT_CONVERSION
@@ -1781,11 +1777,7 @@ PHP_FUNCTION(mysqli_options)
17811777
MYSQLI_FETCH_RESOURCE_CONN(mysql, mysql_link, MYSQLI_STATUS_INITIALIZED);
17821778

17831779
#if !defined(MYSQLI_USE_MYSQLND)
1784-
#if PHP_API_VERSION < 20100412
1785-
if ((PG(open_basedir) && PG(open_basedir)[0] != '\0') || PG(safe_mode)) {
1786-
#else
17871780
if (PG(open_basedir) && PG(open_basedir)[0] != '\0') {
1788-
#endif
17891781
if(mysql_option == MYSQL_OPT_LOCAL_INFILE) {
17901782
RETURN_FALSE;
17911783
}

ext/mysqli/mysqli_fe.c

-4
Original file line numberDiff line numberDiff line change
@@ -243,18 +243,14 @@ ZEND_END_ARG_INFO()
243243

244244

245245
ZEND_BEGIN_ARG_INFO_EX(arginfo_mysqli_fetch_object, 0, 0, 1)
246-
#if PHP_VERSION_ID > 50399
247246
MYSQLI_ZEND_ARG_OBJ_INFO_RESULT()
248247
ZEND_ARG_INFO(0, class_name)
249248
ZEND_ARG_ARRAY_INFO(0, params, 0)
250-
#endif
251249
ZEND_END_ARG_INFO()
252250

253251
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_mysqli_fetch_object, 0, 0, 0)
254-
#if PHP_VERSION_ID > 50399
255252
ZEND_ARG_INFO(0, class_name)
256253
ZEND_ARG_ARRAY_INFO(0, params, 0)
257-
#endif
258254
ZEND_END_ARG_INFO()
259255

260256
ZEND_BEGIN_ARG_INFO_EX(arginfo_mysqli_kill, 0, 0, 2)

ext/mysqlnd/mysqlnd_net.c

-16
Original file line numberDiff line numberDiff line change
@@ -133,11 +133,7 @@ MYSQLND_METHOD(mysqlnd_net, open_pipe)(MYSQLND_NET * const net, const char * con
133133
const zend_bool persistent,
134134
MYSQLND_STATS * const conn_stats, MYSQLND_ERROR_INFO * const error_info)
135135
{
136-
#if PHP_API_VERSION < 20100412
137-
unsigned int streams_options = ENFORCE_SAFE_MODE;
138-
#else
139136
unsigned int streams_options = 0;
140-
#endif
141137
dtor_func_t origin_dtor;
142138
php_stream * net_stream = NULL;
143139

@@ -173,11 +169,7 @@ MYSQLND_METHOD(mysqlnd_net, open_tcp_or_unix)(MYSQLND_NET * const net, const cha
173169
const zend_bool persistent,
174170
MYSQLND_STATS * const conn_stats, MYSQLND_ERROR_INFO * const error_info)
175171
{
176-
#if PHP_API_VERSION < 20100412
177-
unsigned int streams_options = ENFORCE_SAFE_MODE;
178-
#else
179172
unsigned int streams_options = 0;
180-
#endif
181173
unsigned int streams_flags = STREAM_XPORT_CLIENT | STREAM_XPORT_CONNECT;
182174
char * hashed_details = NULL;
183175
int hashed_details_len = 0;
@@ -983,11 +975,7 @@ MYSQLND_METHOD(mysqlnd_net, enable_ssl)(MYSQLND_NET * const net)
983975
php_stream_context_set_option(context, "ssl", "allow_self_signed", &verify_peer_zval);
984976
}
985977
}
986-
#if PHP_API_VERSION >= 20131106
987-
php_stream_context_set(net_stream, context);
988-
#else
989978
php_stream_context_set(net_stream, context);
990-
#endif
991979
if (php_stream_xport_crypto_setup(net_stream, STREAM_CRYPTO_METHOD_TLS_CLIENT, NULL) < 0 ||
992980
php_stream_xport_crypto_enable(net_stream, 1) < 0)
993981
{
@@ -1003,11 +991,7 @@ MYSQLND_METHOD(mysqlnd_net, enable_ssl)(MYSQLND_NET * const net)
1003991
of the context, which means usage of already freed memory, bad. Actually we don't need this
1004992
context anymore after we have enabled SSL on the connection. Thus it is very simple, we remove it.
1005993
*/
1006-
#if PHP_API_VERSION >= 20131106
1007994
php_stream_context_set(net_stream, NULL);
1008-
#else
1009-
php_stream_context_set(net_stream, NULL);
1010-
#endif
1011995

1012996
if (net->data->options.timeout_read) {
1013997
struct timeval tv;

ext/mysqlnd/mysqlnd_vio.c

-16
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,7 @@ static php_stream *
121121
MYSQLND_METHOD(mysqlnd_vio, open_pipe)(MYSQLND_VIO * const vio, const MYSQLND_CSTRING scheme, const zend_bool persistent,
122122
MYSQLND_STATS * const conn_stats, MYSQLND_ERROR_INFO * const error_info)
123123
{
124-
#if PHP_API_VERSION < 20100412
125-
unsigned int streams_options = ENFORCE_SAFE_MODE;
126-
#else
127124
unsigned int streams_options = 0;
128-
#endif
129125
dtor_func_t origin_dtor;
130126
php_stream * net_stream = NULL;
131127

@@ -160,11 +156,7 @@ static php_stream *
160156
MYSQLND_METHOD(mysqlnd_vio, open_tcp_or_unix)(MYSQLND_VIO * const vio, const MYSQLND_CSTRING scheme, const zend_bool persistent,
161157
MYSQLND_STATS * const conn_stats, MYSQLND_ERROR_INFO * const error_info)
162158
{
163-
#if PHP_API_VERSION < 20100412
164-
unsigned int streams_options = ENFORCE_SAFE_MODE;
165-
#else
166159
unsigned int streams_options = 0;
167-
#endif
168160
unsigned int streams_flags = STREAM_XPORT_CLIENT | STREAM_XPORT_CONNECT;
169161
char * hashed_details = NULL;
170162
int hashed_details_len = 0;
@@ -566,11 +558,7 @@ MYSQLND_METHOD(mysqlnd_vio, enable_ssl)(MYSQLND_VIO * const net)
566558
php_stream_context_set_option(context, "ssl", "allow_self_signed", &verify_peer_zval);
567559
}
568560
}
569-
#if PHP_API_VERSION >= 20131106
570-
php_stream_context_set(net_stream, context);
571-
#else
572561
php_stream_context_set(net_stream, context);
573-
#endif
574562
if (php_stream_xport_crypto_setup(net_stream, STREAM_CRYPTO_METHOD_TLS_CLIENT, NULL) < 0 ||
575563
php_stream_xport_crypto_enable(net_stream, 1) < 0)
576564
{
@@ -586,11 +574,7 @@ MYSQLND_METHOD(mysqlnd_vio, enable_ssl)(MYSQLND_VIO * const net)
586574
of the context, which means usage of already freed memory, bad. Actually we don't need this
587575
context anymore after we have enabled SSL on the connection. Thus it is very simple, we remove it.
588576
*/
589-
#if PHP_API_VERSION >= 20131106
590577
php_stream_context_set(net_stream, NULL);
591-
#else
592-
php_stream_context_set(net_stream, NULL);
593-
#endif
594578

595579
if (net->data->options.timeout_read) {
596580
struct timeval tv;

0 commit comments

Comments
 (0)