Skip to content
This repository has been archived by the owner on Nov 21, 2024. It is now read-only.

Commit

Permalink
throw an exception when server doesn't give us list of mechanisms (ot…
Browse files Browse the repository at this point in the history
…herwise we get a fatal error)
  • Loading branch information
priyadi committed Oct 21, 2013
1 parent 597cada commit 21abba8
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/XmppPrebind.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,12 @@ public function connect($username, $password) {
$this->sid = $body->getAttribute('sid');
$this->debug($this->sid, 'sid');

$mechanisms = $body->firstChild->firstChild->getElementsByTagName('mechanism');
$child = $body->firstChild->firstChild;
if (is_object($child)) {
$mechanisms = $child->getElementsByTagName('mechanism');
} else {
throw new Exception('Invalid response');
}

foreach ($mechanisms as $value) {
$this->mechanisms[] = $value->nodeValue;
Expand Down Expand Up @@ -617,4 +622,4 @@ protected function getAndIncrementRid() {
*/
class XmppPrebindException extends Exception{}

class XmppPrebindConnectionException extends XmppPrebindException {}
class XmppPrebindConnectionException extends XmppPrebindException {}

0 comments on commit 21abba8

Please sign in to comment.