mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-11 22:15:30 +00:00
Beware threads/workers might not inherit \pocketmine\PATH
if the inherit flags don't include PTHREADS_INHERIT_CONSTANTS, this code would fail. Store the Composer autoloader path in advance instead.
This commit is contained in:
parent
c601816586
commit
82948726ed
@ -30,6 +30,9 @@ abstract class Thread extends \Thread{
|
|||||||
|
|
||||||
/** @var \ClassLoader */
|
/** @var \ClassLoader */
|
||||||
protected $classLoader;
|
protected $classLoader;
|
||||||
|
/** @var string|null */
|
||||||
|
protected $composerAutoloaderPath;
|
||||||
|
|
||||||
protected $isKilled = false;
|
protected $isKilled = false;
|
||||||
|
|
||||||
public function getClassLoader(){
|
public function getClassLoader(){
|
||||||
@ -37,6 +40,8 @@ abstract class Thread extends \Thread{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function setClassLoader(\ClassLoader $loader = null){
|
public function setClassLoader(\ClassLoader $loader = null){
|
||||||
|
$this->composerAutoloaderPath = \pocketmine\COMPOSER_AUTOLOADER_PATH;
|
||||||
|
|
||||||
if($loader === null){
|
if($loader === null){
|
||||||
$loader = Server::getInstance()->getLoader();
|
$loader = Server::getInstance()->getLoader();
|
||||||
}
|
}
|
||||||
@ -51,7 +56,9 @@ abstract class Thread extends \Thread{
|
|||||||
* (unless you are using a custom autoloader).
|
* (unless you are using a custom autoloader).
|
||||||
*/
|
*/
|
||||||
public function registerClassLoader(){
|
public function registerClassLoader(){
|
||||||
require(\pocketmine\PATH . "vendor/autoload.php");
|
if($this->composerAutoloaderPath !== null){
|
||||||
|
require $this->composerAutoloaderPath;
|
||||||
|
}
|
||||||
if($this->classLoader !== null){
|
if($this->classLoader !== null){
|
||||||
$this->classLoader->register(false);
|
$this->classLoader->register(false);
|
||||||
}
|
}
|
||||||
|
@ -30,6 +30,8 @@ abstract class Worker extends \Worker{
|
|||||||
|
|
||||||
/** @var \ClassLoader */
|
/** @var \ClassLoader */
|
||||||
protected $classLoader;
|
protected $classLoader;
|
||||||
|
/** @var string|null */
|
||||||
|
protected $composerAutoloaderPath;
|
||||||
|
|
||||||
protected $isKilled = false;
|
protected $isKilled = false;
|
||||||
|
|
||||||
@ -38,6 +40,8 @@ abstract class Worker extends \Worker{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function setClassLoader(\ClassLoader $loader = null){
|
public function setClassLoader(\ClassLoader $loader = null){
|
||||||
|
$this->composerAutoloaderPath = \pocketmine\COMPOSER_AUTOLOADER_PATH;
|
||||||
|
|
||||||
if($loader === null){
|
if($loader === null){
|
||||||
$loader = Server::getInstance()->getLoader();
|
$loader = Server::getInstance()->getLoader();
|
||||||
}
|
}
|
||||||
@ -52,7 +56,9 @@ abstract class Worker extends \Worker{
|
|||||||
* (unless you are using a custom autoloader).
|
* (unless you are using a custom autoloader).
|
||||||
*/
|
*/
|
||||||
public function registerClassLoader(){
|
public function registerClassLoader(){
|
||||||
require(\pocketmine\PATH . "vendor/autoload.php");
|
if($this->composerAutoloaderPath !== null){
|
||||||
|
require $this->composerAutoloaderPath;
|
||||||
|
}
|
||||||
if($this->classLoader !== null){
|
if($this->classLoader !== null){
|
||||||
$this->classLoader->register(false);
|
$this->classLoader->register(false);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user