Step-through debug of a clean unconfigured site running from git:-
Unconfigured server (tropo/twillio) configuration form, calls VoipVoice::getDefaultVoice()->getVoiceId().
In getDefaultVoice() there is no variable_get('voipcall_voice_id', ''); set. So $voipvoice_voice = self::getVoice($voice_id); get's called with an empty arg. So getVoice gets called and
83 else if (empty($voice_id)) {
84 $voice_id = variable_get('voipcall_voice_id', ''); # no variable set $voice_id = ''
85 }
87 $voipvoices = self::getVoices()
/**
Array
(
[voip_log] => Array
(
[language] => en
[voice] => man
[description] => Log - VoIP Drupal Log voice
)
)
**/
88 $voipvoice = $voipvoices[$voice_id]; # not set
89 if (empty($voipvoice)) { #empty
90 //If wrong voice_id
91 watchdog('voipcall', 'VoipVoice::getVoice called with non-existing id: '. $voice_id, NULL, WATCHDOG_ERROR);
92 //Load default voice instead
93 $voipvoice = self::getDefaultVoice(); # hence calls getDefaultVoice() again and we loop.
94 }
Seems to be an issue for configurations as above since beta7.
Will just a set of defaults in the variables solve it as desired?
Comments
Comment #1
tamerzg commentedvariable_get('voipcall_voice_id', '');was unintentionally left empty it should of been:
variable_get('voipcall_voice_id', 'log');We just fixed it in latest dev.
Comment #2
ekes commentedVoipTropo doesn't return [log] as a key to the hook_getvoices() (by the way shouldn't that be in namespace?); so running 6.x-1.x from git at the moment I'm still getting the loop. May the servers could offer up a [voipdrupal_default] or something to make it easier?
Comment #3
tamerzg commentedYou will need to reinstall the voipcall module and clear the caches in order for variable 'voipcall_voice_id' to get deleted, as with previous version it might get stuck with empty value so that would cause the loop again.
It doesn't matter if Tropo or any other server doesn't return log as a key, because in first install value of voipcall_voice_id variable is not set so it will get it from default value provided in variable_get() function.
Comment #4
ekes commentedYes if I have no
voipcall_voice_idvariable set then now 'log' is used as the default. This happens when you first set the Server to Tropo. Butvoiptropo_getvoicesgets called and doesn't return anything keyed as 'log'. Hence the loop.Comment #5
ben.bunk commentedI'm also experiencing this. If you set Tropo as the default server before configuring it you'll still get the error. It might not make a lot of sense to enable the server before it's configured but I do it myself and I think many others will do it as well.
It looks like if the log server is going to be the default voice for all servers then it's hook_getvoices() needs to be modified to always return a voice - this is what I came up with:
Alternatively, you could also disable the radio buttons for all servers except the log server so that the user can still click on the configure link but they can't enable the server yet -
Comment #6
leoburd commented- Added benbunk fix to voip_getvoices().
That seems to work for me. Does that solve the problem for everyone else?
Comment #7
barrett commentedThe solution in #5 appears to have worked for me as well.
Comment #8
srevilak commentedI'd like to submit a patch that works around the infinite loop.
The patch takes the first element from getVoices(), and uses that for the default voice_id.
Comment #9
freescholar commentedThe patch in post #8 works for me!
Thanks srevilak!
Comment #10
leoburd commentedHi guys,
If the goal is to provide a fallback default value for getDefaultVoice(), I don't see what the proposed patch adds to what we already had in #6. Would anyone clarify that for me?
Thanks,
.L.
Comment #11
freescholar commentedOne benefit I see is that the patch uses the first voice listed in the script as the default. This removes the confusion around the voice named 'log' - as a newbie php programmer, it was not initially evident that 'log' was a voice name.
Is there a significance to the user named 'log'? Does it need to be set as the default voice for some reason?
I didn't try the solution of blocking the radio buttons, because it removes a bit of flexibility on the admin's part.
Comment #12
ben.bunk commentedThe patch in #8 fails on a clean install.
The reason #8 fails is because on a clean install there aren't any default voices to choose from in the list. For patch #8 to work correctly it would need to make significant assumptions about the voice configurations and requires changes to all of the voip provider modules. The patch in #5 assumes the log server is the default which has no voice and eliminates a lot of code changes.
Comment #13
freescholar commentedThanks for the clarity - I will try the patch in #5 again and let you know how it goes!
I am new to "patching" and may have applied it incorrectly on first attempt.
Comment #14
leoburd commentedHello all,
Would you mind testing the new dev version? The issue reported above prompted us to significantly change the way voices are handled by the VoIP servers in the system. We believe that the bug is now solved. What do you think?
.L.
Comment #15
freescholar commentedThe dev version works great - no sign of the bug.
6.x-1.x-dev tar.gz (120.47 KB) | zip (142.99 KB) 2012-Mar-03
I installed it on a fresh installation of D6 without any issues!
I also updated a D6 site that did have the bug and it is now working as planned.
Thanks Leo!!!
Comment #16
leoburd commentedGlad that this is solved!
Comment #16.0
leoburd commentedDone the clean install; it's the same.