From 21801b09af6da5d14c949cc0b6ce1c260330c30d Mon Sep 17 00:00:00 2001 From: Bob Weinand Date: Thu, 30 Mar 2017 19:06:11 +0200 Subject: [PATCH] Fix $restore callback calls --- lib/Connection.php | 4 ++-- lib/Processor.php | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/Connection.php b/lib/Connection.php index 651004d..2e919d2 100644 --- a/lib/Connection.php +++ b/lib/Connection.php @@ -37,10 +37,10 @@ public function __construct($config, $sslOptions = null) { $cb($hash); } }; - $restore = static function() use ($hash, $config) { + $restore = static function($init) use ($hash, $config) { $cb = $config->restore; if (isset($cb)) { - $cb($hash); + $cb($hash, $init); } }; $this->processor = new Processor($ready, $busy, $restore); diff --git a/lib/Processor.php b/lib/Processor.php index 4740c0e..edb6b0a 100644 --- a/lib/Processor.php +++ b/lib/Processor.php @@ -423,7 +423,7 @@ private function parseOk($packet) { if ($this->capabilities & self::CLIENT_SESSION_TRACK) { // Even though it seems required according to 14.1.3.1, there is no length encoded string, i.e. no trailing NULL byte ....??? - if (\strlen($packet) > 7) { + if (\strlen($packet) > $off) { $this->connInfo->statusInfo = DataTypes::decodeStringOff($packet, $off); if ($this->connInfo->statusFlags & StatusFlags::SERVER_SESSION_STATE_CHANGED) { @@ -948,8 +948,8 @@ private function goneAway() { } } $this->closeSocket(); - if (null !== $cb = $this->config->restore) { - $cb(spl_object_hash($this), $this->connectionState < self::READY); + if (null !== $cb = $this->restore) { + $cb($this->connectionState < self::READY); /* @TODO if packet not completely sent, resend? */ } }