1
0
mirror of https://github.com/danog/MadelineProto.git synced 2024-11-27 03:14:39 +01:00

Startup fixes

This commit is contained in:
Daniil Gentili 2023-01-24 12:45:55 +01:00
parent 06f7b08a32
commit 868f6d1110
9 changed files with 11 additions and 11 deletions

View File

@ -146,7 +146,7 @@ final class API extends InternalDoc
*/
public function __construct(string $session, array|SettingsAbstract $settings = [])
{
Magic::start(true);
Magic::start(light: true);
$settings = Settings::parseFromLegacy($settings);
$this->session = new SessionPaths($session);
$this->wrapper = new APIWrapper($this, $this->exportNamespace());

View File

@ -103,7 +103,7 @@ use Webmozart\Assert\Assert;
$runnerId = (int) $runnerId;
try {
Magic::start();
Magic::start(light: false);
Magic::$script_cwd = $_GET['cwd'] ?? Magic::getcwd();
$session = new SessionPaths($session);

View File

@ -602,7 +602,7 @@ final class MTProto implements TLCallback, LoggerGetter
private function initialize(Settings|SettingsEmpty $settings): void
{
// Initialize needed stuffs
Magic::start();
Magic::start(light: false);
// Parse and store settings
$this->updateSettingsInternal($settings, false);
// Actually instantiate needed classes like a boss
@ -1056,7 +1056,7 @@ final class MTProto implements TLCallback, LoggerGetter
public function wakeup(SettingsAbstract $settings, APIWrapper $wrapper): void
{
// Setup one-time stuffs
Magic::start();
Magic::start(light: false);
// Set reference to itself
self::$references[\spl_object_hash($this)] = $this;

View File

@ -205,7 +205,7 @@ final class Magic
*
* @param bool $light Use lightweight initialization routine
*/
public static function start(bool $light = false): void
public static function start(bool $light): void
{
if (self::$inited || (self::$initedLight && $light)) {
return;

View File

@ -78,7 +78,7 @@ final class RPCErrorException extends \Exception
}
public function __toString(): string
{
Magic::start(true);
Magic::start(light: true);
$this->localized ??= self::localizeMessage($this->caller, $this->code, $this->message);
$result = \sprintf(Lang::$current_lang['rpc_tg_error'], $this->localized." ({$this->code})", $this->rpc, $this->file, $this->line.PHP_EOL, Magic::$revision.PHP_EOL.PHP_EOL).PHP_EOL.$this->getTLTrace().PHP_EOL;
if (PHP_SAPI !== 'cli' && PHP_SAPI !== 'phpdbg') {

View File

@ -77,7 +77,7 @@ final class AppInfo extends SettingsAbstract
}
public function init(): void
{
Magic::start(true);
Magic::start(light: true);
// Detect language pack
if (isset(Lang::$lang[$this->langCode])) {
Lang::$current_lang =& Lang::$lang[$this->langCode];

View File

@ -219,7 +219,7 @@ final class Connection extends SettingsAbstract
}
public function init(): void
{
Magic::start(true);
Magic::start(light: true);
if (Magic::$altervista) {
$this->addProxy(HttpProxy::class, ['address' => 'localhost', 'port' => 80]);

View File

@ -14,7 +14,7 @@ final class Ipc extends SettingsAbstract
{
public function __construct()
{
Magic::start(true);
Magic::start(light: true);
}
public function mergeArray(array $settings): void

View File

@ -91,7 +91,7 @@ final class Logger extends SettingsAbstract
$this->type = (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg')
? MadelineProtoLogger::ECHO_LOGGER
: MadelineProtoLogger::FILE_LOGGER;
Magic::start(true);
Magic::start(light: true);
$this->extra = Magic::$script_cwd.'/MadelineProto.log';
}
@ -120,7 +120,7 @@ final class Logger extends SettingsAbstract
*/
private function init(): void
{
Magic::start(false);
Magic::start(light: true);
MadelineProtoLogger::constructorFromSettings($this);
}
/**