Ticket #5863 (closed Bugs: fixed)

Opened 1 year ago

Last modified 11 months ago

BUG on adhoc device when submit change in device

Reported by: bmerindol Assigned to: p_lindheimer
Priority: minor Milestone: 2.11
Component: Core Version: 2.10-branch
Keywords: adhoc Cc:
Confirmation: Need testing Distro:
Backend Engine: All Distro Ver:
Backend Ver: SVN Revision (if applicable):

Description (Last modified by p_lindheimer)

Hi,

It have bug in core function on change adhoc device. This BUG is present from 2.5 to 2.10 (I dont'have FREEPBX before 2.5 but I think this bug is present to).

You create adhoc device with defaut user .

You log an other user (not default) on this device with *11.

You go on device definition and you chane (example) the description of this device and you submit.

After this submit you see AMPUSER/<logged in user>/device ins ASTDB and this entry is deleted. But the entry of AMPUSER/<default user>/device is populated with device id.

The bug is in functions.inc.php in core the patch for core version 2.10.0.8 (but same patch for old freepbx version) Best regards Bernard


--- functions.inc.php.orig	2012-06-01 12:34:38.000000000 +0200
+++ functions.inc.php.new	2012-06-01 15:20:06.000000000 +0200
@@ -4423,16 +4423,19 @@
 			$astman->database_del("DEVICE",$id."/emergency_cid");
     }
 
-		if ($user != "none") {
-			$existingdevices = $astman->database_get("AMPUSER",$user."/device");
+        // TNE-BME 2012/06/01 Problem with adhoc phone loggedin on users before this change
+        // If not test on defaut user but on DEVICE/$id/user
+        $connecteduser=$astman->database_get("DEVICE",$id."/user");
+		if ($connecteduser != "none") {
+			$existingdevices = $astman->database_get("AMPUSER",$connecteduser."/device");
 			if (empty($existingdevices)) {
-				$astman->database_put("AMPUSER",$user."/device",$id);
+				$astman->database_put("AMPUSER",$connecteduser."/device",$id);
 			} else {
 				$existingdevices_array = explode('&',$existingdevices);
 				if (!in_array($id, $existingdevices_array)) {
 					$existingdevices_array[]=$id;
 					$existingdevices = implode('&',$existingdevices_array);
-					$astman->database_put("AMPUSER",$user."/device",$existingdevices);
+					$astman->database_put("AMPUSER",$connecteduser."/device",$existingdevices);
 				}
 			}
 		}

Attachments

functions.inc.php-adhoc.patch (1.2 kB) - added by p_lindheimer on 06/01/12 09:47:16.
patch file with proper type so it formats correctly

Change History

06/01/12 09:43:52 changed by p_lindheimer

  • description changed.

thanks for the patch will have a look.

06/01/12 09:47:16 changed by p_lindheimer

  • attachment functions.inc.php-adhoc.patch added.

patch file with proper type so it formats correctly

06/01/12 11:28:30 changed by p_lindheimer

  • confirmation changed from Unreviewed to Need testing.

Reviewing this I see the flaw in the logic but the fix you provide does not seem correct. (for one $connecteduser will never be 'none').

Can you try the following patch:

Index: functions.inc.php
===================================================================
--- functions.inc.php	(revision 14121)
+++ functions.inc.php	(working copy)
@@ -4423,7 +4423,8 @@
 			$astman->database_del("DEVICE",$id."/emergency_cid");
     }
 
-		if ($user != "none") {
+		$apparent_connecteduser = ($editmode && $user != "none") ? $astman->database_get("DEVICE",$id."/user") : $user;
+		if ($user != "none" && $apparent_connecteduser == $user)  {
 			$existingdevices = $astman->database_get("AMPUSER",$user."/device");
 			if (empty($existingdevices)) {
 				$astman->database_put("AMPUSER",$user."/device",$id);

The logic here is that the apparent_connecteduser will ultimately determine if there is someone other than the default user logged into that device already. Then, assuming there is suppose to be a default user ($user != none) and the current user is NOT someone else, then we make sure they get logged into the device which is what the rest of the logic does there.

06/11/12 15:25:18 changed by bmerindol

Hi

I not undestand this in your ticket " (for one $connecteduser will never be 'none')" But if the default users on device is none and you Logout on this device you get: /DEVICE/2000/default_user : none /DEVICE/2000/dial : SIP/2000 /DEVICE/2000/type : adhoc /DEVICE/2000/user : none

In this case connecteduser=$astman->database_get("DEVICE",$id."/user") get none.

Best regards Bernard

06/29/12 15:29:00 changed by p_lindheimer

  • status changed from new to closed.
  • resolution set to fixed.

(In [14168]) fixes #5863 need to be more discerning as to the connecteduser, please test and confirm or open a new ticket if this creates issues or doesn't fix all the issues