Deactivate a plugin, if it throws an exception

This commit is contained in:
Alexander Nell 2020-05-19 20:48:56 +02:00
parent 7b0e16bfdf
commit 8760364d82

View File

@ -122,13 +122,12 @@ class ErrorHandler {
$report['FileLine'] = self::stripBaseDir($fileLine); $report['FileLine'] = self::stripBaseDir($fileLine);
} }
if ($sourceClass) { if ($sourceClass) {
$report['SourceClass'] = $sourceClass; $report['SourceClass'] = $sourceClass;
$pluginId = PluginManager::getPluginId($sourceClass); $pluginId = PluginManager::getPluginId($sourceClass);
if ($pluginId > 0) { if ($pluginId > 0) {
$report['PluginId'] = $pluginId; $report['PluginId'] = $pluginId;
$report['PluginVersion'] = PluginManager::getPluginVersion($sourceClass);
if ($isFatalError) { if ($isFatalError) {
$this->maniaControl->getPluginManager()->deactivatePlugin($sourceClass); $this->maniaControl->getPluginManager()->deactivatePlugin($sourceClass);
@ -137,9 +136,6 @@ class ErrorHandler {
$isPluginError = true; $isPluginError = true;
} }
} }
$report['PluginId'] = $pluginId;
$report['PluginVersion'] = PluginManager::getPluginVersion($sourceClass);
} }
if ($traceString) { if ($traceString) {
@ -478,9 +474,19 @@ class ErrorHandler {
$report['Message'] = $message; $report['Message'] = $message;
$report['Class'] = $exceptionClass; $report['Class'] = $exceptionClass;
$report['FileLine'] = self::stripBaseDir($exception->getFile()) . ': ' . $exception->getLine(); $report['FileLine'] = self::stripBaseDir($exception->getFile()) . ': ' . $exception->getLine();
if ($sourceClass) {
$report['SourceClass'] = $sourceClass; $report['SourceClass'] = $sourceClass;
$report['PluginId'] = PluginManager::getPluginId($sourceClass); $pluginId = PluginManager::getPluginId($sourceClass);
if ($pluginId > 0) {
$report['PluginId'] = $pluginId;
$report['PluginVersion'] = PluginManager::getPluginVersion($sourceClass); $report['PluginVersion'] = PluginManager::getPluginVersion($sourceClass);
$this->maniaControl->getPluginManager()->deactivatePlugin($sourceClass);
$this->maniaControl->getChat()->sendError("Plugin " . $sourceClass . " has an Error -> The Plugin will be deactivated and ManiaControl restarted");
Logger::logError("Plugin " . $sourceClass . " has an Error -> The Plugin will be deactivated and ManiaControl restarted");
}
}
$report['Backtrace'] = $traceString; $report['Backtrace'] = $traceString;
$report['OperatingSystem'] = php_uname(); $report['OperatingSystem'] = php_uname();
$report['PHPVersion'] = phpversion(); $report['PHPVersion'] = phpversion();