diff --git a/include/maxscale/modinfo.h b/include/maxscale/modinfo.h index 912ec5df6..677cd54bb 100644 --- a/include/maxscale/modinfo.h +++ b/include/maxscale/modinfo.h @@ -107,7 +107,11 @@ enum mxs_module_param_options MXS_MODULE_OPT_PATH_W_OK = (1 << 3), /**< PATH: Write permission to path required */ MXS_MODULE_OPT_PATH_F_OK = (1 << 4), /**< PATH: Path must exist */ MXS_MODULE_OPT_PATH_CREAT = (1 << 5), /**< PATH: Create path if it doesn't exist */ - MXS_MODULE_OPT_ENUM_UNIQUE = (1 << 6) /**< ENUM: Only one value can be defined */ + MXS_MODULE_OPT_ENUM_UNIQUE = (1 << 6), /**< ENUM: Only one value can be defined */ + + /**< Parameter is deprecated: Causes a warning to be logged if the parameter + * is used but will not cause a configuration error. */ + MXS_MODULE_OPT_DEPRECATED = (1 << 7), }; /** String to enum value mappings */ diff --git a/server/core/config.cc b/server/core/config.cc index 7449766b6..d13435961 100644 --- a/server/core/config.cc +++ b/server/core/config.cc @@ -29,6 +29,7 @@ #include #include #include +#include #include #include @@ -2391,6 +2392,27 @@ static void process_path_parameter(MXS_CONFIG_PARAMETER *param) } } +static bool param_is_deprecated(const MXS_MODULE_PARAM* params, const char* name, const char* modname) +{ + bool rval = false; + + for (int i = 0; params[i].name; i++) + { + if (strcmp(params[i].name, name) == 0) + { + if (params[i].options & MXS_MODULE_OPT_DEPRECATED) + { + MXS_WARNING("Parameter '%s' for module '%s' is deprecated and " + "will be ignored.", name, modname); + rval = true; + } + break; + } + } + + return rval; +} + /** * @brief Check that the configuration objects have valid parameters * @@ -2440,6 +2462,8 @@ check_config_objects(CONFIG_CONTEXT *context) if (param_set != NULL) { + std::vector to_be_removed; + MXS_CONFIG_PARAMETER *params = obj->parameters; while (params) { @@ -2471,9 +2495,19 @@ check_config_objects(CONFIG_CONTEXT *context) /** Fix old-style object names */ config_fix_param(mod->parameters, params); } + + if (mod && param_is_deprecated(mod->parameters, params->name, obj->object)) + { + to_be_removed.push_back(params->name); + } } params = params->next; } + + for (auto it = to_be_removed.begin(); it != to_be_removed.end(); it++) + { + config_remove_param(obj, it->c_str()); + } } if (mod && missing_required_parameters(mod->parameters, obj->parameters))