From ab8465d7b6bbc34e9989b3a593e3ee13fa328e85 Mon Sep 17 00:00:00 2001
From: Peter Jaszkowiak
Date: Fri, 20 Oct 2017 13:47:08 -0600
Subject: [PATCH] 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
---
public/language/en-GB/admin/menu.json | 2 +-
src/routes/index.js | 13 +++++++++++--
2 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/public/language/en-GB/admin/menu.json b/public/language/en-GB/admin/menu.json
index 3ec4ad41c4..d42af99bce 100644
--- a/public/language/en-GB/admin/menu.json
+++ b/public/language/en-GB/admin/menu.json
@@ -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 ",
"search.keep-typing": "Type more to see results...",
diff --git a/src/routes/index.js b/src/routes/index.js
index 60c97bd8d3..aabfa51a78 100644
--- a/src/routes/index.js
+++ b/src/routes/index.js
@@ -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']);
});