mirror of
https://github.com/danog/MadelineProto.git
synced 2024-11-27 05:34:42 +01:00
Bugfixes
This commit is contained in:
parent
d8adba8d68
commit
eb3ee22e3f
42
a.php
42
a.php
@ -1,38 +1,12 @@
|
||||
<?php
|
||||
|
||||
$service_port = getservbyname('www', 'tcp');
|
||||
$address = gethostbyname('www.google.com');
|
||||
var_dump(unpack('q', pack('l', 200).chr(0).chr(0).chr(0).chr(0)));
|
||||
require 'vendor/autoload.php';
|
||||
class a extends Volatile
|
||||
{
|
||||
public $a = [];
|
||||
// public $a = [];
|
||||
public function __construct() {
|
||||
$this->a = 'le';
|
||||
}
|
||||
}
|
||||
$a = new a;
|
||||
|
||||
public function run()
|
||||
{
|
||||
$this->a[1] = new b();
|
||||
$this->a[1]->a['a'] = [];
|
||||
var_dump($this);
|
||||
}
|
||||
}
|
||||
class b extends \Volatile
|
||||
{
|
||||
public $a = [];
|
||||
}
|
||||
class main extends Threaded
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->a = new a();
|
||||
var_dump($this->a);
|
||||
$this->a->run();
|
||||
// One of the OH NOES (b) is printed here
|
||||
}
|
||||
|
||||
public function run()
|
||||
{
|
||||
// $this->a;
|
||||
}
|
||||
}
|
||||
$a = new main();
|
||||
$pool = new Pool(1);
|
||||
//$pool->submit($a); // One of the OH NOES (a) is printed here
|
||||
var_dump($a);
|
||||
|
@ -31,23 +31,23 @@ if (!extension_loaded('pthreads')) {
|
||||
|
||||
public function count()
|
||||
{
|
||||
return count($this->data);
|
||||
return count((array)$this);
|
||||
}
|
||||
|
||||
public function getIterator()
|
||||
{
|
||||
return new ArrayIterator($this->data);
|
||||
return new ArrayIterator($this);
|
||||
}
|
||||
|
||||
public function __set($offset, $value)
|
||||
{
|
||||
if ($offset === null) {
|
||||
$offset = count($this->data);
|
||||
$offset = count($this);
|
||||
}
|
||||
|
||||
if (!$this instanceof Volatile) {
|
||||
if (isset($this->data[$offset]) &&
|
||||
$this->data[$offset] instanceof self) {
|
||||
if (isset($this->{$offset}) &&
|
||||
$this->{$offset} instanceof self) {
|
||||
throw new \RuntimeException();
|
||||
}
|
||||
}
|
||||
@ -60,32 +60,32 @@ if (!extension_loaded('pthreads')) {
|
||||
$value = $safety;
|
||||
}
|
||||
|
||||
return $this->data[$offset] = $value;
|
||||
return $this->{$offset} = $value;
|
||||
}
|
||||
|
||||
public function __get($offset)
|
||||
{
|
||||
return $this->data[$offset];
|
||||
return $this->{$offset};
|
||||
}
|
||||
|
||||
public function __isset($offset)
|
||||
{
|
||||
return isset($this->data[$offset]);
|
||||
return isset($this->{$offset});
|
||||
}
|
||||
|
||||
public function __unset($offset)
|
||||
{
|
||||
if (!$this instanceof Volatile) {
|
||||
if (isset($this->data[$offset]) && $this->data[$offset] instanceof self) {
|
||||
if (isset($this->{$offset}) && $this->{$offset} instanceof self) {
|
||||
throw new \RuntimeException();
|
||||
}
|
||||
}
|
||||
unset($this->data[$offset]);
|
||||
unset($this->{$offset});
|
||||
}
|
||||
|
||||
public function shift()
|
||||
{
|
||||
return array_shift($this->data);
|
||||
|
||||
}
|
||||
|
||||
public function chunk($size)
|
||||
@ -100,13 +100,12 @@ if (!extension_loaded('pthreads')) {
|
||||
|
||||
public function pop()
|
||||
{
|
||||
return array_pop($this->data);
|
||||
}
|
||||
|
||||
public function merge($merge)
|
||||
{
|
||||
foreach ($merge as $k => $v) {
|
||||
$this->data[$k] = $v;
|
||||
$this->{$k} = $v;
|
||||
}
|
||||
}
|
||||
|
||||
@ -193,7 +192,6 @@ if (!extension_loaded('pthreads')) {
|
||||
return $value;
|
||||
}
|
||||
|
||||
protected $data;
|
||||
protected $state;
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ if (!extension_loaded('pthreads')) {
|
||||
public function __set($offset, $value)
|
||||
{
|
||||
if ($offset === null) {
|
||||
$offset = count($this->data);
|
||||
$offset = count((array)$this);
|
||||
}
|
||||
|
||||
if (is_array($value)) {
|
||||
@ -17,7 +17,7 @@ if (!extension_loaded('pthreads')) {
|
||||
$value = $safety;
|
||||
}
|
||||
|
||||
return $this->data[$offset] = $value;
|
||||
return $this->{$offset} = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -16,8 +16,8 @@ class Button extends \Volatile implements \JsonSerializable
|
||||
{
|
||||
use \danog\Serializable;
|
||||
private $info = [];
|
||||
|
||||
public function __construct($API, $message, $button)
|
||||
private $data = [];
|
||||
public function ___construct($API, $message, $button)
|
||||
{
|
||||
$this->data = $button;
|
||||
$this->info['peer'] = $message['to_id'];
|
||||
@ -27,20 +27,17 @@ class Button extends \Volatile implements \JsonSerializable
|
||||
|
||||
public function click($donotwait = false)
|
||||
{
|
||||
switch ($this->_) {
|
||||
switch ($this->data['_']) {
|
||||
default: return false;
|
||||
case 'keyboardButtonUrl': return $this->url;
|
||||
case 'keyboardButton': return $this->info['API']->method_call('messages.sendMessage', ['peer' => $this->info['peer'], 'message' => $this->text, 'reply_to_msg_id' => $this->info['id']], ['datacenter' => $this->info['API']->datacenter->curdc]);
|
||||
case 'keyboardButtonCallback': return $this->info['API']->method_call('messages.getBotCallbackAnswer', ['peer' => $this->info['peer'], 'msg_id' => $this->info['id'], 'data' => $this->data], ['noResponse' => $donotwait, 'datacenter' => $this->info['API']->datacenter->curdc]);
|
||||
case 'keyboardButtonUrl': return $this->data['url'];
|
||||
case 'keyboardButton': return $this->info['API']->method_call('messages.sendMessage', ['peer' => $this->info['peer'], 'message' => $this->data['text'], 'reply_to_msg_id' => $this->info['id']], ['datacenter' => $this->info['API']->datacenter->curdc]);
|
||||
case 'keyboardButtonCallback': return $this->info['API']->method_call('messages.getBotCallbackAnswer', ['peer' => $this->info['peer'], 'msg_id' => $this->info['id'], 'data' => $this->data['data']], ['noResponse' => $donotwait, 'datacenter' => $this->info['API']->datacenter->curdc]);
|
||||
case 'keyboardButtonGame': return $this->info['API']->method_call('messages.getBotCallbackAnswer', ['peer' => $this->info['peer'], 'msg_id' => $this->info['id'], 'game' => true], ['noResponse' => $donotwait, 'datacenter' => $this->info['API']->datacenter->curdc]);
|
||||
}
|
||||
}
|
||||
|
||||
public function jsonSerialize()
|
||||
{
|
||||
$res = get_object_vars($this);
|
||||
unset($res['info']);
|
||||
|
||||
return $res;
|
||||
return (array) $this->data;
|
||||
}
|
||||
}
|
||||
|
@ -154,12 +154,14 @@ class Connection extends \Volatile
|
||||
if (isset($t['sock'])) {
|
||||
unset($t['sock']);
|
||||
}
|
||||
if (isset($t['data'])) {
|
||||
unset($t['data']);
|
||||
}
|
||||
|
||||
$keys = array_keys((array) $t);
|
||||
if (count($keys) !== count(array_unique($keys))) {
|
||||
throw new Bug74586Exception();
|
||||
}
|
||||
|
||||
return $keys;
|
||||
}
|
||||
|
||||
|
@ -118,6 +118,9 @@ class MTProto extends \Volatile
|
||||
if (isset($t['readers'])) {
|
||||
unset($t['readers']);
|
||||
}
|
||||
if (isset($t['data'])) {
|
||||
unset($t['data']);
|
||||
}
|
||||
|
||||
$keys = array_keys((array) $t);
|
||||
if (count($keys) !== count(array_unique($keys))) {
|
||||
@ -148,6 +151,10 @@ class MTProto extends \Volatile
|
||||
if (method_exists($elem, 'wakeup')) $this->datacenter->sockets[$key] = $elem->wakeup();
|
||||
}
|
||||
*/
|
||||
if (isset($this->data)) {
|
||||
foreach ($this->data as $k => $v) { $this->{$k} = $v; }
|
||||
unset($this->data);
|
||||
}
|
||||
$this->getting_state = false;
|
||||
$this->reset_session();
|
||||
if (!isset($this->v) || $this->v !== $this->getV()) {
|
||||
|
@ -59,10 +59,14 @@ class Serialization
|
||||
foreach (['RSA', 'TL\TLMethod', 'TL\TLConstructor', 'MTProto', 'API', 'DataCenter', 'Connection'] as $class) {
|
||||
class_exists('\danog\MadelineProto\\'.$class);
|
||||
}
|
||||
class_exists('\Volatile');
|
||||
\danog\MadelineProto\Logger::class_exists();
|
||||
try {
|
||||
$unserialized = \danog\MadelineProto\Logger::$has_thread ? \danog\Serialization::unserialize($unserialized) : unserialize($unserialized);
|
||||
} catch (Bug74586Exception $e) {
|
||||
$unserialized = \danog\Serialization::unserialize($unserialized);
|
||||
} catch (Exception $e) {
|
||||
$unserialized = \danog\Serialization::unserialize($unserialized);
|
||||
}
|
||||
} else {
|
||||
throw new Exception('File does not exist');
|
||||
|
Loading…
Reference in New Issue
Block a user