1
0
mirror of https://github.com/danog/MadelineProto.git synced 2024-11-30 04:39:50 +01:00

Fix update checks on composer

This commit is contained in:
Daniil Gentili 2023-07-25 16:12:42 +02:00
parent 0114106b77
commit 26713b1349
Signed by: danog
GPG Key ID: 8C1BE3B34B230CA7
7 changed files with 15 additions and 33 deletions

View File

@ -72,10 +72,10 @@ final class GarbageCollector
$cb = function () use ($client, $request, &$id): void {
try {
$latest = $client->request($request);
Magic::$version_latest = \trim($latest->getBody()->buffer());
if (Magic::$version !== Magic::$version_latest) {
$old = Magic::$version;
$new = Magic::$version_latest;
Magic::$latest_release = \trim($latest->getBody()->buffer());
if (API::RELEASE !== Magic::$latest_release) {
$old = API::RELEASE;
$new = Magic::$latest_release;
Logger::log("!!!!!!!!!!!!! An update of MadelineProto is required (old=$old, new=$new)! !!!!!!!!!!!!!", Logger::FATAL_ERROR);
$contents = $client->request(new Request("https://phar.madelineproto.xyz/phar.php?v=new".\rand(0, PHP_INT_MAX)))
@ -105,7 +105,7 @@ final class GarbageCollector
foreach (\glob(MADELINE_PHAR_GLOB) as $path) {
$base = \basename($path);
if ($base === 'madeline-'.Magic::$version.'.phar') {
if ($base === 'madeline-'.API::RELEASE.'.phar') {
continue;
}
$f = \fopen("$path.lock", 'c');

View File

@ -1657,7 +1657,7 @@ final class MTProto implements TLCallback, LoggerGetter
{
Magic::start(light: false);
$warning = '';
if (Magic::$version !== Magic::$version_latest) {
if (API::RELEASE !== Magic::$latest_release) {
$warning .= "<h2 style='color:red;'>".\htmlentities(Lang::$current_lang['update_madelineproto']).'</h2>';
}
if (!Magic::$hasOpenssl) {

View File

@ -156,16 +156,11 @@ final class Magic
*
*/
public static string $revision;
/**
* MadelineProto version (clean).
*
*/
public static ?string $version;
/**
* Latest MadelineProto version.
*
*/
public static ?string $version_latest;
public static ?string $latest_release;
/**
* Our CWD.
*
@ -286,18 +281,7 @@ final class Magic
self::$altervista = isset($_SERVER['SERVER_ADMIN']) && \strpos($_SERVER['SERVER_ADMIN'], 'altervista.org');
self::$zerowebhost = isset($_SERVER['SERVER_ADMIN']) && \strpos($_SERVER['SERVER_ADMIN'], '000webhost.io');
self::$can_getmypid = !self::$altervista && !self::$zerowebhost;
self::$version = null;
if (\file_exists(__DIR__.'/../.git/refs/heads/v8')) {
try {
self::$version = \trim(@\file_get_contents(__DIR__.'/../.git/refs/heads/v8'));
if (self::$version && !\str_ends_with(self::$version, '-81')) {
// Running from within repo
self::$version_latest = self::$version;
}
} catch (Throwable $e) {
}
}
self::$revision = 'Revision: '.self::$version;
self::$revision = 'Revision: '.API::RELEASE;
self::$initedLight = true;
if ($light) {
return;
@ -332,14 +316,14 @@ final class Magic
self::$twoe1984 = new BigInteger('010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000', 16);
self::$twoe2047 = new BigInteger('80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000', 16);
self::$twoe2048 = new BigInteger('0100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000', 16);
if (self::$version && !isset(self::$version_latest)) {
self::$version_latest = null;
if (!isset(self::$latest_release)) {
self::$latest_release = null;
try {
$php = (string) \min(81, (int) (PHP_MAJOR_VERSION.PHP_MINOR_VERSION));
self::$version_latest = \trim(@\file_get_contents("https://phar.madelineproto.xyz/release$php"));
self::$latest_release = \trim(@\file_get_contents("https://phar.madelineproto.xyz/release$php"));
} catch (Throwable $e) {
}
if (self::$version_latest !== self::$version) {
if (self::$latest_release !== API::RELEASE) {
self::$revision .= ' (AN UPDATE IS REQUIRED)';
}
}

View File

@ -206,7 +206,7 @@ abstract class Serialization
Logger::log("Session has event handler, but it's not started.", Logger::ERROR);
Logger::log("We don't have access to the event handler class, so we can't start it.", Logger::ERROR);
Logger::log('Please start the event handler or unset it to use the IPC server.', Logger::ERROR);
throw new AssertionError("Please make sure the $class class is in scope.");
throw new AssertionError("Please make sure the $class class is in scope, or that the event handler is running (in a separate process).");
} elseif ($class && \is_subclass_of($class, EventHandler::class)) {
EventHandler::cachePlugins($class);
}

View File

@ -74,7 +74,7 @@ final class AppInfo extends SettingsAbstract
$this->setLangCode(\explode('_', $_SERVER['LANG'])[0]);
}
$this->init();
$this->appVersion = \danog\MadelineProto\API::RELEASE.' ('.MTProto::V.', '.Magic::$version.')';
$this->appVersion = \danog\MadelineProto\API::RELEASE;
}
public function __wakeup(): void
{

View File

@ -203,7 +203,7 @@ if [ "$PLATFORM" == "linux/arm64" ]; then :; else exit 0; fi
cp "$input/madeline$php$branch.phar" "madeline81.phar"
git remote add hub https://github.com/danog/MadelineProto
echo -n "$COMMIT-81" > release
echo -n "$TAG" > release
cp tools/phar.php madeline.php
gh release upload "$TAG" "madeline81.phar"

View File

@ -20,8 +20,6 @@ if (!isset($argv[3])) {
$p = new Phar(__DIR__.'/../'.$argv[2], 0, $argv[2]);
$p->buildFromDirectory(realpath($argv[1]), '/^((?!tests).)*(\.php|\.py|\.exe|\.tl|\.json|\.dat|\.h)$/i');
$p->addFromString('vendor/danog/madelineproto/.git/refs/heads/v8', $argv[3]);
$p->addFromString('.git/refs/heads/v8', $argv[3]);
$p->setStub('<?php