diff --git a/.travis.yml b/.travis.yml index 2c7bef4..30f5601 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,4 +11,5 @@ matrix: - php: hhvm before_script: + - sh -c 'if [ "$TRAVIS_PHP_VERSION" != "hhvm" ]; then echo "session.serialize_handler = php" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi;' - composer install --dev --prefer-source diff --git a/src/Ratchet/Session/SessionProvider.php b/src/Ratchet/Session/SessionProvider.php index 8aefc96..a8495b2 100644 --- a/src/Ratchet/Session/SessionProvider.php +++ b/src/Ratchet/Session/SessionProvider.php @@ -56,14 +56,7 @@ class SessionProvider implements MessageComponentInterface, WsServerInterface { $this->setOptions($options); if (null === $serializer) { - // Temporarily fixing HHVM issue w/ reading ini values - $handler_name = ini_get('session.serialize_handler'); - if ('' === $handler_name) { - trigger_error('ini value session.seralize_handler was empty, assuming "php" - tmp hack/fix, bad things might happen', E_USER_WARNING); - $handler_name = 'php'; - } - - $serialClass = __NAMESPACE__ . "\\Serialize\\{$this->toClassCase($handler_name)}Handler"; // awesome/terrible hack, eh? + $serialClass = __NAMESPACE__ . "\\Serialize\\{$this->toClassCase(ini_get('session.serialize_handler'))}Handler"; // awesome/terrible hack, eh? if (!class_exists($serialClass)) { throw new \RuntimeException('Unable to parse session serialize handler'); } diff --git a/src/Ratchet/Wamp/TopicManager.php b/src/Ratchet/Wamp/TopicManager.php index bceee73..a69e315 100644 --- a/src/Ratchet/Wamp/TopicManager.php +++ b/src/Ratchet/Wamp/TopicManager.php @@ -77,8 +77,11 @@ class TopicManager implements WsServerInterface, WampServerInterface { public function onClose(ConnectionInterface $conn) { $this->app->onClose($conn); - foreach ($this->topicLookup as $topic) { - $topic->remove($conn); + foreach ($this->topicLookup as $topic => $storage) { + $storage->remove($conn); + if (0 === $storage->count()) { + unset($this->topicLookup[$topic]); + } } } diff --git a/tests/unit/Wamp/TopicManagerTest.php b/tests/unit/Wamp/TopicManagerTest.php index 0c31d9a..7439064 100644 --- a/tests/unit/Wamp/TopicManagerTest.php +++ b/tests/unit/Wamp/TopicManagerTest.php @@ -166,12 +166,19 @@ class TopicManagerTest extends \PHPUnit_Framework_TestCase { $method = $class->getMethod('getTopic'); $method->setAccessible(true); + $attribute = $class->getProperty('topicLookup'); + $attribute->setAccessible(true); + $topic = $method->invokeArgs($this->mngr, array($name)); + $this->assertCount(1, $attribute->getValue($this->mngr)); + $this->mngr->onSubscribe($this->conn, $name); $this->mngr->onClose($this->conn); $this->assertFalse($topic->has($this->conn)); + + $this->assertCount(0, $attribute->getValue($this->mngr)); } public function testOnErrorBubbles() {