fix: Deprecation warning logged at server launch for nested Parse Server option even if option is explicitly set (#9934)

This commit is contained in:
Manuel
2025-11-17 19:43:32 +01:00
committed by GitHub
parent 5e15403bc1
commit c22cb0ae58
4 changed files with 103 additions and 1 deletions

View File

@@ -1,5 +1,6 @@
import logger from '../logger';
import Deprecations from './Deprecations';
import Utils from '../Utils';
/**
* The deprecator class.
@@ -21,7 +22,7 @@ class Deprecator {
const changeNewDefault = deprecation.changeNewDefault;
// If default will change, only throw a warning if option is not set
if (changeNewDefault != null && options[optionKey] == null) {
if (changeNewDefault != null && Utils.getNestedProperty(options, optionKey) == null) {
Deprecator._logOption({ optionKey, changeNewDefault, solution });
}
}

View File

@@ -444,6 +444,31 @@ class Utils {
return value;
};
}
/**
* Gets a nested property value from an object using dot notation.
* @param {Object} obj The object to get the property from.
* @param {String} path The property path in dot notation, e.g. 'databaseOptions.allowPublicExplain'.
* @returns {any} The property value or undefined if not found.
* @example
* const obj = { database: { options: { enabled: true } } };
* Utils.getNestedProperty(obj, 'database.options.enabled');
* // Output: true
*/
static getNestedProperty(obj, path) {
if (!obj || !path) {
return undefined;
}
const keys = path.split('.');
let current = obj;
for (const key of keys) {
if (current == null || typeof current !== 'object') {
return undefined;
}
current = current[key];
}
return current;
}
}
module.exports = Utils;