Skip to content

remove deprecated call and deprecate function to be removed in libenc… #5492

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions ext/enchant/config.m4
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ PHP_ARG_WITH([enchant],
[Include Enchant support])])

if test "$PHP_ENCHANT" != "no"; then
PKG_CHECK_MODULES([ENCHANT], [enchant])
PKG_CHECK_MODULES([ENCHANT], [enchant >= 1.4.2])

PHP_EVAL_INCLINE($ENCHANT_CFLAGS)
PHP_EVAL_LIBLINE($ENCHANT_LIBS, ENCHANT_SHARED_LIBADD)
Expand All @@ -13,14 +13,14 @@ if test "$PHP_ENCHANT" != "no"; then

PHP_CHECK_LIBRARY(enchant, enchant_get_version,
[
AC_DEFINE(HAVE_ENCHANT_GET_VERSION, 1, [ ])
AC_DEFINE(HAVE_ENCHANT_GET_VERSION, 1, [ enchant_get_version since 1.6.0 ])
], [ ], [
$ENCHANT_LIBS
])

PHP_CHECK_LIBRARY(enchant, enchant_broker_set_param,
[
AC_DEFINE(HAVE_ENCHANT_BROKER_SET_PARAM, 1, [ ])
AC_DEFINE(HAVE_ENCHANT_BROKER_SET_PARAM, 1, [ enchant_broker_set_param since 1.5.0 and removed in 2.x ])
], [ ], [
$ENCHANT_LIBS
])
Expand Down
23 changes: 13 additions & 10 deletions ext/enchant/enchant.c
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,9 @@ PHP_MINIT_FUNCTION(enchant)
le_enchant_dict = zend_register_list_destructors_ex(php_enchant_dict_free, NULL, "enchant_dict", module_number);
REGISTER_LONG_CONSTANT("ENCHANT_MYSPELL", PHP_ENCHANT_MYSPELL, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("ENCHANT_ISPELL", PHP_ENCHANT_ISPELL, CONST_CS | CONST_PERSISTENT);
#ifdef HAVE_ENCHANT_GET_VERSION
REGISTER_STRING_CONSTANT("LIBENCHANT_VERSION", enchant_get_version(), CONST_CS | CONST_PERSISTENT);
#endif
return SUCCESS;
}
/* }}} */
Expand Down Expand Up @@ -304,7 +307,7 @@ PHP_FUNCTION(enchant_broker_get_error)
{
zval *broker;
enchant_broker *pbroker;
char *msg;
const char *msg;

if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &broker) == FAILURE) {
RETURN_THROWS();
Expand Down Expand Up @@ -650,7 +653,7 @@ PHP_FUNCTION(enchant_dict_quick_check)
for (i = 0; i < n_sugg; i++) {
add_next_index_string(sugg, suggs[i]);
}
enchant_dict_free_suggestions(pdict->pdict, suggs);
enchant_dict_free_string_list(pdict->pdict, suggs);
}


Expand Down Expand Up @@ -705,14 +708,14 @@ PHP_FUNCTION(enchant_dict_suggest)
add_next_index_string(return_value, suggs[i]);
}

enchant_dict_free_suggestions(pdict->pdict, suggs);
enchant_dict_free_string_list(pdict->pdict, suggs);
}
}
/* }}} */

/* {{{ proto void enchant_dict_add_to_personal(resource dict, string word)
/* {{{ proto void enchant_dict_add(resource dict, string word)
add 'word' to personal word list */
PHP_FUNCTION(enchant_dict_add_to_personal)
PHP_FUNCTION(enchant_dict_add)
{
zval *dict;
char *word;
Expand All @@ -725,7 +728,7 @@ PHP_FUNCTION(enchant_dict_add_to_personal)

PHP_ENCHANT_GET_DICT;

enchant_dict_add_to_personal(pdict->pdict, word, wordlen);
enchant_dict_add(pdict->pdict, word, wordlen);
}
/* }}} */

Expand All @@ -748,9 +751,9 @@ PHP_FUNCTION(enchant_dict_add_to_session)
}
/* }}} */

/* {{{ proto bool enchant_dict_is_in_session(resource dict, string word)
/* {{{ proto bool enchant_dict_is_added(resource dict, string word)
whether or not 'word' exists in this spelling-session */
PHP_FUNCTION(enchant_dict_is_in_session)
PHP_FUNCTION(enchant_dict_is_added)
{
zval *dict;
char *word;
Expand All @@ -763,7 +766,7 @@ PHP_FUNCTION(enchant_dict_is_in_session)

PHP_ENCHANT_GET_DICT;

RETURN_BOOL(enchant_dict_is_in_session(pdict->pdict, word, wordlen));
RETURN_BOOL(enchant_dict_is_added(pdict->pdict, word, wordlen));
}
/* }}} */

Expand Down Expand Up @@ -796,7 +799,7 @@ PHP_FUNCTION(enchant_dict_get_error)
{
zval *dict;
enchant_dict *pdict;
char *msg;
const char *msg;

if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &dict) == FAILURE) {
RETURN_THROWS();
Expand Down
24 changes: 22 additions & 2 deletions ext/enchant/enchant.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,16 @@ function enchant_broker_free($broker): bool {}
*/
function enchant_broker_get_error($broker) {}

/** @param resource $broker */
/**
* @param resource $broker
* @deprecated
*/
function enchant_broker_set_dict_path($broker, int $name, string $value): bool {}

/** @param resource $broker */
/**
* @param resource $broker
* @deprecated
*/
function enchant_broker_get_dict_path($broker, int $name): string|false {}

/** @param resource $broker */
Expand Down Expand Up @@ -57,12 +63,26 @@ function enchant_dict_check($dict, string $word): bool {}
function enchant_dict_suggest($dict, string $word): ?array {}

/** @param resource $dict */
function enchant_dict_add($dict, string $word): void {}

/**
* @param resource $dict
* @alias enchant_dict_add
* @deprecated
*/
function enchant_dict_add_to_personal($dict, string $word): void {}

/** @param resource $dict */
function enchant_dict_add_to_session($dict, string $word): void {}

/** @param resource $dict */
function enchant_dict_is_added($dict, string $word): bool {}

/**
* @param resource $dict
* @alias enchant_dict_is_added
* @deprecated
*/
function enchant_dict_is_in_session($dict, string $word): bool {}

/** @param resource $dict */
Expand Down
22 changes: 14 additions & 8 deletions ext/enchant/enchant_arginfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,16 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_enchant_dict_suggest, 0, 2, IS_A
ZEND_ARG_TYPE_INFO(0, word, IS_STRING, 0)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_enchant_dict_add_to_personal, 0, 2, IS_VOID, 0)
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_enchant_dict_add, 0, 2, IS_VOID, 0)
ZEND_ARG_INFO(0, dict)
ZEND_ARG_TYPE_INFO(0, word, IS_STRING, 0)
ZEND_END_ARG_INFO()

#define arginfo_enchant_dict_add_to_session arginfo_enchant_dict_add_to_personal
#define arginfo_enchant_dict_add_to_personal arginfo_enchant_dict_add

#define arginfo_enchant_dict_add_to_session arginfo_enchant_dict_add

#define arginfo_enchant_dict_is_added arginfo_enchant_dict_check

#define arginfo_enchant_dict_is_in_session arginfo_enchant_dict_check

Expand Down Expand Up @@ -108,9 +112,9 @@ ZEND_FUNCTION(enchant_broker_describe);
ZEND_FUNCTION(enchant_dict_quick_check);
ZEND_FUNCTION(enchant_dict_check);
ZEND_FUNCTION(enchant_dict_suggest);
ZEND_FUNCTION(enchant_dict_add_to_personal);
ZEND_FUNCTION(enchant_dict_add);
ZEND_FUNCTION(enchant_dict_add_to_session);
ZEND_FUNCTION(enchant_dict_is_in_session);
ZEND_FUNCTION(enchant_dict_is_added);
ZEND_FUNCTION(enchant_dict_store_replacement);
ZEND_FUNCTION(enchant_dict_get_error);
ZEND_FUNCTION(enchant_dict_describe);
Expand All @@ -120,8 +124,8 @@ static const zend_function_entry ext_functions[] = {
ZEND_FE(enchant_broker_init, arginfo_enchant_broker_init)
ZEND_FE(enchant_broker_free, arginfo_enchant_broker_free)
ZEND_FE(enchant_broker_get_error, arginfo_enchant_broker_get_error)
ZEND_FE(enchant_broker_set_dict_path, arginfo_enchant_broker_set_dict_path)
ZEND_FE(enchant_broker_get_dict_path, arginfo_enchant_broker_get_dict_path)
ZEND_DEP_FE(enchant_broker_set_dict_path, arginfo_enchant_broker_set_dict_path)
ZEND_DEP_FE(enchant_broker_get_dict_path, arginfo_enchant_broker_get_dict_path)
ZEND_FE(enchant_broker_list_dicts, arginfo_enchant_broker_list_dicts)
ZEND_FE(enchant_broker_request_dict, arginfo_enchant_broker_request_dict)
ZEND_FE(enchant_broker_request_pwl_dict, arginfo_enchant_broker_request_pwl_dict)
Expand All @@ -132,9 +136,11 @@ static const zend_function_entry ext_functions[] = {
ZEND_FE(enchant_dict_quick_check, arginfo_enchant_dict_quick_check)
ZEND_FE(enchant_dict_check, arginfo_enchant_dict_check)
ZEND_FE(enchant_dict_suggest, arginfo_enchant_dict_suggest)
ZEND_FE(enchant_dict_add_to_personal, arginfo_enchant_dict_add_to_personal)
ZEND_FE(enchant_dict_add, arginfo_enchant_dict_add)
ZEND_DEP_FALIAS(enchant_dict_add_to_personal, enchant_dict_add, arginfo_enchant_dict_add_to_personal)
ZEND_FE(enchant_dict_add_to_session, arginfo_enchant_dict_add_to_session)
ZEND_FE(enchant_dict_is_in_session, arginfo_enchant_dict_is_in_session)
ZEND_FE(enchant_dict_is_added, arginfo_enchant_dict_is_added)
ZEND_DEP_FALIAS(enchant_dict_is_in_session, enchant_dict_is_added, arginfo_enchant_dict_is_in_session)
ZEND_FE(enchant_dict_store_replacement, arginfo_enchant_dict_store_replacement)
ZEND_FE(enchant_dict_get_error, arginfo_enchant_dict_get_error)
ZEND_FE(enchant_dict_describe, arginfo_enchant_dict_describe)
Expand Down
2 changes: 1 addition & 1 deletion ext/enchant/tests/broker_free_02.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ if (is_resource($broker)) {
if ($requestDict) {
echo("OK\n");
for($x=0;$x<count($newWord);$x++) {
$AddtoPersonalDict = enchant_dict_add_to_personal($requestDict,$newWord[$x]);
$AddtoPersonalDict = enchant_dict_add($requestDict,$newWord[$x]);
}

if (NULL === $AddtoPersonalDict) {
Expand Down
2 changes: 1 addition & 1 deletion ext/enchant/tests/broker_free_dict.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ if (is_resource($broker)) {

if ($requestDict) {
echo("OK\n");
$AddtoPersonalDict = enchant_dict_add_to_personal($requestDict, $newWord);
$AddtoPersonalDict = enchant_dict_add($requestDict, $newWord);

if (NULL === $AddtoPersonalDict) {
var_dump($AddtoPersonalDict);
Expand Down
5 changes: 5 additions & 0 deletions ext/enchant/tests/bug53070.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Bug #53070 (enchant_broker_get_path crashes if no path is set)
<?php
if(!extension_loaded('enchant')) die('skip, enchant not loader');
if (!is_resource(enchant_broker_init())) {die("skip, resource dont load\n");}
if (defined("LIBENCHANT_VERSION") && version_compare(LIBENCHANT_VERSION, "2", ">")) die('skip libenchant v1 only');
?>
--FILE--
<?php
Expand All @@ -12,8 +13,12 @@ var_dump(enchant_broker_get_dict_path($broker, ENCHANT_MYSPELL));
var_dump(enchant_broker_get_dict_path($broker, ENCHANT_ISPELL));
?>
--EXPECTF--
Deprecated: Function enchant_broker_get_dict_path() is deprecated in %s

Warning: enchant_broker_get_dict_path(): dict_path not set in %s on line %d
bool(false)

Deprecated: Function enchant_broker_get_dict_path() is deprecated in %s

Warning: enchant_broker_get_dict_path(): dict_path not set in %s on line %d
bool(false)
4 changes: 2 additions & 2 deletions ext/enchant/tests/dict_add_to_personal.phpt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
--TEST--
enchant_dict_add_to_personal() function
enchant_dict_add() function
--CREDITS--
marcosptf - <marcosptf@yahoo.com.br>
--SKIPIF--
Expand All @@ -20,7 +20,7 @@ if (is_resource($broker)) {

if ($requestDict) {
echo("OK\n");
$AddtoPersonalDict = enchant_dict_add_to_personal($requestDict,$newWord);
$AddtoPersonalDict = enchant_dict_add($requestDict,$newWord);

if (NULL === $AddtoPersonalDict) {
var_dump($AddtoPersonalDict);
Expand Down
2 changes: 1 addition & 1 deletion ext/enchant/tests/dict_check.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ if (is_resource($broker)) {

if ($requestDict) {
echo("OK\n");
enchant_dict_add_to_personal($requestDict, $newWord);
enchant_dict_add($requestDict, $newWord);

if (enchant_dict_check($requestDict, $newWord)) {
echo("OK\n");
Expand Down
4 changes: 2 additions & 2 deletions ext/enchant/tests/dict_is_in_session.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ if (is_resource($broker)) {

if ($requestDict) {
echo("OK\n");
$AddtoPersonalDict = enchant_dict_add_to_personal($requestDict,$newWord);
$AddtoPersonalDict = enchant_dict_add($requestDict,$newWord);

if (NULL === $AddtoPersonalDict) {
var_dump(enchant_dict_is_in_session($requestDict,$newWord));
var_dump(enchant_dict_is_added($requestDict,$newWord));
} else {
echo("dict add to personal failed\n");
}
Expand Down
11 changes: 10 additions & 1 deletion ext/enchant/tests/enchant_broker_set_dict_path.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ marcosptf - <marcosptf@yahoo.com.br>
if(!extension_loaded('enchant')) die('skip, enchant not loader');
if (!is_resource(enchant_broker_init())) {die("skip, resource dont load\n");}
if (!is_array(enchant_broker_list_dicts(enchant_broker_init()))) {die("skip, no dictionary installed on this machine! \n");}
if (defined("LIBENCHANT_VERSION") && version_compare(LIBENCHANT_VERSION, "2", ">")) die('skip libenchant v1 only');
?>
--FILE--
<?php
Expand Down Expand Up @@ -46,8 +47,16 @@ if (is_resource($broker)) {
echo("broker is not a resource; failed; \n");
}
?>
--EXPECT--
--EXPECTF--
OK

Deprecated: Function enchant_broker_set_dict_path() is deprecated in %s
OK

Deprecated: Function enchant_broker_set_dict_path() is deprecated in %s
OK

Deprecated: Function enchant_broker_get_dict_path() is deprecated in %s

Deprecated: Function enchant_broker_get_dict_path() is deprecated in %s
OK