Skip to content

Commit

Permalink
Remove version checks
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
nikic committed Jan 30, 2016
1 parent 2eb4728 commit 93dc91b
Show file tree
Hide file tree
Showing 31 changed files with 19 additions and 475 deletions.
4 changes: 0 additions & 4 deletions ext/enchant/enchant.c
Original file line number Diff line number Diff line change
Expand Up @@ -587,11 +587,7 @@ PHP_FUNCTION(enchant_broker_request_pwl_dict)
RETURN_FALSE;
}

#if PHP_API_VERSION < 20100412
if ((PG(safe_mode) && (!php_checkuid(pwl, NULL, CHECKUID_CHECK_FILE_AND_DIR))) || php_check_open_basedir(pwl)) {
#else
if (php_check_open_basedir(pwl)) {
#endif
RETURN_FALSE;
}

Expand Down
4 changes: 0 additions & 4 deletions ext/fileinfo/fileinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -548,11 +548,7 @@ static void _php_finfo_get_type(INTERNAL_FUNCTION_PARAMETERS, int mode, int mime
}
#endif

#if PHP_API_VERSION < 20100412
stream = php_stream_open_wrapper_ex(buffer, "rb", ENFORCE_SAFE_MODE | REPORT_ERRORS, NULL, context);
#else
stream = php_stream_open_wrapper_ex(buffer, "rb", REPORT_ERRORS, NULL, context);
#endif

if (!stream) {
RETVAL_FALSE;
Expand Down
10 changes: 2 additions & 8 deletions ext/hash/hash.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,6 @@
static int php_hash_le_hash;
HashTable php_hash_hashtable;

#if (PHP_MAJOR_VERSION >= 5)
# define DEFAULT_CONTEXT FG(default_context)
#else
# define DEFAULT_CONTEXT NULL
#endif

#ifdef PHP_MHASH_BC
struct mhash_bc_entry {
char *mhash_name;
Expand Down Expand Up @@ -140,7 +134,7 @@ static void php_hash_do_hash(INTERNAL_FUNCTION_PARAMETERS, int isfilename, zend_
php_error_docref(NULL, E_WARNING, "Invalid path");
RETURN_FALSE;
}
stream = php_stream_open_wrapper_ex(data, "rb", REPORT_ERRORS, NULL, DEFAULT_CONTEXT);
stream = php_stream_open_wrapper_ex(data, "rb", REPORT_ERRORS, NULL, FG(default_context));
if (!stream) {
/* Stream will report errors opening file */
RETURN_FALSE;
Expand Down Expand Up @@ -259,7 +253,7 @@ static void php_hash_do_hash_hmac(INTERNAL_FUNCTION_PARAMETERS, int isfilename,
php_error_docref(NULL, E_WARNING, "Invalid path");
RETURN_FALSE;
}
stream = php_stream_open_wrapper_ex(data, "rb", REPORT_ERRORS, NULL, DEFAULT_CONTEXT);
stream = php_stream_open_wrapper_ex(data, "rb", REPORT_ERRORS, NULL, FG(default_context));
if (!stream) {
/* Stream will report errors opening file */
RETURN_FALSE;
Expand Down
8 changes: 1 addition & 7 deletions ext/intl/collator/collator_convert.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,6 @@
#include <unicode/ustring.h>
#include <php.h>

#if PHP_VERSION_ID <= 50100
#define CAST_OBJECT_SHOULD_FREE ,0
#else
#define CAST_OBJECT_SHOULD_FREE
#endif

#define COLLATOR_CONVERT_RETURN_FAILED(retval) { \
Z_TRY_ADDREF_P(retval); \
return retval; \
Expand Down Expand Up @@ -258,7 +252,7 @@ zval* collator_convert_object_to_string( zval* obj, zval *rv )
{
zstr = rv;

if( Z_OBJ_HT_P(obj)->cast_object( obj, zstr, IS_STRING CAST_OBJECT_SHOULD_FREE ) == FAILURE )
if( Z_OBJ_HT_P(obj)->cast_object( obj, zstr, IS_STRING ) == FAILURE )
{
/* cast_object failed => bail out. */
zval_ptr_dtor( zstr );
Expand Down
15 changes: 2 additions & 13 deletions ext/intl/collator/collator_is_numeric.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,6 @@

#include "collator_is_numeric.h"

#if ZEND_MODULE_API_NO < 20071006
/* not 5.3 */
#ifndef ALLOCA_FLAG
#define ALLOCA_FLAG(use_heap)
#endif
#define _do_alloca(x, y) do_alloca((x))
#define _free_alloca(x, y) free_alloca((x))
#else
#define _do_alloca do_alloca
#define _free_alloca free_alloca
#endif
/* {{{ collator_u_strtod
* Taken from PHP6:zend_u_strtod()
*/
Expand Down Expand Up @@ -87,7 +76,7 @@ static double collator_u_strtod(const UChar *nptr, UChar **endptr) /* {{{ */
if (length < sizeof(buf)) {
numbuf = buf;
} else {
numbuf = (char *) _do_alloca(length + 1, use_heap);
numbuf = (char *) do_alloca(length + 1, use_heap);
}

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

if (numbuf != buf) {
_free_alloca(numbuf, use_heap);
free_alloca(numbuf, use_heap);
}

if (endptr != NULL) {
Expand Down
2 changes: 0 additions & 2 deletions ext/mysqli/mysqli.c
Original file line number Diff line number Diff line change
Expand Up @@ -583,9 +583,7 @@ PHP_MINIT_FUNCTION(mysqli)
mysqli_object_handlers.write_property = mysqli_write_property;
mysqli_object_handlers.get_property_ptr_ptr = std_hnd->get_property_ptr_ptr;
mysqli_object_handlers.has_property = mysqli_object_has_property;
#if PHP_VERSION_ID >= 50300
mysqli_object_handlers.get_debug_info = mysqli_object_get_debug_info;
#endif
memcpy(&mysqli_object_driver_handlers, &mysqli_object_handlers, sizeof(zend_object_handlers));
mysqli_object_driver_handlers.free_obj = mysqli_driver_free_storage;
memcpy(&mysqli_object_link_handlers, &mysqli_object_handlers, sizeof(zend_object_handlers));
Expand Down
8 changes: 0 additions & 8 deletions ext/mysqli/mysqli_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -1697,10 +1697,6 @@ static int mysqli_options_get_option_zval_type(int option)
{
switch (option) {
#ifdef MYSQLI_USE_MYSQLND
#if PHP_MAJOR_VERSION == 6
/* PHP-7 doesn't supprt unicode */
case MYSQLND_OPT_NUMERIC_AND_DATETIME_AS_UNICODE:
#endif
case MYSQLND_OPT_NET_CMD_BUFFER_SIZE:
case MYSQLND_OPT_NET_READ_BUFFER_SIZE:
#ifdef MYSQLND_STRING_TO_INT_CONVERSION
Expand Down Expand Up @@ -1781,11 +1777,7 @@ PHP_FUNCTION(mysqli_options)
MYSQLI_FETCH_RESOURCE_CONN(mysql, mysql_link, MYSQLI_STATUS_INITIALIZED);

#if !defined(MYSQLI_USE_MYSQLND)
#if PHP_API_VERSION < 20100412
if ((PG(open_basedir) && PG(open_basedir)[0] != '\0') || PG(safe_mode)) {
#else
if (PG(open_basedir) && PG(open_basedir)[0] != '\0') {
#endif
if(mysql_option == MYSQL_OPT_LOCAL_INFILE) {
RETURN_FALSE;
}
Expand Down
4 changes: 0 additions & 4 deletions ext/mysqli/mysqli_fe.c
Original file line number Diff line number Diff line change
Expand Up @@ -243,18 +243,14 @@ ZEND_END_ARG_INFO()


ZEND_BEGIN_ARG_INFO_EX(arginfo_mysqli_fetch_object, 0, 0, 1)
#if PHP_VERSION_ID > 50399
MYSQLI_ZEND_ARG_OBJ_INFO_RESULT()
ZEND_ARG_INFO(0, class_name)
ZEND_ARG_ARRAY_INFO(0, params, 0)
#endif
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_class_mysqli_fetch_object, 0, 0, 0)
#if PHP_VERSION_ID > 50399
ZEND_ARG_INFO(0, class_name)
ZEND_ARG_ARRAY_INFO(0, params, 0)
#endif
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_mysqli_kill, 0, 0, 2)
Expand Down
16 changes: 0 additions & 16 deletions ext/mysqlnd/mysqlnd_net.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,7 @@ MYSQLND_METHOD(mysqlnd_net, open_pipe)(MYSQLND_NET * const net, const char * con
const zend_bool persistent,
MYSQLND_STATS * const conn_stats, MYSQLND_ERROR_INFO * const error_info)
{
#if PHP_API_VERSION < 20100412
unsigned int streams_options = ENFORCE_SAFE_MODE;
#else
unsigned int streams_options = 0;
#endif
dtor_func_t origin_dtor;
php_stream * net_stream = NULL;

Expand Down Expand Up @@ -173,11 +169,7 @@ MYSQLND_METHOD(mysqlnd_net, open_tcp_or_unix)(MYSQLND_NET * const net, const cha
const zend_bool persistent,
MYSQLND_STATS * const conn_stats, MYSQLND_ERROR_INFO * const error_info)
{
#if PHP_API_VERSION < 20100412
unsigned int streams_options = ENFORCE_SAFE_MODE;
#else
unsigned int streams_options = 0;
#endif
unsigned int streams_flags = STREAM_XPORT_CLIENT | STREAM_XPORT_CONNECT;
char * hashed_details = NULL;
int hashed_details_len = 0;
Expand Down Expand Up @@ -983,11 +975,7 @@ MYSQLND_METHOD(mysqlnd_net, enable_ssl)(MYSQLND_NET * const net)
php_stream_context_set_option(context, "ssl", "allow_self_signed", &verify_peer_zval);
}
}
#if PHP_API_VERSION >= 20131106
php_stream_context_set(net_stream, context);
#else
php_stream_context_set(net_stream, context);
#endif
if (php_stream_xport_crypto_setup(net_stream, STREAM_CRYPTO_METHOD_TLS_CLIENT, NULL) < 0 ||
php_stream_xport_crypto_enable(net_stream, 1) < 0)
{
Expand All @@ -1003,11 +991,7 @@ MYSQLND_METHOD(mysqlnd_net, enable_ssl)(MYSQLND_NET * const net)
of the context, which means usage of already freed memory, bad. Actually we don't need this
context anymore after we have enabled SSL on the connection. Thus it is very simple, we remove it.
*/
#if PHP_API_VERSION >= 20131106
php_stream_context_set(net_stream, NULL);
#else
php_stream_context_set(net_stream, NULL);
#endif

if (net->data->options.timeout_read) {
struct timeval tv;
Expand Down
16 changes: 0 additions & 16 deletions ext/mysqlnd/mysqlnd_vio.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,7 @@ static php_stream *
MYSQLND_METHOD(mysqlnd_vio, open_pipe)(MYSQLND_VIO * const vio, const MYSQLND_CSTRING scheme, const zend_bool persistent,
MYSQLND_STATS * const conn_stats, MYSQLND_ERROR_INFO * const error_info)
{
#if PHP_API_VERSION < 20100412
unsigned int streams_options = ENFORCE_SAFE_MODE;
#else
unsigned int streams_options = 0;
#endif
dtor_func_t origin_dtor;
php_stream * net_stream = NULL;

Expand Down Expand Up @@ -160,11 +156,7 @@ static php_stream *
MYSQLND_METHOD(mysqlnd_vio, open_tcp_or_unix)(MYSQLND_VIO * const vio, const MYSQLND_CSTRING scheme, const zend_bool persistent,
MYSQLND_STATS * const conn_stats, MYSQLND_ERROR_INFO * const error_info)
{
#if PHP_API_VERSION < 20100412
unsigned int streams_options = ENFORCE_SAFE_MODE;
#else
unsigned int streams_options = 0;
#endif
unsigned int streams_flags = STREAM_XPORT_CLIENT | STREAM_XPORT_CONNECT;
char * hashed_details = NULL;
int hashed_details_len = 0;
Expand Down Expand Up @@ -566,11 +558,7 @@ MYSQLND_METHOD(mysqlnd_vio, enable_ssl)(MYSQLND_VIO * const net)
php_stream_context_set_option(context, "ssl", "allow_self_signed", &verify_peer_zval);
}
}
#if PHP_API_VERSION >= 20131106
php_stream_context_set(net_stream, context);
#else
php_stream_context_set(net_stream, context);
#endif
if (php_stream_xport_crypto_setup(net_stream, STREAM_CRYPTO_METHOD_TLS_CLIENT, NULL) < 0 ||
php_stream_xport_crypto_enable(net_stream, 1) < 0)
{
Expand All @@ -586,11 +574,7 @@ MYSQLND_METHOD(mysqlnd_vio, enable_ssl)(MYSQLND_VIO * const net)
of the context, which means usage of already freed memory, bad. Actually we don't need this
context anymore after we have enabled SSL on the connection. Thus it is very simple, we remove it.
*/
#if PHP_API_VERSION >= 20131106
php_stream_context_set(net_stream, NULL);
#else
php_stream_context_set(net_stream, NULL);
#endif

if (net->data->options.timeout_read) {
struct timeval tv;
Expand Down
Loading

0 comments on commit 93dc91b

Please sign in to comment.