mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-11 04:17:48 +00:00
CrashDump: more robust core crash detection
This commit is contained in:
parent
994062f6dc
commit
104e90b794
@ -310,8 +310,8 @@ class CrashDump{
|
|||||||
}
|
}
|
||||||
|
|
||||||
private function determinePluginFromFile(string $filePath, bool $crashFrame) : bool{
|
private function determinePluginFromFile(string $filePath, bool $crashFrame) : bool{
|
||||||
$frameCleanPath = Utils::cleanPath($filePath); //this will be empty in phar stub
|
$frameCleanPath = Utils::cleanPath($filePath);
|
||||||
if(strpos($frameCleanPath, "plugins") === 0){
|
if(strpos($frameCleanPath, Utils::CLEAN_PATH_SRC_PREFIX) !== 0){
|
||||||
$this->addLine();
|
$this->addLine();
|
||||||
if($crashFrame){
|
if($crashFrame){
|
||||||
$this->addLine("THIS CRASH WAS CAUSED BY A PLUGIN");
|
$this->addLine("THIS CRASH WAS CAUSED BY A PLUGIN");
|
||||||
|
@ -106,6 +106,9 @@ class Utils{
|
|||||||
public const OS_BSD = "bsd";
|
public const OS_BSD = "bsd";
|
||||||
public const OS_UNKNOWN = "other";
|
public const OS_UNKNOWN = "other";
|
||||||
|
|
||||||
|
public const CLEAN_PATH_SRC_PREFIX = "pmsrc";
|
||||||
|
public const CLEAN_PATH_PLUGINS_PREFIX = "plugins";
|
||||||
|
|
||||||
/** @var string|null */
|
/** @var string|null */
|
||||||
public static $os;
|
public static $os;
|
||||||
/** @var UUID|null */
|
/** @var UUID|null */
|
||||||
@ -604,13 +607,13 @@ class Utils{
|
|||||||
//remove relative paths
|
//remove relative paths
|
||||||
//TODO: make these paths dynamic so they can be unit-tested against
|
//TODO: make these paths dynamic so they can be unit-tested against
|
||||||
static $cleanPaths = [
|
static $cleanPaths = [
|
||||||
\pocketmine\PLUGIN_PATH => "plugins", //this has to come BEFORE \pocketmine\PATH because it's inside that by default on src installations
|
\pocketmine\PLUGIN_PATH => self::CLEAN_PATH_PLUGINS_PREFIX, //this has to come BEFORE \pocketmine\PATH because it's inside that by default on src installations
|
||||||
\pocketmine\PATH => ""
|
\pocketmine\PATH => self::CLEAN_PATH_SRC_PREFIX
|
||||||
];
|
];
|
||||||
foreach($cleanPaths as $cleanPath => $replacement){
|
foreach($cleanPaths as $cleanPath => $replacement){
|
||||||
$cleanPath = rtrim(str_replace([DIRECTORY_SEPARATOR, "phar://"], ["/", ""], $cleanPath), "/");
|
$cleanPath = rtrim(str_replace([DIRECTORY_SEPARATOR, "phar://"], ["/", ""], $cleanPath), "/");
|
||||||
if(strpos($result, $cleanPath) === 0){
|
if(strpos($result, $cleanPath) === 0){
|
||||||
$result = ltrim(str_replace($cleanPath, $replacement, $result), "/");
|
$result = ltrim(str_replace($cleanPath, "[$replacement]", $result), "/");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $result;
|
return $result;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user