mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merge pull request #10556 from creative-commoners/pulls/4/deprecation-no-manifests
FIX Handle calling Deprecation::notice() before manifests are available
This commit is contained in:
commit
25241a98e1
@ -9,6 +9,8 @@ use BadMethodCallException;
|
|||||||
*/
|
*/
|
||||||
class InjectorLoader
|
class InjectorLoader
|
||||||
{
|
{
|
||||||
|
public const NO_MANIFESTS_AVAILABLE = 'No injector manifests available';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
* @var self
|
* @var self
|
||||||
@ -42,7 +44,7 @@ class InjectorLoader
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (empty($this->manifests)) {
|
if (empty($this->manifests)) {
|
||||||
throw new BadMethodCallException("No injector manifests available");
|
throw new BadMethodCallException(self::NO_MANIFESTS_AVAILABLE);
|
||||||
}
|
}
|
||||||
return $this->manifests[count($this->manifests) - 1];
|
return $this->manifests[count($this->manifests) - 1];
|
||||||
}
|
}
|
||||||
|
@ -2,8 +2,11 @@
|
|||||||
|
|
||||||
namespace SilverStripe\Dev;
|
namespace SilverStripe\Dev;
|
||||||
|
|
||||||
|
use BadMethodCallException;
|
||||||
|
use Exception;
|
||||||
use SilverStripe\Control\Director;
|
use SilverStripe\Control\Director;
|
||||||
use SilverStripe\Core\Environment;
|
use SilverStripe\Core\Environment;
|
||||||
|
use SilverStripe\Core\Injector\InjectorLoader;
|
||||||
use SilverStripe\Core\Manifest\Module;
|
use SilverStripe\Core\Manifest\Module;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -234,6 +237,14 @@ class Deprecation
|
|||||||
} else {
|
} else {
|
||||||
user_error($string, self::$notice_level);
|
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;
|
||||||
|
}
|
||||||
} finally {
|
} finally {
|
||||||
static::$inside_notice = false;
|
static::$inside_notice = false;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user