A platform for community discussion. Free, open, simple.
DEV: Unsilence this-property-fallback deprecation (#29855)
David Taylor019ba099c84f
diff --git a/app/assets/javascripts/discourse-common/addon/deprecation-workflow.js b/app/assets/javascripts/discourse-common/addon/deprecation-workflow.jsindex 30a83f6d61e..5782e89fc56 100644--- a/app/assets/javascripts/discourse-common/addon/deprecation-workflow.js+++ b/app/assets/javascripts/discourse-common/addon/deprecation-workflow.js@@ -1,8 +1,4 @@const DEPRECATION_WORKFLOW = [- {- handler: "silence",- matchId: "ember-this-fallback.this-property-fallback",- },{ handler: "silence", matchId: "discourse.select-kit" },{handler: "silence",diff --git a/app/assets/javascripts/discourse/app/initializers/deprecation-this-property-fallback-handler.js b/app/assets/javascripts/discourse/app/initializers/deprecation-this-property-fallback-handler.jsnew file mode 100644index 00000000000..a431af71966--- /dev/null+++ b/app/assets/javascripts/discourse/app/initializers/deprecation-this-property-fallback-handler.js@@ -0,0 +1,44 @@+import { registerDeprecationHandler } from "@ember/debug";+import { consolePrefix, getThemeInfo } from "discourse/lib/source-identifier";++let registered = false;+const seenMessages = new Set();++export default {+ initialize() {+ if (registered) {+ return;+ }++ registerDeprecationHandler((message, options, next) => {+ if (options.id !== "ember-this-fallback.this-property-fallback") {+ return;+ }++ // These errors don't have useful backtraces, but we can parse theme/plugin+ // info from the message itself.+ const pluginMatch = message.match(/\/plugins\/([\w-]+)\//)?.[1];+ const themeIdMatch = message.match(/\/theme-(\d+)\//)?.[1];++ if (pluginMatch || themeIdMatch) {+ const source = {+ type: pluginMatch ? "plugin" : "theme",+ name: pluginMatch || getThemeInfo(parseInt(themeIdMatch, 10)),+ id: themeIdMatch,+ };+ options.source = source;+ message = `${consolePrefix(null, source)} ${message}`;+ }++ // Only print each message once, to avoid flood of console noise+ if (seenMessages.has(message)) {+ return;+ }+ seenMessages.add(message);+ options.url = "https://meta.discourse.org/t/337276";+ next(message, options);+ });++ registered = true;+ },+};diff --git a/app/assets/javascripts/discourse/app/lib/highlight-syntax.js b/app/assets/javascripts/discourse/app/lib/highlight-syntax.jsindex 279f0069832..6188932840c 100644--- a/app/assets/javascripts/discourse/app/lib/highlight-syntax.js+++ b/app/assets/javascripts/discourse/app/lib/highlight-syntax.js@@ -1,4 +1,4 @@-import DEBUG from "@glimmer/env";+import { DEBUG } from "@glimmer/env";import { waitForPromise } from "@ember/test-waiters";import mergeHTMLPlugin from "discourse/lib/highlight-syntax-merge-html-plugin";import { isTesting } from "discourse-common/config/environment";diff --git a/app/assets/javascripts/discourse/app/services/deprecation-warning-handler.js b/app/assets/javascripts/discourse/app/services/deprecation-warning-handler.jsindex d9c494d1496..331bade034f 100644--- a/app/assets/javascripts/discourse/app/services/deprecation-warning-handler.js+++ b/app/assets/javascripts/discourse/app/services/deprecation-warning-handler.js@@ -1,3 +1,4 @@+import { DEBUG } from "@glimmer/env";import { registerDeprecationHandler } from "@ember/debug";import Service, { service } from "@ember/service";import { addGlobalNotice } from "discourse/components/global-notice";@@ -19,9 +20,13 @@ export const CRITICAL_DEPRECATIONS = ["discourse.plugin-outlet-tag-name","discourse.plugin-outlet-parent-view","discourse.d-button-action-string",- /^(?!discourse\.)/, // All unsilenced ember deprecations];+if (DEBUG) {+ // used in system specs+ CRITICAL_DEPRECATIONS.push("fake-deprecation");+}+// Deprecation handling APIs don't have any way to unregister handlers, so we set up permanent// handlers and link them up to the application lifecycle using module-local state.let handler;