diff --git a/NEWS b/NEWS index f4f05b5cf387a..59308b0242b08 100644 --- a/NEWS +++ b/NEWS @@ -29,6 +29,9 @@ PHP NEWS . Added Dom\Element::$outerHTML. (nielsdos) . Added Dom\Element::insertAdjacentHTML(). (nielsdos) +- Enchant: + . Added enchant_dict_remove_from_session(). (nielsdos) + - Intl: . Bumped ICU requirement to ICU >= 57.1. (cmb) . IntlDateFormatter::setTimeZone()/datefmt_set_timezone() throws an exception diff --git a/UPGRADING b/UPGRADING index ff6d4bc048f94..5420358fd4a58 100644 --- a/UPGRADING +++ b/UPGRADING @@ -166,6 +166,10 @@ PHP 8.5 UPGRADE NOTES - DOM: . Added Dom\Element::insertAdjacentHTML(). +- Enchant: + . Added enchant_dict_remove_from_session() to remove a word added to the + spellcheck session via enchant_dict_add_to_session(). + - PGSQL: . pg_close_stmt offers an alternative way to close a prepared statement from the DEALLOCATE sql command in that we can reuse diff --git a/ext/enchant/enchant.c b/ext/enchant/enchant.c index 9a905db2639d9..c003a1287f9d7 100644 --- a/ext/enchant/enchant.c +++ b/ext/enchant/enchant.c @@ -707,6 +707,22 @@ PHP_FUNCTION(enchant_dict_add_to_session) } /* }}} */ +PHP_FUNCTION(enchant_dict_remove_from_session) +{ + zval *dict; + const char *word; + size_t wordlen; + const enchant_dict *pdict; + + if (zend_parse_parameters(ZEND_NUM_ARGS(), "Op", &dict, enchant_dict_ce, &word, &wordlen) == FAILURE) { + RETURN_THROWS(); + } + + PHP_ENCHANT_GET_DICT; + + enchant_dict_remove_from_session(pdict->pdict, word, wordlen); +} + /* {{{ whether or not 'word' exists in this spelling-session */ PHP_FUNCTION(enchant_dict_is_added) { diff --git a/ext/enchant/enchant.stub.php b/ext/enchant/enchant.stub.php index 74f41054e5c59..7ca966490f3d1 100644 --- a/ext/enchant/enchant.stub.php +++ b/ext/enchant/enchant.stub.php @@ -95,6 +95,8 @@ function enchant_dict_add_to_personal(EnchantDictionary $dictionary, string $wor function enchant_dict_add_to_session(EnchantDictionary $dictionary, string $word): void {} +function enchant_dict_remove_from_session(EnchantDictionary $dictionary, string $word): void {} + function enchant_dict_is_added(EnchantDictionary $dictionary, string $word): bool {} /** diff --git a/ext/enchant/enchant_arginfo.h b/ext/enchant/enchant_arginfo.h index 32f18a290c263..1b85b7dd48f3a 100644 --- a/ext/enchant/enchant_arginfo.h +++ b/ext/enchant/enchant_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: bcd5195c8a1eea47d881747a57f1b1342ef0bbd1 */ + * Stub hash: f4705d8708830247ffb55a7bf73bc6e874e12629 */ ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_enchant_broker_init, 0, 0, EnchantBroker, MAY_BE_FALSE) ZEND_END_ARG_INFO() @@ -79,6 +79,8 @@ ZEND_END_ARG_INFO() #define arginfo_enchant_dict_add_to_session arginfo_enchant_dict_add +#define arginfo_enchant_dict_remove_from_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 @@ -114,6 +116,7 @@ ZEND_FUNCTION(enchant_dict_check); ZEND_FUNCTION(enchant_dict_suggest); ZEND_FUNCTION(enchant_dict_add); ZEND_FUNCTION(enchant_dict_add_to_session); +ZEND_FUNCTION(enchant_dict_remove_from_session); ZEND_FUNCTION(enchant_dict_is_added); ZEND_FUNCTION(enchant_dict_store_replacement); ZEND_FUNCTION(enchant_dict_get_error); @@ -138,6 +141,7 @@ static const zend_function_entry ext_functions[] = { ZEND_FE(enchant_dict_add, arginfo_enchant_dict_add) ZEND_RAW_FENTRY("enchant_dict_add_to_personal", zif_enchant_dict_add, arginfo_enchant_dict_add_to_personal, ZEND_ACC_DEPRECATED, NULL, NULL) ZEND_FE(enchant_dict_add_to_session, arginfo_enchant_dict_add_to_session) + ZEND_FE(enchant_dict_remove_from_session, arginfo_enchant_dict_remove_from_session) ZEND_FE(enchant_dict_is_added, arginfo_enchant_dict_is_added) ZEND_RAW_FENTRY("enchant_dict_is_in_session", zif_enchant_dict_is_added, arginfo_enchant_dict_is_in_session, ZEND_ACC_DEPRECATED, NULL, NULL) ZEND_FE(enchant_dict_store_replacement, arginfo_enchant_dict_store_replacement) diff --git a/ext/enchant/tests/dict_remove_from_session.phpt b/ext/enchant/tests/dict_remove_from_session.phpt new file mode 100644 index 0000000000000..4d79e156af76a --- /dev/null +++ b/ext/enchant/tests/dict_remove_from_session.phpt @@ -0,0 +1,31 @@ +--TEST-- +enchant_dict_remove_from_session() function +--EXTENSIONS-- +enchant +--SKIPIF-- + +--FILE-- + +--EXPECT-- +bool(false) +bool(true) +bool(true) +bool(false) +bool(false) diff --git a/ext/enchant/tests/null_bytes.phpt b/ext/enchant/tests/null_bytes.phpt index cdd26cf97d355..4778cb3f299f6 100644 --- a/ext/enchant/tests/null_bytes.phpt +++ b/ext/enchant/tests/null_bytes.phpt @@ -25,6 +25,7 @@ $two_params_dict = [ "enchant_dict_suggest", "enchant_dict_add", "enchant_dict_add_to_session", + "enchant_dict_remove_from_session", "enchant_dict_is_added", ]; @@ -65,6 +66,7 @@ enchant_dict_check(): Argument #2 ($word) must not contain any null bytes enchant_dict_suggest(): Argument #2 ($word) must not contain any null bytes enchant_dict_add(): Argument #2 ($word) must not contain any null bytes enchant_dict_add_to_session(): Argument #2 ($word) must not contain any null bytes +enchant_dict_remove_from_session(): Argument #2 ($word) must not contain any null bytes enchant_dict_is_added(): Argument #2 ($word) must not contain any null bytes enchant_broker_set_ordering(): Argument #2 ($tag) must not contain any null bytes enchant_dict_store_replacement(): Argument #2 ($misspelled) must not contain any null bytes