From b6a6921371ccaadb00e7808bc464c5799531e718 Mon Sep 17 00:00:00 2001 From: "Christoph M. Becker" Date: Mon, 11 Jul 2016 12:17:53 +0200 Subject: [PATCH] Use PHP_DEP_FE instead of manually emitting deprecation warnings --- ext/mcrypt/mcrypt.c | 122 ++++++++++++++------------------------------ 1 file changed, 37 insertions(+), 85 deletions(-) diff --git a/ext/mcrypt/mcrypt.c b/ext/mcrypt/mcrypt.c index bc2de1f82d..68528d30f2 100644 --- a/ext/mcrypt/mcrypt.c +++ b/ext/mcrypt/mcrypt.c @@ -207,43 +207,43 @@ ZEND_END_ARG_INFO() /* }}} */ const zend_function_entry mcrypt_functions[] = { /* {{{ */ - PHP_FE(mcrypt_get_key_size, arginfo_mcrypt_get_key_size) - PHP_FE(mcrypt_get_block_size, arginfo_mcrypt_get_block_size) - PHP_FE(mcrypt_get_cipher_name, arginfo_mcrypt_get_cipher_name) - PHP_FE(mcrypt_create_iv, arginfo_mcrypt_create_iv) - - PHP_FE(mcrypt_list_algorithms, arginfo_mcrypt_list_algorithms) - PHP_FE(mcrypt_list_modes, arginfo_mcrypt_list_modes) - PHP_FE(mcrypt_get_iv_size, arginfo_mcrypt_get_iv_size) - PHP_FE(mcrypt_encrypt, arginfo_mcrypt_encrypt) - PHP_FE(mcrypt_decrypt, arginfo_mcrypt_decrypt) - - PHP_FE(mcrypt_module_open, arginfo_mcrypt_module_open) - PHP_FE(mcrypt_generic_init, arginfo_mcrypt_generic_init) - PHP_FE(mcrypt_generic, arginfo_mcrypt_generic) - PHP_FE(mdecrypt_generic, arginfo_mdecrypt_generic) - PHP_FE(mcrypt_generic_deinit, arginfo_mcrypt_generic_deinit) - - PHP_FE(mcrypt_enc_self_test, arginfo_mcrypt_enc_self_test) - PHP_FE(mcrypt_enc_is_block_algorithm_mode, arginfo_mcrypt_enc_is_block_algorithm_mode) - PHP_FE(mcrypt_enc_is_block_algorithm, arginfo_mcrypt_enc_is_block_algorithm) - PHP_FE(mcrypt_enc_is_block_mode, arginfo_mcrypt_enc_is_block_mode) - PHP_FE(mcrypt_enc_get_block_size, arginfo_mcrypt_enc_get_block_size) - PHP_FE(mcrypt_enc_get_key_size, arginfo_mcrypt_enc_get_key_size) - PHP_FE(mcrypt_enc_get_supported_key_sizes, arginfo_mcrypt_enc_get_supported_key_sizes) - PHP_FE(mcrypt_enc_get_iv_size, arginfo_mcrypt_enc_get_iv_size) - PHP_FE(mcrypt_enc_get_algorithms_name, arginfo_mcrypt_enc_get_algorithms_name) - PHP_FE(mcrypt_enc_get_modes_name, arginfo_mcrypt_enc_get_modes_name) - PHP_FE(mcrypt_module_self_test, arginfo_mcrypt_module_self_test) - - PHP_FE(mcrypt_module_is_block_algorithm_mode, arginfo_mcrypt_module_is_block_algorithm_mode) - PHP_FE(mcrypt_module_is_block_algorithm, arginfo_mcrypt_module_is_block_algorithm) - PHP_FE(mcrypt_module_is_block_mode, arginfo_mcrypt_module_is_block_mode) - PHP_FE(mcrypt_module_get_algo_block_size, arginfo_mcrypt_module_get_algo_block_size) - PHP_FE(mcrypt_module_get_algo_key_size, arginfo_mcrypt_module_get_algo_key_size) - PHP_FE(mcrypt_module_get_supported_key_sizes, arginfo_mcrypt_module_get_supported_key_sizes) - - PHP_FE(mcrypt_module_close, arginfo_mcrypt_module_close) + PHP_DEP_FE(mcrypt_get_key_size, arginfo_mcrypt_get_key_size) + PHP_DEP_FE(mcrypt_get_block_size, arginfo_mcrypt_get_block_size) + PHP_DEP_FE(mcrypt_get_cipher_name, arginfo_mcrypt_get_cipher_name) + PHP_DEP_FE(mcrypt_create_iv, arginfo_mcrypt_create_iv) + + PHP_DEP_FE(mcrypt_list_algorithms, arginfo_mcrypt_list_algorithms) + PHP_DEP_FE(mcrypt_list_modes, arginfo_mcrypt_list_modes) + PHP_DEP_FE(mcrypt_get_iv_size, arginfo_mcrypt_get_iv_size) + PHP_DEP_FE(mcrypt_encrypt, arginfo_mcrypt_encrypt) + PHP_DEP_FE(mcrypt_decrypt, arginfo_mcrypt_decrypt) + + PHP_DEP_FE(mcrypt_module_open, arginfo_mcrypt_module_open) + PHP_DEP_FE(mcrypt_generic_init, arginfo_mcrypt_generic_init) + PHP_DEP_FE(mcrypt_generic, arginfo_mcrypt_generic) + PHP_DEP_FE(mdecrypt_generic, arginfo_mdecrypt_generic) + PHP_DEP_FE(mcrypt_generic_deinit, arginfo_mcrypt_generic_deinit) + + PHP_DEP_FE(mcrypt_enc_self_test, arginfo_mcrypt_enc_self_test) + PHP_DEP_FE(mcrypt_enc_is_block_algorithm_mode, arginfo_mcrypt_enc_is_block_algorithm_mode) + PHP_DEP_FE(mcrypt_enc_is_block_algorithm, arginfo_mcrypt_enc_is_block_algorithm) + PHP_DEP_FE(mcrypt_enc_is_block_mode, arginfo_mcrypt_enc_is_block_mode) + PHP_DEP_FE(mcrypt_enc_get_block_size, arginfo_mcrypt_enc_get_block_size) + PHP_DEP_FE(mcrypt_enc_get_key_size, arginfo_mcrypt_enc_get_key_size) + PHP_DEP_FE(mcrypt_enc_get_supported_key_sizes, arginfo_mcrypt_enc_get_supported_key_sizes) + PHP_DEP_FE(mcrypt_enc_get_iv_size, arginfo_mcrypt_enc_get_iv_size) + PHP_DEP_FE(mcrypt_enc_get_algorithms_name, arginfo_mcrypt_enc_get_algorithms_name) + PHP_DEP_FE(mcrypt_enc_get_modes_name, arginfo_mcrypt_enc_get_modes_name) + PHP_DEP_FE(mcrypt_module_self_test, arginfo_mcrypt_module_self_test) + + PHP_DEP_FE(mcrypt_module_is_block_algorithm_mode, arginfo_mcrypt_module_is_block_algorithm_mode) + PHP_DEP_FE(mcrypt_module_is_block_algorithm, arginfo_mcrypt_module_is_block_algorithm) + PHP_DEP_FE(mcrypt_module_is_block_mode, arginfo_mcrypt_module_is_block_mode) + PHP_DEP_FE(mcrypt_module_get_algo_block_size, arginfo_mcrypt_module_get_algo_block_size) + PHP_DEP_FE(mcrypt_module_get_algo_key_size, arginfo_mcrypt_module_get_algo_key_size) + PHP_DEP_FE(mcrypt_module_get_supported_key_sizes, arginfo_mcrypt_module_get_supported_key_sizes) + + PHP_DEP_FE(mcrypt_module_close, arginfo_mcrypt_module_close) PHP_FE_END }; /* }}} */ @@ -334,9 +334,6 @@ typedef enum { RETURN_FALSE; \ } \ -#define PHP_MCRYPT_DEPRECATED_WARNING php_error_docref(NULL, E_DEPRECATED, \ - "The mcrypt extension is deprecated and will be removed in the future: use openssl instead"); - PHP_INI_BEGIN() STD_PHP_INI_ENTRY("mcrypt.algorithms_dir", NULL, PHP_INI_ALL, OnUpdateString, algorithms_dir, zend_mcrypt_globals, mcrypt_globals) STD_PHP_INI_ENTRY("mcrypt.modes_dir", NULL, PHP_INI_ALL, OnUpdateString, modes_dir, zend_mcrypt_globals, mcrypt_globals) @@ -508,8 +505,6 @@ PHP_FUNCTION(mcrypt_module_open) MCRYPT td; php_mcrypt *pm; - PHP_MCRYPT_DEPRECATED_WARNING - if (zend_parse_parameters (ZEND_NUM_ARGS(), "ssss", &cipher, &cipher_len, &cipher_dir, &cipher_dir_len, &mode, &mode_len, &mode_dir, &mode_dir_len)) { @@ -547,8 +542,6 @@ PHP_FUNCTION(mcrypt_generic_init) php_mcrypt *pm; int result = 0; - PHP_MCRYPT_DEPRECATED_WARNING - if (zend_parse_parameters(ZEND_NUM_ARGS(), "rss", &mcryptind, &key, &key_len, &iv, &iv_len) == FAILURE) { return; } @@ -626,8 +619,6 @@ PHP_FUNCTION(mcrypt_generic) zend_string* data_str; int block_size, data_size; - PHP_MCRYPT_DEPRECATED_WARNING - if (zend_parse_parameters(ZEND_NUM_ARGS(), "rs", &mcryptind, &data, &data_len) == FAILURE) { return; } @@ -678,8 +669,6 @@ PHP_FUNCTION(mdecrypt_generic) char* data_s; int block_size, data_size; - PHP_MCRYPT_DEPRECATED_WARNING - if (zend_parse_parameters(ZEND_NUM_ARGS(), "rs", &mcryptind, &data, &data_len) == FAILURE) { return; } @@ -727,7 +716,6 @@ PHP_FUNCTION(mcrypt_enc_get_supported_key_sizes) int *key_sizes; MCRYPT_GET_TD_ARG - PHP_MCRYPT_DEPRECATED_WARNING array_init(return_value); key_sizes = mcrypt_enc_get_supported_key_sizes(pm->td, &count); @@ -745,7 +733,6 @@ PHP_FUNCTION(mcrypt_enc_get_supported_key_sizes) PHP_FUNCTION(mcrypt_enc_self_test) { MCRYPT_GET_TD_ARG - PHP_MCRYPT_DEPRECATED_WARNING RETURN_LONG(mcrypt_enc_self_test(pm->td)); } /* }}} */ @@ -755,7 +742,6 @@ PHP_FUNCTION(mcrypt_enc_self_test) PHP_FUNCTION(mcrypt_module_close) { MCRYPT_GET_TD_ARG - PHP_MCRYPT_DEPRECATED_WARNING zend_list_close(Z_RES_P(mcryptind)); RETURN_TRUE; } @@ -766,7 +752,6 @@ PHP_FUNCTION(mcrypt_module_close) PHP_FUNCTION(mcrypt_generic_deinit) { MCRYPT_GET_TD_ARG - PHP_MCRYPT_DEPRECATED_WARNING if (mcrypt_generic_deinit(pm->td) < 0) { php_error_docref(NULL, E_WARNING, "Could not terminate encryption specifier"); @@ -782,7 +767,6 @@ PHP_FUNCTION(mcrypt_generic_deinit) PHP_FUNCTION(mcrypt_enc_is_block_algorithm_mode) { MCRYPT_GET_TD_ARG - PHP_MCRYPT_DEPRECATED_WARNING if (mcrypt_enc_is_block_algorithm_mode(pm->td) == 1) { RETURN_TRUE @@ -797,7 +781,6 @@ PHP_FUNCTION(mcrypt_enc_is_block_algorithm_mode) PHP_FUNCTION(mcrypt_enc_is_block_algorithm) { MCRYPT_GET_TD_ARG - PHP_MCRYPT_DEPRECATED_WARNING if (mcrypt_enc_is_block_algorithm(pm->td) == 1) { RETURN_TRUE @@ -812,7 +795,6 @@ PHP_FUNCTION(mcrypt_enc_is_block_algorithm) PHP_FUNCTION(mcrypt_enc_is_block_mode) { MCRYPT_GET_TD_ARG - PHP_MCRYPT_DEPRECATED_WARNING if (mcrypt_enc_is_block_mode(pm->td) == 1) { RETURN_TRUE @@ -827,7 +809,6 @@ PHP_FUNCTION(mcrypt_enc_is_block_mode) PHP_FUNCTION(mcrypt_enc_get_block_size) { MCRYPT_GET_TD_ARG - PHP_MCRYPT_DEPRECATED_WARNING RETURN_LONG(mcrypt_enc_get_block_size(pm->td)); } /* }}} */ @@ -837,7 +818,6 @@ PHP_FUNCTION(mcrypt_enc_get_block_size) PHP_FUNCTION(mcrypt_enc_get_key_size) { MCRYPT_GET_TD_ARG - PHP_MCRYPT_DEPRECATED_WARNING RETURN_LONG(mcrypt_enc_get_key_size(pm->td)); } /* }}} */ @@ -847,7 +827,6 @@ PHP_FUNCTION(mcrypt_enc_get_key_size) PHP_FUNCTION(mcrypt_enc_get_iv_size) { MCRYPT_GET_TD_ARG - PHP_MCRYPT_DEPRECATED_WARNING RETURN_LONG(mcrypt_enc_get_iv_size(pm->td)); } /* }}} */ @@ -858,7 +837,6 @@ PHP_FUNCTION(mcrypt_enc_get_algorithms_name) { char *name; MCRYPT_GET_TD_ARG - PHP_MCRYPT_DEPRECATED_WARNING name = mcrypt_enc_get_algorithms_name(pm->td); RETVAL_STRING(name); @@ -872,7 +850,6 @@ PHP_FUNCTION(mcrypt_enc_get_modes_name) { char *name; MCRYPT_GET_TD_ARG - PHP_MCRYPT_DEPRECATED_WARNING name = mcrypt_enc_get_modes_name(pm->td); RETVAL_STRING(name); @@ -885,7 +862,6 @@ PHP_FUNCTION(mcrypt_enc_get_modes_name) PHP_FUNCTION(mcrypt_module_self_test) { MCRYPT_GET_MODE_DIR_ARGS(algorithms_dir); - PHP_MCRYPT_DEPRECATED_WARNING if (mcrypt_module_self_test(module, dir) == 0) { RETURN_TRUE; @@ -900,7 +876,6 @@ PHP_FUNCTION(mcrypt_module_self_test) PHP_FUNCTION(mcrypt_module_is_block_algorithm_mode) { MCRYPT_GET_MODE_DIR_ARGS(modes_dir) - PHP_MCRYPT_DEPRECATED_WARNING if (mcrypt_module_is_block_algorithm_mode(module, dir) == 1) { RETURN_TRUE; @@ -915,7 +890,6 @@ PHP_FUNCTION(mcrypt_module_is_block_algorithm_mode) PHP_FUNCTION(mcrypt_module_is_block_algorithm) { MCRYPT_GET_MODE_DIR_ARGS(algorithms_dir) - PHP_MCRYPT_DEPRECATED_WARNING if (mcrypt_module_is_block_algorithm(module, dir) == 1) { RETURN_TRUE; @@ -930,7 +904,6 @@ PHP_FUNCTION(mcrypt_module_is_block_algorithm) PHP_FUNCTION(mcrypt_module_is_block_mode) { MCRYPT_GET_MODE_DIR_ARGS(modes_dir) - PHP_MCRYPT_DEPRECATED_WARNING if (mcrypt_module_is_block_mode(module, dir) == 1) { RETURN_TRUE; @@ -945,7 +918,6 @@ PHP_FUNCTION(mcrypt_module_is_block_mode) PHP_FUNCTION(mcrypt_module_get_algo_block_size) { MCRYPT_GET_MODE_DIR_ARGS(algorithms_dir) - PHP_MCRYPT_DEPRECATED_WARNING RETURN_LONG(mcrypt_module_get_algo_block_size(module, dir)); } @@ -956,7 +928,6 @@ PHP_FUNCTION(mcrypt_module_get_algo_block_size) PHP_FUNCTION(mcrypt_module_get_algo_key_size) { MCRYPT_GET_MODE_DIR_ARGS(algorithms_dir); - PHP_MCRYPT_DEPRECATED_WARNING RETURN_LONG(mcrypt_module_get_algo_key_size(module, dir)); } @@ -970,7 +941,6 @@ PHP_FUNCTION(mcrypt_module_get_supported_key_sizes) int *key_sizes; MCRYPT_GET_MODE_DIR_ARGS(algorithms_dir) - PHP_MCRYPT_DEPRECATED_WARNING array_init(return_value); key_sizes = mcrypt_module_get_algo_supported_key_sizes(module, dir, &count); @@ -991,8 +961,6 @@ PHP_FUNCTION(mcrypt_list_algorithms) size_t lib_dir_len; int i, count; - PHP_MCRYPT_DEPRECATED_WARNING - if (zend_parse_parameters(ZEND_NUM_ARGS(), "|s", &lib_dir, &lib_dir_len) == FAILURE) { return; @@ -1020,8 +988,6 @@ PHP_FUNCTION(mcrypt_list_modes) size_t lib_dir_len; int i, count; - PHP_MCRYPT_DEPRECATED_WARNING - if (zend_parse_parameters(ZEND_NUM_ARGS(), "|s", &lib_dir, &lib_dir_len) == FAILURE) { return; @@ -1051,8 +1017,6 @@ PHP_FUNCTION(mcrypt_get_key_size) char *module_dir_string; MCRYPT td; - PHP_MCRYPT_DEPRECATED_WARNING - MCRYPT_GET_INI if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", @@ -1082,8 +1046,6 @@ PHP_FUNCTION(mcrypt_get_block_size) char *module_dir_string; MCRYPT td; - PHP_MCRYPT_DEPRECATED_WARNING - MCRYPT_GET_INI if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", @@ -1113,8 +1075,6 @@ PHP_FUNCTION(mcrypt_get_iv_size) char *module_dir_string; MCRYPT td; - PHP_MCRYPT_DEPRECATED_WARNING - MCRYPT_GET_INI if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", @@ -1144,8 +1104,6 @@ PHP_FUNCTION(mcrypt_get_cipher_name) size_t cipher_len; MCRYPT td; - PHP_MCRYPT_DEPRECATED_WARNING - MCRYPT_GET_INI if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", @@ -1361,8 +1319,6 @@ PHP_FUNCTION(mcrypt_encrypt) char *cipher, *key, *data, *mode, *iv = NULL; size_t cipher_len, key_len, data_len, mode_len, iv_len = 0; - PHP_MCRYPT_DEPRECATED_WARNING - if (zend_parse_parameters(ZEND_NUM_ARGS(), "ssss|s", &cipher, &cipher_len, &key, &key_len, &data, &data_len, &mode, &mode_len, &iv, &iv_len) == FAILURE) { return; @@ -1379,8 +1335,6 @@ PHP_FUNCTION(mcrypt_decrypt) char *cipher, *key, *data, *mode, *iv = NULL; size_t cipher_len, key_len, data_len, mode_len, iv_len = 0; - PHP_MCRYPT_DEPRECATED_WARNING - if (zend_parse_parameters(ZEND_NUM_ARGS(), "ssss|s", &cipher, &cipher_len, &key, &key_len, &data, &data_len, &mode, &mode_len, &iv, &iv_len) == FAILURE) { return; @@ -1399,8 +1353,6 @@ PHP_FUNCTION(mcrypt_create_iv) zend_long size; int n = 0; - PHP_MCRYPT_DEPRECATED_WARNING - if (zend_parse_parameters(ZEND_NUM_ARGS(), "l|l", &size, &source) == FAILURE) { return; } -- 2.40.0