DEV: Improve modifyClass warning message (#21140)

- Print warning when it affects user/currentUser
- Improve description and link to Meta topic
This commit is contained in:
David Taylor 2023-04-18 11:41:38 +01:00 committed by GitHub
parent 95238be953
commit 7a8ed517a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 2 deletions

View File

@ -187,11 +187,15 @@ class PluginApi {
_resolveClass(resolverName, opts) {
opts = opts || {};
if (this.container.cache[resolverName]) {
if (
this.container.cache[resolverName] ||
(resolverName === "model:user" &&
this.container.lookup("service:current-user"))
) {
// eslint-disable-next-line no-console
console.warn(
consolePrefix(),
`"${resolverName}" was already cached in the container. Changes won't be applied.`
`"${resolverName}" has already been initialized and registered as a singleton. Move the modifyClass call earlier in the boot process for changes to take effect. https://meta.discourse.org/t/262064`
);
}