1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

Add enchant_dict_remove_from_session() (#17393)

This commit is contained in:
Niels Dossche
2025-01-08 21:53:40 +01:00
committed by GitHub
parent 915feea12d
commit 3a039e3725
7 changed files with 63 additions and 1 deletions

3
NEWS
View File

@@ -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

View File

@@ -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

View File

@@ -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)
{

View File

@@ -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 {}
/**

View File

@@ -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)

View File

@@ -0,0 +1,31 @@
--TEST--
enchant_dict_remove_from_session() function
--EXTENSIONS--
enchant
--SKIPIF--
<?php
if (!is_array(enchant_broker_list_dicts(enchant_broker_init()))) die("skip no dictionary installed on this machine!");
?>
--FILE--
<?php
$broker = enchant_broker_init();
$dicts = enchant_broker_list_dicts($broker);
$newWord = 'myImaginaryWord';
$requestDict = enchant_broker_request_dict($broker, $dicts[0]['lang_tag']);
var_dump(enchant_dict_check($requestDict, $newWord));
enchant_dict_add_to_session($requestDict, $newWord);
var_dump(enchant_dict_check($requestDict, $newWord));
var_dump(enchant_dict_is_added($requestDict, $newWord));
enchant_dict_remove_from_session($requestDict, $newWord);
var_dump(enchant_dict_check($requestDict, $newWord));
var_dump(enchant_dict_is_added($requestDict, $newWord));
?>
--EXPECT--
bool(false)
bool(true)
bool(true)
bool(false)
bool(false)

View File

@@ -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