nilovese / xmpphp

Automatically exported from code.google.com/p/xmpphp
0 stars 0 forks source link

errormessage in roster.php for users without resource #91

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. getting presence notice from a user without a resource (no /)
2.
3.

What is the expected output? What do you see instead?

We get a PHP notice for an undefined array element.

What version of the product are you using? On what operating system?

Please provide any additional information below.

Not sure if a blank resource string is desirable, but it fixes the issue.

FIX:

        public function setPresence($presence, $priority, $show, $status) {
                if (strpos($presence,'/')===FALSE) {
                        $jid=$presence;
                        $resource='';
                } else {
                        list($jid, $resource) = split("/", $presence);
                }
                if ($show != 'unavailable') {
                        if (!$this->isContact($jid)) {
                                $this->addContact($jid, 'not-in-roster');
                        }
                        $resource = $resource ? $resource : '';
                        $this->roster_array[$jid]['presence'][$resource] =
array('priority' => $priority, 'show' => $show, 'status' => $status);
                } else { //Nuke unavailable resources to save memory

unset($this->roster_array[$jid]['resource'][$resource]);
                }
        }

Original issue reported on code.google.com by darkf...@gmail.com on 5 May 2010 at 10:41