-
Notifications
You must be signed in to change notification settings - Fork 824
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FIX Handle calling Deprecation::notice() before manifests are available #10556
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,8 +2,11 @@ | |
|
||
namespace SilverStripe\Dev; | ||
|
||
use BadMethodCallException; | ||
use Exception; | ||
use SilverStripe\Control\Director; | ||
use SilverStripe\Core\Environment; | ||
use SilverStripe\Core\Injector\InjectorLoader; | ||
use SilverStripe\Core\Manifest\Module; | ||
|
||
/** | ||
|
@@ -234,6 +237,14 @@ public static function notice($atVersion, $string = '', $scope = Deprecation::SC | |
} else { | ||
user_error($string, self::$notice_level); | ||
} | ||
} catch (BadMethodCallException $e) { | ||
if ($e->getMessage() === InjectorLoader::NO_MANIFESTS_AVAILABLE) { | ||
// noop | ||
// this can happen when calling Deprecation::notice() before manifests are available, i.e. | ||
// some of the code involved in creating the manifests calls Deprecation::notice() | ||
} else { | ||
throw $e; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure about this, but I'm assuming that every exception rethrown here, will appear to be coming from There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't believe so, I think it just throws the original php -r '
class A {
function f() {
throw new \Exception();
}
}
class B {
function f() {
try {
(new A)->f();
} catch (\Exception $e) {
throw $e;
}
}
}
class C {
function f() {
try {
(new B)->f();
} catch (\Exception $e) {
var_dump($e->getLine());
var_dump($e->getTraceAsString());
}
}
}
(new C)->f();
'
int(4)
string(108) "#0 Command line code(10): A->f()
#1 Command line code(19): B->f()
#2 Command line code(26): C->f()
#3 {main}" |
||
} | ||
} finally { | ||
static::$inside_notice = false; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like this would be a good place to throw a custom exception. Maybe, we can look at doing something like in CMS5/CMS6.