Bugfixes
This commit is contained in:
parent
d8adba8d68
commit
eb3ee22e3f
42
a.php
42
a.php
@ -1,38 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
require 'vendor/autoload.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)));
|
|
||||||
class a extends Volatile
|
class a extends Volatile
|
||||||
{
|
{
|
||||||
public $a = [];
|
// public $a = [];
|
||||||
|
public function __construct() {
|
||||||
|
$this->a = 'le';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$a = new a;
|
||||||
|
|
||||||
public function run()
|
var_dump($a);
|
||||||
{
|
|
||||||
$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
|
|
||||||
|
@ -31,23 +31,23 @@ if (!extension_loaded('pthreads')) {
|
|||||||
|
|
||||||
public function count()
|
public function count()
|
||||||
{
|
{
|
||||||
return count($this->data);
|
return count((array)$this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getIterator()
|
public function getIterator()
|
||||||
{
|
{
|
||||||
return new ArrayIterator($this->data);
|
return new ArrayIterator($this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function __set($offset, $value)
|
public function __set($offset, $value)
|
||||||
{
|
{
|
||||||
if ($offset === null) {
|
if ($offset === null) {
|
||||||
$offset = count($this->data);
|
$offset = count($this);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$this instanceof Volatile) {
|
if (!$this instanceof Volatile) {
|
||||||
if (isset($this->data[$offset]) &&
|
if (isset($this->{$offset}) &&
|
||||||
$this->data[$offset] instanceof self) {
|
$this->{$offset} instanceof self) {
|
||||||
throw new \RuntimeException();
|
throw new \RuntimeException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -60,32 +60,32 @@ if (!extension_loaded('pthreads')) {
|
|||||||
$value = $safety;
|
$value = $safety;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->data[$offset] = $value;
|
return $this->{$offset} = $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function __get($offset)
|
public function __get($offset)
|
||||||
{
|
{
|
||||||
return $this->data[$offset];
|
return $this->{$offset};
|
||||||
}
|
}
|
||||||
|
|
||||||
public function __isset($offset)
|
public function __isset($offset)
|
||||||
{
|
{
|
||||||
return isset($this->data[$offset]);
|
return isset($this->{$offset});
|
||||||
}
|
}
|
||||||
|
|
||||||
public function __unset($offset)
|
public function __unset($offset)
|
||||||
{
|
{
|
||||||
if (!$this instanceof Volatile) {
|
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();
|
throw new \RuntimeException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
unset($this->data[$offset]);
|
unset($this->{$offset});
|
||||||
}
|
}
|
||||||
|
|
||||||
public function shift()
|
public function shift()
|
||||||
{
|
{
|
||||||
return array_shift($this->data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function chunk($size)
|
public function chunk($size)
|
||||||
@ -100,13 +100,12 @@ if (!extension_loaded('pthreads')) {
|
|||||||
|
|
||||||
public function pop()
|
public function pop()
|
||||||
{
|
{
|
||||||
return array_pop($this->data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function merge($merge)
|
public function merge($merge)
|
||||||
{
|
{
|
||||||
foreach ($merge as $k => $v) {
|
foreach ($merge as $k => $v) {
|
||||||
$this->data[$k] = $v;
|
$this->{$k} = $v;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -193,7 +192,6 @@ if (!extension_loaded('pthreads')) {
|
|||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected $data;
|
|
||||||
protected $state;
|
protected $state;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@ if (!extension_loaded('pthreads')) {
|
|||||||
public function __set($offset, $value)
|
public function __set($offset, $value)
|
||||||
{
|
{
|
||||||
if ($offset === null) {
|
if ($offset === null) {
|
||||||
$offset = count($this->data);
|
$offset = count((array)$this);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_array($value)) {
|
if (is_array($value)) {
|
||||||
@ -17,7 +17,7 @@ if (!extension_loaded('pthreads')) {
|
|||||||
$value = $safety;
|
$value = $safety;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->data[$offset] = $value;
|
return $this->{$offset} = $value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,8 +16,8 @@ class Button extends \Volatile implements \JsonSerializable
|
|||||||
{
|
{
|
||||||
use \danog\Serializable;
|
use \danog\Serializable;
|
||||||
private $info = [];
|
private $info = [];
|
||||||
|
private $data = [];
|
||||||
public function __construct($API, $message, $button)
|
public function ___construct($API, $message, $button)
|
||||||
{
|
{
|
||||||
$this->data = $button;
|
$this->data = $button;
|
||||||
$this->info['peer'] = $message['to_id'];
|
$this->info['peer'] = $message['to_id'];
|
||||||
@ -27,20 +27,17 @@ class Button extends \Volatile implements \JsonSerializable
|
|||||||
|
|
||||||
public function click($donotwait = false)
|
public function click($donotwait = false)
|
||||||
{
|
{
|
||||||
switch ($this->_) {
|
switch ($this->data['_']) {
|
||||||
default: return false;
|
default: return false;
|
||||||
case 'keyboardButtonUrl': return $this->url;
|
case 'keyboardButtonUrl': return $this->data['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 '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], ['noResponse' => $donotwait, '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]);
|
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()
|
public function jsonSerialize()
|
||||||
{
|
{
|
||||||
$res = get_object_vars($this);
|
return (array) $this->data;
|
||||||
unset($res['info']);
|
|
||||||
|
|
||||||
return $res;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -154,12 +154,14 @@ class Connection extends \Volatile
|
|||||||
if (isset($t['sock'])) {
|
if (isset($t['sock'])) {
|
||||||
unset($t['sock']);
|
unset($t['sock']);
|
||||||
}
|
}
|
||||||
|
if (isset($t['data'])) {
|
||||||
|
unset($t['data']);
|
||||||
|
}
|
||||||
|
|
||||||
$keys = array_keys((array) $t);
|
$keys = array_keys((array) $t);
|
||||||
if (count($keys) !== count(array_unique($keys))) {
|
if (count($keys) !== count(array_unique($keys))) {
|
||||||
throw new Bug74586Exception();
|
throw new Bug74586Exception();
|
||||||
}
|
}
|
||||||
|
|
||||||
return $keys;
|
return $keys;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -118,6 +118,9 @@ class MTProto extends \Volatile
|
|||||||
if (isset($t['readers'])) {
|
if (isset($t['readers'])) {
|
||||||
unset($t['readers']);
|
unset($t['readers']);
|
||||||
}
|
}
|
||||||
|
if (isset($t['data'])) {
|
||||||
|
unset($t['data']);
|
||||||
|
}
|
||||||
|
|
||||||
$keys = array_keys((array) $t);
|
$keys = array_keys((array) $t);
|
||||||
if (count($keys) !== count(array_unique($keys))) {
|
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 (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->getting_state = false;
|
||||||
$this->reset_session();
|
$this->reset_session();
|
||||||
if (!isset($this->v) || $this->v !== $this->getV()) {
|
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) {
|
foreach (['RSA', 'TL\TLMethod', 'TL\TLConstructor', 'MTProto', 'API', 'DataCenter', 'Connection'] as $class) {
|
||||||
class_exists('\danog\MadelineProto\\'.$class);
|
class_exists('\danog\MadelineProto\\'.$class);
|
||||||
}
|
}
|
||||||
|
class_exists('\Volatile');
|
||||||
|
\danog\MadelineProto\Logger::class_exists();
|
||||||
try {
|
try {
|
||||||
$unserialized = \danog\MadelineProto\Logger::$has_thread ? \danog\Serialization::unserialize($unserialized) : unserialize($unserialized);
|
$unserialized = \danog\MadelineProto\Logger::$has_thread ? \danog\Serialization::unserialize($unserialized) : unserialize($unserialized);
|
||||||
} catch (Bug74586Exception $e) {
|
} catch (Bug74586Exception $e) {
|
||||||
$unserialized = \danog\Serialization::unserialize($unserialized);
|
$unserialized = \danog\Serialization::unserialize($unserialized);
|
||||||
|
} catch (Exception $e) {
|
||||||
|
$unserialized = \danog\Serialization::unserialize($unserialized);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new Exception('File does not exist');
|
throw new Exception('File does not exist');
|
||||||
|
Loading…
Reference in New Issue
Block a user