danog / MadelineProto

Async PHP client API for the telegram MTProto protocol
https://docs.madelineproto.xyz
GNU Affero General Public License v3.0
2.8k stars 636 forks source link

FileCallback readonly property #1372

Closed MDKPredator closed 1 year ago

MDKPredator commented 1 year ago

Hi,

I have a piece of code that was working until yesterday:

$MadelineProto->messages->sendMedia([
    'peer' => $destination_chat,
    'media' => [
        '_' => 'inputMediaUploadedDocument',
        'file' => new \danog\MadelineProto\FileCallback(
            $filepath,
            function ($progress, $speed, $time) use ($MadelineProto, $origin_chat) {
                try {
                    echo "$progress%\r\n";
                } catch (\Throwable $e) {}
            }
        ),
        'attributes' => [
            $attributes
        ]
    ],
    'message' => $caption,
    'parse_mode' => 'Markdown'
]);

The error is:

Exception:              Error: Cannot modify readonly property danog\MadelineProto\FileCallback::$file in phar:///madeline-6cc71a5c8efd72b591df775bdc667b64ae5670ab-81.phar/vendor/danog/madelineproto/src/FileCallback.php:42
Stack trace:
#0 /send_document.php(30): danog\MadelineProto\FileCallback->__construct()
#1 {main}

Line 30 corresponds to 'file' => new \danogameMadelineProtoFileCallback(

PHP version is 8.2:

PHP 8.2.7 (cli) (built: Jun  9 2023 07:38:59) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.2.7, Copyright (c) Zend Technologies
    with Zend OPcache v8.2.7, Copyright (c), by Zend Technologies

Should I change anything in my script to make it work again?

Thanks

danog commented 1 year ago

Will be fixed in beta101!