mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-03-11 15:10:45 +01:00
Make deprecation warnings more clear (#5996)
* Add these as warnings To be removed in next major version * Make ACP search's purpose more clear * Only warn once per deprecated path
This commit is contained in:
committed by
Julian Lam
parent
ec3bb1c727
commit
ab8465d7b6
@@ -65,7 +65,7 @@
|
||||
"logout": "Log out",
|
||||
"view-forum": "View Forum",
|
||||
|
||||
"search.placeholder": "Search...",
|
||||
"search.placeholder": "Search for settings",
|
||||
"search.no-results": "No results...",
|
||||
"search.search-forum": "Search the forum for <strong></strong>",
|
||||
"search.keep-typing": "Type more to see results...",
|
||||
|
||||
@@ -170,6 +170,9 @@ module.exports = function (app, middleware, hotswapIds, callback) {
|
||||
res.redirect(relativePath + '/assets/uploads' + req.path + '?' + meta.config['cache-buster']);
|
||||
});
|
||||
|
||||
// only warn once
|
||||
var warned = new Set();
|
||||
|
||||
// DEPRECATED
|
||||
var deprecatedPaths = [
|
||||
'/nodebb.min.js',
|
||||
@@ -188,8 +191,11 @@ module.exports = function (app, middleware, hotswapIds, callback) {
|
||||
];
|
||||
app.use(relativePath, function (req, res, next) {
|
||||
if (deprecatedPaths.some(function (path) { return req.path.startsWith(path); })) {
|
||||
winston.verbose('[deprecated] Accessing `' + req.path.slice(1) + '` from `/` is deprecated. ' +
|
||||
if (!warned.has(req.path)) {
|
||||
winston.warn('[deprecated] Accessing `' + req.path.slice(1) + '` from `/` is deprecated to be REMOVED in NodeBB v1.7.0. ' +
|
||||
'Use `/assets' + req.path + '` to access this file.');
|
||||
warned.add(req.path);
|
||||
}
|
||||
res.redirect(relativePath + '/assets' + req.path + '?' + meta.config['cache-buster']);
|
||||
} else {
|
||||
next();
|
||||
@@ -197,8 +203,11 @@ module.exports = function (app, middleware, hotswapIds, callback) {
|
||||
});
|
||||
// DEPRECATED
|
||||
app.use(relativePath + '/api/language', function (req, res) {
|
||||
winston.verbose('[deprecated] Accessing language files from `/api/language` is deprecated. ' +
|
||||
if (!warned.has(req.path)) {
|
||||
winston.warn('[deprecated] Accessing language files from `/api/language` is deprecated to be REMOVED in NodeBB v1.7.0. ' +
|
||||
'Use `/assets/language' + req.path + '.json` for prefetch paths.');
|
||||
warned.add(req.path);
|
||||
}
|
||||
res.redirect(relativePath + '/assets/language' + req.path + '.json?' + meta.config['cache-buster']);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user