mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-10 07:49:42 +00:00
make more use of igbinary_serialize() and igbinary_unserialize()
This commit is contained in:
parent
6f4d4be3da
commit
82b3e3398b
@ -32,9 +32,9 @@ use pocketmine\network\mcpe\protocol\types\login\JwtChainLinkBody;
|
||||
use pocketmine\network\mcpe\protocol\types\login\JwtHeader;
|
||||
use pocketmine\scheduler\AsyncTask;
|
||||
use function base64_decode;
|
||||
use function serialize;
|
||||
use function igbinary_serialize;
|
||||
use function igbinary_unserialize;
|
||||
use function time;
|
||||
use function unserialize;
|
||||
|
||||
class ProcessLoginTask extends AsyncTask{
|
||||
private const TLS_KEY_ON_COMPLETION = "completion";
|
||||
@ -73,7 +73,7 @@ class ProcessLoginTask extends AsyncTask{
|
||||
*/
|
||||
public function __construct(array $chainJwts, string $clientDataJwt, bool $authRequired, \Closure $onCompletion){
|
||||
$this->storeLocal(self::TLS_KEY_ON_COMPLETION, $onCompletion);
|
||||
$this->chain = serialize($chainJwts);
|
||||
$this->chain = igbinary_serialize($chainJwts);
|
||||
$this->clientDataJwt = $clientDataJwt;
|
||||
$this->authRequired = $authRequired;
|
||||
}
|
||||
@ -89,7 +89,7 @@ class ProcessLoginTask extends AsyncTask{
|
||||
|
||||
private function validateChain() : PublicKeyInterface{
|
||||
/** @var string[] $chain */
|
||||
$chain = unserialize($this->chain);
|
||||
$chain = igbinary_unserialize($this->chain);
|
||||
|
||||
$currentKey = null;
|
||||
$first = true;
|
||||
|
@ -24,11 +24,11 @@ declare(strict_types=1);
|
||||
namespace pocketmine\scheduler;
|
||||
|
||||
use pocketmine\utils\AssumptionFailedError;
|
||||
use function igbinary_serialize;
|
||||
use function igbinary_unserialize;
|
||||
use function is_scalar;
|
||||
use function is_string;
|
||||
use function serialize;
|
||||
use function spl_object_id;
|
||||
use function unserialize;
|
||||
|
||||
/**
|
||||
* Class used to run async tasks in other threads.
|
||||
@ -109,7 +109,7 @@ abstract class AsyncTask extends \Threaded{
|
||||
public function getResult(){
|
||||
if($this->serialized){
|
||||
if(!is_string($this->result)) throw new AssumptionFailedError("Result expected to be a serialized string");
|
||||
return unserialize($this->result);
|
||||
return igbinary_unserialize($this->result);
|
||||
}
|
||||
return $this->result;
|
||||
}
|
||||
@ -130,7 +130,7 @@ abstract class AsyncTask extends \Threaded{
|
||||
* @param mixed $result
|
||||
*/
|
||||
public function setResult($result) : void{
|
||||
$this->result = ($this->serialized = !is_scalar($result)) ? serialize($result) : $result;
|
||||
$this->result = ($this->serialized = !is_scalar($result)) ? igbinary_serialize($result) : $result;
|
||||
}
|
||||
|
||||
public function setSubmitted() : void{
|
||||
@ -161,7 +161,7 @@ abstract class AsyncTask extends \Threaded{
|
||||
* @param mixed $progress A value that can be safely serialize()'ed.
|
||||
*/
|
||||
public function publishProgress($progress) : void{
|
||||
$this->progressUpdates[] = serialize($progress);
|
||||
$this->progressUpdates[] = igbinary_serialize($progress);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -170,7 +170,7 @@ abstract class AsyncTask extends \Threaded{
|
||||
public function checkProgressUpdates() : void{
|
||||
while($this->progressUpdates->count() !== 0){
|
||||
$progress = $this->progressUpdates->shift();
|
||||
$this->onProgressUpdate(unserialize($progress));
|
||||
$this->onProgressUpdate(igbinary_unserialize($progress));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -25,8 +25,8 @@ namespace pocketmine\scheduler;
|
||||
|
||||
use pocketmine\utils\Internet;
|
||||
use pocketmine\utils\InternetException;
|
||||
use function serialize;
|
||||
use function unserialize;
|
||||
use function igbinary_serialize;
|
||||
use function igbinary_unserialize;
|
||||
|
||||
/**
|
||||
* Executes a consecutive list of cURL operations.
|
||||
@ -48,12 +48,12 @@ class BulkCurlTask extends AsyncTask{
|
||||
* @phpstan-param list<array{page: string, timeout?: float, extraHeaders?: list<string>, extraOpts?: array<int, mixed>}> $operations
|
||||
*/
|
||||
public function __construct(array $operations){
|
||||
$this->operations = serialize($operations);
|
||||
$this->operations = igbinary_serialize($operations);
|
||||
}
|
||||
|
||||
public function onRun() : void{
|
||||
/** @phpstan-var list<array{page: string, timeout?: float, extraHeaders?: list<string>, extraOpts?: array<int, mixed>}> $operations */
|
||||
$operations = unserialize($this->operations);
|
||||
$operations = igbinary_unserialize($this->operations);
|
||||
$results = [];
|
||||
foreach($operations as $op){
|
||||
try{
|
||||
|
@ -26,8 +26,8 @@ namespace pocketmine\world\generator;
|
||||
use pocketmine\scheduler\AsyncTask;
|
||||
use pocketmine\world\biome\Biome;
|
||||
use pocketmine\world\World;
|
||||
use function serialize;
|
||||
use function unserialize;
|
||||
use function igbinary_serialize;
|
||||
use function igbinary_unserialize;
|
||||
|
||||
class GeneratorRegisterTask extends AsyncTask{
|
||||
|
||||
@ -48,7 +48,7 @@ class GeneratorRegisterTask extends AsyncTask{
|
||||
*/
|
||||
public function __construct(World $world, string $generatorClass, array $generatorSettings = []){
|
||||
$this->generatorClass = $generatorClass;
|
||||
$this->settings = serialize($generatorSettings);
|
||||
$this->settings = igbinary_serialize($generatorSettings);
|
||||
$this->seed = $world->getSeed();
|
||||
$this->worldId = $world->getId();
|
||||
$this->worldHeight = $world->getWorldHeight();
|
||||
@ -63,7 +63,7 @@ class GeneratorRegisterTask extends AsyncTask{
|
||||
* @var Generator $generator
|
||||
* @see Generator::__construct()
|
||||
*/
|
||||
$generator = new $this->generatorClass($manager, $this->seed, unserialize($this->settings));
|
||||
$generator = new $this->generatorClass($manager, $this->seed, igbinary_unserialize($this->settings));
|
||||
$this->worker->saveToThreadStore("generation.world{$this->worldId}.generator", $generator);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user