php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #58516 PHP Notices
Submitted: 2009-01-25 13:05 UTC Modified: 2017-04-01 21:35 UTC
Votes:6
Avg. Score:3.3 ± 1.4
Reproduced:5 of 5 (100.0%)
Same Version:2 (40.0%)
Same OS:0 (0.0%)
From: markright at gmail dot com Assigned:
Status: Wont fix Package: sam (PECL)
PHP Version: Irrelevant OS: Centos 5
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2009-01-25 13:05 UTC] markright at gmail dot com
Description:
------------
When using SAM to send a message via MQTT a number of notices are thrown.

Notice: Use of undefined constant SAM_PORT - assumed 'SAM_PORT' in /usr/share/pear/SAM/MQTT/sam_mqtt.php on line 102

Notice: Use of undefined constant SAM_PORT - assumed 'SAM_PORT' in /usr/share/pear/SAM/MQTT/sam_mqtt.php on line 105
Notice: Use of undefined constant SAM_HOST - assumed 'SAM_HOST' in /usr/share/pear/SAM/MQTT/sam_mqtt.php on line 107
Notice: Use of undefined constant SAM_HOST - assumed 'SAM_HOST' in /usr/share/pear/SAM/MQTT/sam_mqtt.php on line 110
Notice: Use of undefined constant SAM_WAIT - assumed 'SAM_WAIT' in /usr/share/pear/SAM/MQTT/sam_mqtt.php on line 237
Notice: Undefined index: SAM_WAIT in /usr/share/pear/SAM/MQTT/sam_mqtt.php on line 237

Reproduce code:
---------------
<?php

include_once('/usr/share/php/SAM/php_sam.php');
$conn = new SAMConnection();
$conn->setdebug(TRUE);

$conn->connect(SAM_MQTT, array(SAM_HOST => 'localhost',SAM_PORT => 1883));
$subName = $conn->subscribe('topic://send/test');

if (!$subName) {
   echo "Subscribe failed";
} else {
}

$msg = new SAMMessage('This is a simple text message');
$msg->header->SAM_REPLY_TO = 'topic://receive/test';
$correlid = $conn->send('topic://send/test', $msg);

if (!$correlid) {
  echo "Send failed ($conn->errno) $conn->error";
} else {
  $resp = $conn->receive($subName, array(SAM_CORRELID => $correlid));
}

echo $resp->body;
?>

Expected result:
----------------
This is a simple text message

Actual result:
--------------
Notice: Use of undefined constant SAM_PORT - assumed 'SAM_PORT' in /usr/share/pear/SAM/MQTT/sam_mqtt.php on line 102

Notice: Use of undefined constant SAM_PORT - assumed 'SAM_PORT' in /usr/share/pear/SAM/MQTT/sam_mqtt.php on line 105
Notice: Use of undefined constant SAM_HOST - assumed 'SAM_HOST' in /usr/share/pear/SAM/MQTT/sam_mqtt.php on line 107
Notice: Use of undefined constant SAM_HOST - assumed 'SAM_HOST' in /usr/share/pear/SAM/MQTT/sam_mqtt.php on line 110
Notice: Use of undefined constant SAM_WAIT - assumed 'SAM_WAIT' in /usr/share/pear/SAM/MQTT/sam_mqtt.php on line 237
Notice: Undefined index: SAM_WAIT in /usr/share/pear/SAM/MQTT/sam_mqtt.php on line 237

This is a simple text message

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-01-25 13:35 UTC] markright at gmail dot com
Here is a patch which fixes these notices

Index: sam/MQTT/sam_mqtt.php
===================================================================
RCS file: /repository/pecl/sam/MQTT/sam_mqtt.php,v
retrieving revision 1.1
diff -u -u -r1.1 sam_mqtt.php
--- sam/MQTT/sam_mqtt.php	2 Feb 2007 15:36:46 -0000	1.1
+++ sam/MQTT/sam_mqtt.php	25 Jan 2009 18:32:10 -0000
@@ -99,15 +99,15 @@
     if ($this->debug) e('SAMConnection_MQTT.Connect()');
 
     /* Check our optional parameter array for the necessary bits...   */
-    if ($options[SAM_PORT] == '') {
+    if ($options['SAM_PORT'] == '') {
         $this->port = 1883;
     } else {
-        $this->port = $options[SAM_PORT];
+        $this->port = $options['SAM_PORT'];
     }
-    if ($options[SAM_HOST] == '') {
+    if ($options['SAM_HOST'] == '') {
         $this->host = 'localhost';
     } else {
-        $this->host = $options[SAM_HOST];
+        $this->host = $options['SAM_HOST'];
     }
 
     $this->cleanstart = in_array(SAM_MQTT_CLEANSTART, $options);
@@ -234,10 +234,10 @@
     if ($rc) {
 
         /* have we got a timeout specified?    */
-        if ($options[SAM_WAIT] > 1) {
-            $m = $options[SAM_WAIT] % 1000;
-            $s = ($options[SAM_WAIT] - $m) /1000;
-            if ($this->debug) t('SAMConnection_MQTT.Receive() timeout='.$options[SAM_WAIT]." ($s secs $m millisecs)");
+        if (isset($options['SAM_WAIT']) && $options['SAM_WAIT'] > 1) {
+            $m = $options['SAM_WAIT'] % 1000;
+            $s = ($options['SAM_WAIT'] - $m) /1000;
+            if ($this->debug) t('SAMConnection_MQTT.Receive() timeout='.$options['SAM_WAIT']." ($s secs $m millisecs)");
             stream_set_timeout($this->sock, $s, $m);
             if ($this->debug) t('SAMConnection_MQTT.Receive() timeout set.');
         } else {
 [2017-04-01 21:35 UTC] tpunt@php.net
-Status: Open +Status: Wont fix
 [2017-04-01 21:35 UTC] tpunt@php.net
Due to this extension not seeing any activity since 2007, this issue will not be fixed. We are therefore closing this now.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 15:01:28 2024 UTC