mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-19 19:52:48 +00:00
config.c Make ast_variable_update update last match.
ast_variable_update currently sets the first match for a variable, as opposed to the last one. This issue is complementary to that raised in #244. This is incorrect and results in the wrong (or no) action being taken in cases where a section inherits from a template section. When the traversal occurs to update the setting, the existing code erroneously would use the first of possibly multiple matches in its update logic, which is wrong. Now, explicitly use the last match in the traversal, which will ensure that the actual setting is updated properly, and not skipped or ignored because a template from which the setting's section inherits was used for comparison. Resolves: #960 UpgradeNote: Config variables, when set/updated, such as via AMI, will now have the corresponding setting updated, even if their sections inherit from template sections.
This commit is contained in:
committed by
asterisk-org-access-app[bot]
parent
7173c92d9f
commit
3cab4e7ab4
@@ -1534,13 +1534,19 @@ int ast_variable_delete(struct ast_category *category, const char *variable, con
|
|||||||
int ast_variable_update(struct ast_category *category, const char *variable,
|
int ast_variable_update(struct ast_category *category, const char *variable,
|
||||||
const char *value, const char *match, unsigned int object)
|
const char *value, const char *match, unsigned int object)
|
||||||
{
|
{
|
||||||
struct ast_variable *cur, *prev=NULL, *newer=NULL;
|
struct ast_variable *cur, *prev=NULL, *newer=NULL, *matchvar = NULL;
|
||||||
|
|
||||||
for (cur = category->root; cur; prev = cur, cur = cur->next) {
|
for (cur = category->root; cur; prev = cur, cur = cur->next) {
|
||||||
if (strcasecmp(cur->name, variable) ||
|
if (strcasecmp(cur->name, variable) ||
|
||||||
(!ast_strlen_zero(match) && strcasecmp(cur->value, match)))
|
(!ast_strlen_zero(match) && strcasecmp(cur->value, match)))
|
||||||
continue;
|
continue;
|
||||||
|
matchvar = cur;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (cur = category->root; cur; prev = cur, cur = cur->next) {
|
||||||
|
if (cur != matchvar) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (!(newer = ast_variable_new(variable, value, cur->file)))
|
if (!(newer = ast_variable_new(variable, value, cur->file)))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user