mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-09 13:14:54 +00:00
Remove VERSION and GIT_COMMIT constants
these are now lazily computed in VersionInfo as needed.
This commit is contained in:
parent
2645b19617
commit
2c29634d03
@ -61,7 +61,7 @@ function main(array $argv) : void{
|
|||||||
if(isset($argv[1])){
|
if(isset($argv[1])){
|
||||||
$currentVer = new VersionString($argv[1]);
|
$currentVer = new VersionString($argv[1]);
|
||||||
}else{
|
}else{
|
||||||
$currentVer = new VersionString(VersionInfo::BASE_VERSION);
|
$currentVer = VersionInfo::getVersionObj();
|
||||||
}
|
}
|
||||||
$nextVer = new VersionString(sprintf(
|
$nextVer = new VersionString(sprintf(
|
||||||
"%u.%u.%u",
|
"%u.%u.%u",
|
||||||
|
@ -30,7 +30,6 @@ use pocketmine\plugin\PluginBase;
|
|||||||
use pocketmine\plugin\PluginManager;
|
use pocketmine\plugin\PluginManager;
|
||||||
use pocketmine\utils\Filesystem;
|
use pocketmine\utils\Filesystem;
|
||||||
use pocketmine\utils\Utils;
|
use pocketmine\utils\Utils;
|
||||||
use pocketmine\utils\VersionString;
|
|
||||||
use function base64_encode;
|
use function base64_encode;
|
||||||
use function date;
|
use function date;
|
||||||
use function error_get_last;
|
use function error_get_last;
|
||||||
@ -308,14 +307,14 @@ class CrashDump{
|
|||||||
}
|
}
|
||||||
|
|
||||||
private function generalData() : void{
|
private function generalData() : void{
|
||||||
$version = new VersionString(VersionInfo::BASE_VERSION, VersionInfo::IS_DEVELOPMENT_BUILD, VersionInfo::BUILD_NUMBER);
|
$version = VersionInfo::getVersionObj();
|
||||||
$this->data["general"] = [];
|
$this->data["general"] = [];
|
||||||
$this->data["general"]["name"] = $this->server->getName();
|
$this->data["general"]["name"] = $this->server->getName();
|
||||||
$this->data["general"]["base_version"] = VersionInfo::BASE_VERSION;
|
$this->data["general"]["base_version"] = VersionInfo::BASE_VERSION;
|
||||||
$this->data["general"]["build"] = VersionInfo::BUILD_NUMBER;
|
$this->data["general"]["build"] = VersionInfo::BUILD_NUMBER;
|
||||||
$this->data["general"]["is_dev"] = VersionInfo::IS_DEVELOPMENT_BUILD;
|
$this->data["general"]["is_dev"] = VersionInfo::IS_DEVELOPMENT_BUILD;
|
||||||
$this->data["general"]["protocol"] = ProtocolInfo::CURRENT_PROTOCOL;
|
$this->data["general"]["protocol"] = ProtocolInfo::CURRENT_PROTOCOL;
|
||||||
$this->data["general"]["git"] = \pocketmine\GIT_COMMIT;
|
$this->data["general"]["git"] = VersionInfo::getGitHash();
|
||||||
$this->data["general"]["uname"] = php_uname("a");
|
$this->data["general"]["uname"] = php_uname("a");
|
||||||
$this->data["general"]["php"] = phpversion();
|
$this->data["general"]["php"] = phpversion();
|
||||||
$this->data["general"]["zend"] = zend_version();
|
$this->data["general"]["zend"] = zend_version();
|
||||||
@ -323,7 +322,7 @@ class CrashDump{
|
|||||||
$this->data["general"]["os"] = Utils::getOS();
|
$this->data["general"]["os"] = Utils::getOS();
|
||||||
$this->data["general"]["composer_libraries"] = Versions::VERSIONS;
|
$this->data["general"]["composer_libraries"] = Versions::VERSIONS;
|
||||||
$this->addLine($this->server->getName() . " version: " . $version->getFullVersion(true) . " [Protocol " . ProtocolInfo::CURRENT_PROTOCOL . "]");
|
$this->addLine($this->server->getName() . " version: " . $version->getFullVersion(true) . " [Protocol " . ProtocolInfo::CURRENT_PROTOCOL . "]");
|
||||||
$this->addLine("Git commit: " . \pocketmine\GIT_COMMIT);
|
$this->addLine("Git commit: " . VersionInfo::getGitHash());
|
||||||
$this->addLine("uname -a: " . php_uname("a"));
|
$this->addLine("uname -a: " . php_uname("a"));
|
||||||
$this->addLine("PHP Version: " . phpversion());
|
$this->addLine("PHP Version: " . phpversion());
|
||||||
$this->addLine("Zend version: " . zend_version());
|
$this->addLine("Zend version: " . zend_version());
|
||||||
|
@ -197,23 +197,6 @@ namespace pocketmine {
|
|||||||
|
|
||||||
ErrorToExceptionHandler::set();
|
ErrorToExceptionHandler::set();
|
||||||
|
|
||||||
$version = new VersionString(VersionInfo::BASE_VERSION, VersionInfo::IS_DEVELOPMENT_BUILD, VersionInfo::BUILD_NUMBER);
|
|
||||||
define('pocketmine\VERSION', $version->getFullVersion(true));
|
|
||||||
|
|
||||||
$gitHash = str_repeat("00", 20);
|
|
||||||
|
|
||||||
if(\Phar::running(true) === ""){
|
|
||||||
$gitHash = Git::getRepositoryStatePretty(\pocketmine\PATH);
|
|
||||||
}else{
|
|
||||||
$phar = new \Phar(\Phar::running(false));
|
|
||||||
$meta = $phar->getMetadata();
|
|
||||||
if(isset($meta["git"])){
|
|
||||||
$gitHash = $meta["git"];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
define('pocketmine\GIT_COMMIT', $gitHash);
|
|
||||||
|
|
||||||
$opts = getopt("", ["data:", "plugins:", "no-wizard", "enable-ansi", "disable-ansi"]);
|
$opts = getopt("", ["data:", "plugins:", "no-wizard", "enable-ansi", "disable-ansi"]);
|
||||||
|
|
||||||
$dataPath = isset($opts["data"]) ? $opts["data"] . DIRECTORY_SEPARATOR : realpath(getcwd()) . DIRECTORY_SEPARATOR;
|
$dataPath = isset($opts["data"]) ? $opts["data"] . DIRECTORY_SEPARATOR : realpath(getcwd()) . DIRECTORY_SEPARATOR;
|
||||||
|
@ -288,7 +288,7 @@ class Server{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function getPocketMineVersion() : string{
|
public function getPocketMineVersion() : string{
|
||||||
return \pocketmine\VERSION;
|
return VersionInfo::getVersionObj()->getFullVersion(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getVersion() : string{
|
public function getVersion() : string{
|
||||||
@ -1455,7 +1455,7 @@ class Server{
|
|||||||
$report = false;
|
$report = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(strrpos(\pocketmine\GIT_COMMIT, "-dirty") !== false or \pocketmine\GIT_COMMIT === str_repeat("00", 20)){
|
if(strrpos(VersionInfo::getGitHash(), "-dirty") !== false or VersionInfo::getGitHash() === str_repeat("00", 20)){
|
||||||
$this->logger->debug("Not sending crashdump due to locally modified");
|
$this->logger->debug("Not sending crashdump due to locally modified");
|
||||||
$report = false; //Don't send crashdumps for locally modified builds
|
$report = false; //Don't send crashdumps for locally modified builds
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,10 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace pocketmine;
|
namespace pocketmine;
|
||||||
|
|
||||||
|
use pocketmine\utils\Git;
|
||||||
|
use pocketmine\utils\VersionString;
|
||||||
|
use function str_repeat;
|
||||||
|
|
||||||
final class VersionInfo{
|
final class VersionInfo{
|
||||||
public const NAME = "PocketMine-MP";
|
public const NAME = "PocketMine-MP";
|
||||||
public const BASE_VERSION = "4.0.0";
|
public const BASE_VERSION = "4.0.0";
|
||||||
@ -32,4 +36,37 @@ final class VersionInfo{
|
|||||||
private function __construct(){
|
private function __construct(){
|
||||||
//NOOP
|
//NOOP
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @var string|null */
|
||||||
|
private static $gitHash = null;
|
||||||
|
|
||||||
|
public static function getGitHash() : string{
|
||||||
|
if(self::$gitHash === null){
|
||||||
|
$gitHash = str_repeat("00", 20);
|
||||||
|
|
||||||
|
if(\Phar::running(true) === ""){
|
||||||
|
$gitHash = Git::getRepositoryStatePretty(\pocketmine\PATH);
|
||||||
|
}else{
|
||||||
|
$phar = new \Phar(\Phar::running(false));
|
||||||
|
$meta = $phar->getMetadata();
|
||||||
|
if(isset($meta["git"])){
|
||||||
|
$gitHash = $meta["git"];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
self::$gitHash = $gitHash;
|
||||||
|
}
|
||||||
|
|
||||||
|
return self::$gitHash;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @var VersionString|null */
|
||||||
|
private static $fullVersion = null;
|
||||||
|
|
||||||
|
public static function getVersionObj() : VersionString{
|
||||||
|
if(self::$fullVersion === null){
|
||||||
|
self::$fullVersion = new VersionString(self::BASE_VERSION, self::IS_DEVELOPMENT_BUILD, self::BUILD_NUMBER);
|
||||||
|
}
|
||||||
|
return self::$fullVersion;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,6 @@ use pocketmine\utils\AssumptionFailedError;
|
|||||||
use pocketmine\utils\Internet;
|
use pocketmine\utils\Internet;
|
||||||
use pocketmine\utils\Process;
|
use pocketmine\utils\Process;
|
||||||
use pocketmine\utils\Utils;
|
use pocketmine\utils\Utils;
|
||||||
use pocketmine\utils\VersionString;
|
|
||||||
use pocketmine\uuid\UUID;
|
use pocketmine\uuid\UUID;
|
||||||
use pocketmine\VersionInfo;
|
use pocketmine\VersionInfo;
|
||||||
use function array_map;
|
use function array_map;
|
||||||
@ -72,7 +71,7 @@ class SendUsageTask extends AsyncTask{
|
|||||||
case self::TYPE_OPEN:
|
case self::TYPE_OPEN:
|
||||||
$data["event"] = "open";
|
$data["event"] = "open";
|
||||||
|
|
||||||
$version = new VersionString(VersionInfo::BASE_VERSION, VersionInfo::IS_DEVELOPMENT_BUILD, VersionInfo::BUILD_NUMBER);
|
$version = VersionInfo::getVersionObj();
|
||||||
|
|
||||||
$data["server"] = [
|
$data["server"] = [
|
||||||
"port" => $server->getPort(),
|
"port" => $server->getPort(),
|
||||||
|
@ -160,7 +160,7 @@ class AutoUpdater{
|
|||||||
if($this->updateInfo === null){
|
if($this->updateInfo === null){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$currentVersion = new VersionString(VersionInfo::BASE_VERSION, VersionInfo::IS_DEVELOPMENT_BUILD, VersionInfo::BUILD_NUMBER);
|
$currentVersion = VersionInfo::getVersionObj();
|
||||||
try{
|
try{
|
||||||
$newVersion = new VersionString($this->updateInfo->base_version, $this->updateInfo->is_dev, $this->updateInfo->build);
|
$newVersion = new VersionString($this->updateInfo->base_version, $this->updateInfo->is_dev, $this->updateInfo->build);
|
||||||
}catch(\InvalidArgumentException $e){
|
}catch(\InvalidArgumentException $e){
|
||||||
|
@ -224,7 +224,7 @@ class Internet{
|
|||||||
CURLOPT_RETURNTRANSFER => true,
|
CURLOPT_RETURNTRANSFER => true,
|
||||||
CURLOPT_CONNECTTIMEOUT_MS => (int) ($timeout * 1000),
|
CURLOPT_CONNECTTIMEOUT_MS => (int) ($timeout * 1000),
|
||||||
CURLOPT_TIMEOUT_MS => (int) ($timeout * 1000),
|
CURLOPT_TIMEOUT_MS => (int) ($timeout * 1000),
|
||||||
CURLOPT_HTTPHEADER => array_merge(["User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:12.0) Gecko/20100101 Firefox/12.0 " . VersionInfo::NAME . "/" . \pocketmine\VERSION], $extraHeaders),
|
CURLOPT_HTTPHEADER => array_merge(["User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:12.0) Gecko/20100101 Firefox/12.0 " . VersionInfo::NAME . "/" . VersionInfo::getVersionObj()->getFullVersion(true)], $extraHeaders),
|
||||||
CURLOPT_HEADER => true
|
CURLOPT_HEADER => true
|
||||||
]);
|
]);
|
||||||
try{
|
try{
|
||||||
|
@ -25,6 +25,4 @@ define('pocketmine\_PHPSTAN_ANALYSIS', true);
|
|||||||
|
|
||||||
//TODO: these need to be defined properly or removed
|
//TODO: these need to be defined properly or removed
|
||||||
define('pocketmine\COMPOSER_AUTOLOADER_PATH', dirname(__DIR__, 2) . '/vendor/autoload.php');
|
define('pocketmine\COMPOSER_AUTOLOADER_PATH', dirname(__DIR__, 2) . '/vendor/autoload.php');
|
||||||
define('pocketmine\GIT_COMMIT', str_repeat('00', 20));
|
|
||||||
define('pocketmine\PLUGIN_PATH', '');
|
define('pocketmine\PLUGIN_PATH', '');
|
||||||
define('pocketmine\VERSION', '9.9.9');
|
|
||||||
|
@ -30,11 +30,6 @@ parameters:
|
|||||||
count: 7
|
count: 7
|
||||||
path: ../../../src/MemoryManager.php
|
path: ../../../src/MemoryManager.php
|
||||||
|
|
||||||
-
|
|
||||||
message: "#^Cannot access offset 'git' on mixed\\.$#"
|
|
||||||
count: 2
|
|
||||||
path: ../../../src/PocketMine.php
|
|
||||||
|
|
||||||
-
|
-
|
||||||
message: "#^Cannot cast mixed to int\\.$#"
|
message: "#^Cannot cast mixed to int\\.$#"
|
||||||
count: 6
|
count: 6
|
||||||
@ -90,6 +85,11 @@ parameters:
|
|||||||
count: 1
|
count: 1
|
||||||
path: ../../../src/ServerConfigGroup.php
|
path: ../../../src/ServerConfigGroup.php
|
||||||
|
|
||||||
|
-
|
||||||
|
message: "#^Cannot access offset 'git' on mixed\\.$#"
|
||||||
|
count: 2
|
||||||
|
path: ../../../src/VersionInfo.php
|
||||||
|
|
||||||
-
|
-
|
||||||
message: "#^Cannot cast mixed to string\\.$#"
|
message: "#^Cannot cast mixed to string\\.$#"
|
||||||
count: 1
|
count: 1
|
||||||
|
Loading…
x
Reference in New Issue
Block a user