Bug #222

Upon uninstall, Superfecta leaves inbound routes inaccessible

Added by tshif over 2 years ago. Updated about 1 year ago.

Status:Closed Start:10/29/2009
Priority:Urgent Due date:10/18/2010
Assigned to:jkiel % Done:

100%

Category:-
Target version:Caller ID Superfecta v 2.2.4 Maintenance Release

Description

Upon uninstall, Superfecta leaves inbound routes inaccessible. Calls placed to inbound routes which had Superfecta as their CID source FAIL.

The solution is to re-assert each inbound route to one of the caller ID sources on the drop down list, even the NONE entry.

The inbound route will already appear to be set to NONE for CID source, but in fact stillpoints to the non existant Superfecta, causing the calls to fail.

History

Updated by tshif over 2 years ago

  • Target version set to Caller ID Superfecta - Future Versions

Updated by tshif over 2 years ago

  • Status changed from New to Feedback

The Free PBX CallerID Lookup selection effects the table CIDLOOKUP_INCOMING. The FIeld LOOKUP_ID contains a unique non-repeating number that relates to records in another table, CIDLOOKUP.

Each inbound route is represented by a record in table CIDLOOKUP_INCOMING.

During uninstall, Superfecta removes itself from the cid sources list in table CIDLOOKUP, but does nothing to adjust the pointers in table CIDLOOKUP_INCOMING.

I suggest desired behavior would be that upon uninstall, Superfecta would remove itself from table CIDLOOKUP as it does today.

Then Search for records in table CIDLOOKUP_INCOMING whose field CIDLOOKUP_ID is set for the same valie that was set in table CIDLOOKUP field CIDLOOKUP_ID - and change all such refrences in table CIDLOOKUP field CIDLOOKUP_ID to value of 0 (zero).

This will reset the inbound route to a true NONE source for CID lookup, and prevent the inbound routes from failing after an uninstall.

Updated by tshif over 2 years ago

We need to do something like this - which I tried. It doesnt work.

 1 //get cidlookup_id to change for inbound routes
 2 $sql = "SELECT cidlookup_id FROM cidlookup WHERE cidlookup.description = 'Caller ID Superfecta'";
 3 $lookupidnum = $db->query($sql);
 4 //delete the line from the cidlookup table
 5 $sql = "DELETE FROM cidlookup WHERE description = 'Caller ID Superfecta'";
 6 $res = $db->query($sql);
 7 //set inbound routes that were using Superfecta to NON for lookup source
 8 $sql = "UPDATE cidlookup_incoming SET cidlookup_id = '0' WHERE cidlookup_id = '$lookupidnum' LIMIT 1";
 9 $res=$db->query($sql);

Lines 2 and 3, 8 & 9 are new. This is what we need to do to fix the problem, but as often happens syntax is kicking my a**.

I dont quite understand how this database access code works, but Ill bet my mistake is somewhere in line 3, making line 8 fail.

Updated by tshif over 2 years ago

  • Status changed from Feedback to Reviewed

Updated by tshif over 2 years ago

  • Target version changed from Caller ID Superfecta - Future Versions to Caller ID Superfectav 2.2.3 Maintenance Release

Updated by tshif over 2 years ago

Ok - the result of another set of attempts that also do not work.

 1 // FInd SUperfecta index number in table
 2 $sqlA = "SELECT `cidlookup_id` FROM `cidlookup` WHERE `description` = 'Caller ID Superfecta' LIMIT 1";
 3 $lookupidnum = $db->query($sqlA);
 4 //delete the line from the cidlookup table
 5 $sql = "DELETE FROM cidlookup WHERE description = 'Caller ID Superfecta'";
 6 $res = $db->query($sql);
 7 //set inbound routes that were using Superfecta to NON for lookup source
 8 $sql = "UPDATE cidlookup_incoming SET cidlookup_id = '0' WHERE cidlookup_id = '".$lookupidnum."'";
 9 $res=$db->query($sql);

Updated by tshif about 2 years ago

  • Target version changed from Caller ID Superfectav 2.2.3 Maintenance Release to Caller ID Superfecta - Future Versions

Updated by patrick_elx about 2 years ago

I'm just thinking out loud there.
But instead of removing the cid source from the FreePBX database by an SQL request, couldn't we call directly the FreePBX delete cid source function (in the cid lookup page/module) that should have already the proper behavior to reallocate to a proper path.

Updated by bsau about 2 years ago

That also would work. Is one way better than the other?
With direct sql, we have exact control over actions. If FreePBX table usage changes, then we have troubles.

With calling directly the FreePBX delete cid source function, we get the built in proper behavior. If FreePBX changes its usage of or name of this function, then we have troubles.

Thinking out loud also - which way is best?

Updated by bsau about 2 years ago

I would really like to see this addressed for the next release. Its really bad form to leave the PBX unusable (not passing calls) after we uninstall.

In order to address some of the tickets that have been worked on in the last week or so, we are looking at needing to release 2.2.4 (core module changes). Being a terrible php coder, it could take me months to get this right.

Anyone willing to step up and correct it as per the notes in this case?

Updated by tshif over 1 year ago

patrick_elx wrote:

I'm just thinking out loud there. But instead of removing the cid source from the FreePBX database by an SQL request, couldn't we call directly the FreePBX delete cid source function (in the cid lookup page/module) that should have already the proper behavior to reallocate to a proper path.

Yes - I think this could be the best way to do it - but well have to watch for changes to the FreePBX delete source function in future versions.

Patrick, are you able to write the code to call that function?

Updated by tshif over 1 year ago

  • Status changed from Reviewed to Feedback

Coders Wanted. This is a bad bug - who will step up and work it?

Updated by tshif over 1 year ago

  • Priority changed from High to Urgent
  • Target version changed from Caller ID Superfecta - Future Versions to Caller ID Superfecta v 2.2.4 Maintenance Release

Updated by tshif over 1 year ago

  • Due date set to 10/15/2010

Updated by jkiel about 1 year ago

Should the 'Caller ID Superfecta' cidlookup_incoming records be deleted or updated when Caller ID Superfecta uninstalled?

If deleted, use:

//delete incoming lookups
$sql = "delete c1 from cidlookup_incoming c1, cidlookup c2 where c1.cidlookup_id = c2.cidlookup_id and  c2.description = 'Caller ID Superfecta'";
$res = $db->query($sql);
//delete the line from the cidlookup table
$sql = "DELETE FROM cidlookup WHERE description = 'Caller ID Superfecta'";
$res = $db->query($sql);

If update:

//delete incoming lookups
$sql = "update cidlookup_incoming c1, cidlookup c2 set c1.cidlookup_id = 0 where c1.cidlookup_id = c2.cidlookup_id and  c2.description = 'Caller ID Superfecta'";
$res = $db->query($sql);
//delete the line from the cidlookup table
$sql = "DELETE FROM cidlookup WHERE description = 'Caller ID Superfecta'";
$res = $db->query($sql);

Note the importance of deleting/updating cidlookup_incoming before cidlookup.

--John

Updated by tshif about 1 year ago

John - I'm reviewing your notes and question - I'll provide some feedback asap. Thank you for looking at this ticket.

Updated by jkiel about 1 year ago

Assuming cidlookup_incoming records should be deleted (waiting on your confirmation), the following will clean up any mess left behind by a previously bad uninstall:

//delete stray cidlookup_incoming records left by bad uninstall
$sql = "delete c1 from cidlookup_incoming c1 left outer join cidlookup c2 on c1.cidlookup_id = c2.cidlookup_id where c2.cidlookup_id is null";
$res = $db->query($sql);

Updated by jkiel about 1 year ago

  • Status changed from Feedback to Closed

Should be fixed with rev. 280.

Updated by tshif about 1 year ago

  • Due date changed from 10/15/2010 to 10/18/2010
  • Status changed from Closed to QA Testing
  • Assigned to set to tshif

Updated by tshif about 1 year ago

  • Status changed from QA Testing to Closed
  • % Done changed from 0 to 80

QS: Pass Install / Uninstall works, and no longer leaves inbound routes inaccessible.

Tested on FreePBX 2.6 /2.7 / 2.8

Ticket awaiting feedback from other testers.

Updated by tshif about 1 year ago

  • Status changed from Closed to Feedback

Updated by tshif about 1 year ago

  • Status changed from Feedback to QA Testing
  • % Done changed from 80 to 90

QS: Passed against FreePBX 2.6 / 2.7 /2.8

Updated by jkiel about 1 year ago

Currently, on uninstall, Superfecta will try to clean-up left-overs from a previously bad uninstall using "delete c1 from cidlookup_incoming c1 left outer join cidlookup c2 on c1.cidlookup_id = c2.cidlookup_id where c2.cidlookup_id is null", removing any orphaned cidlookup bindings.

My thought is that perhaps this should also be placed in the Superfecta installer -- just to make sure it is installing into a clean environment.

Updated by tshif about 1 year ago

This is an interesting idea. I'm wondering if the current situation has any negatives associated with it? Is there any known issue when NOT doing this has caused problems or unexpected results? What sort of problems do you perceive might occur under perfect (bad) conditions?

Updated by jkiel about 1 year ago

The problem I could see if the clean-up code was not added to the 2.2.4 installer is:

1) Superfecta v2.2.3 (or less) is installed.
2) Superfecta v2.2.3 (or less) is configured for use on some incoming routes.
3) Superfecta v2.2.3 (or less) is uninstalled, leaving orphaned cidlookup routes.
4) Superfecta v2.2.4 is installed.
5) Ugly bits (orphaned cidlookup routes) are left behind by 2.2.3 that wont be cleaned up until 2.2.4 is uninstalled.

Updated by tshif about 1 year ago

Hmm. Yes, that sounds undesireable allright.

Is there any down side to running the clean up upon install in all cases? From my understanding, this cleanup doesnt impact any of the modules configured settings other than the lookup source.

Do you propose running the cleanup upon install in all cases? Or just upon "fresh" installs?

Updated by tshif about 1 year ago

  • Status changed from QA Testing to Feedback
  • Assigned to changed from tshif to jkiel
  • Priority changed from Urgent to High

Updated by tshif about 1 year ago

  • Priority changed from High to Urgent

John - do you have any thoughts on this?

Updated by jkiel about 1 year ago

I don't see any real downside. If the cidlookup database changes enough to the point where the statement fails, it's going to break superfecta anyway -- better that it crashes on install.

I'll add it. It will run on clean and upgrade install.

Updated by jkiel about 1 year ago

O.K., added it to install.php. see r326

Updated by tshif about 1 year ago

These changes are available for test in 2.2.4 BETA1

If Fresh, and upgrade install exihibit no weirdness, we should be able to close this ticket.

Very exciting - this has been a serious bug for us - Thanks for stepping up John. You are making a big difference to the project.

Updated by tshif about 1 year ago

  • Status changed from Feedback to Resolved

Updated by tshif about 1 year ago

  • Status changed from Resolved to Closed
  • % Done changed from 90 to 100

QS: Pass. Performs as expected with no detected undesirable results. Accepted for build 2.2.4

Also available in: Atom PDF