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