Ticket #2554 (closed Bugs: fixed)

Opened 5 years ago

Last modified 5 years ago

ExecIf forces change in extension.conf to support astersk trunk/1.6

Reported by: pnlarsson Assigned to:
Priority: minor Milestone: 2.4
Component: Asterisk Configuration Version: 2.4-branch
Keywords: ExecIf Cc:
Confirmation: Need Feedback Distro:
Backend Engine: Asterisk 1.6 Distro Ver:
Backend Ver: Asterisk Trunk SVN Revision (if applicable): 5474

Description

Some changes to ExecIf? in trunk means:

Index: extensions.class.php
===================================================================
--- extensions.class.php        (revision 5498)
+++ extensions.class.php        (arbetskopia)
@@ -585,7 +585,13 @@
        }

        function output() {
-               return "ExecIf(".$this->expr.",".$this->app.",".$this->data.")";
+               global $version;
+
+               if (version_compare($version, "1.6", "ge")) {
+                       return "ExecIf(".$this->expr."?".$this->app."(".$this->data."):Noop(False))";
+               } else {
+                       return "ExecIf(".$this->expr.",".$this->app.",".$this->data.")";
+               }
        }
 }

The extra Noop(False) has to do with http://bugs.digium.com/view.php?id=11564

We would need two different extensions.conf files, one 1.2/1.4 and one trunk/1.6. This are the diff between the two at the moment.

Index: extensions.conf
===================================================================
--- extensions.conf     (revision 5498)
+++ extensions.conf     (arbetskopia)
@@ -663,7 +663,7 @@
 ;
 [macro-dialout-trunk]
 exten => s,1,Set(DIAL_TRUNK=${ARG1})
-exten => s,n,ExecIf($[$["${ARG3}" != ""] & $["${DB(AMPUSER/${AMPUSER}/pinless)}" != "NOPASSWD"]],Authenticate,${ARG3})
+exten => s,n,ExecIf($[$["${ARG3}" != ""] & $["${DB(AMPUSER/${AMPUSER}/pinless)}" != "NOPASSWD"]]?Authenticate(${ARG3}))
 exten => s,n,GotoIf($["x${OUTDISABLE_${DIAL_TRUNK}}" = "xon"]?disabletrunk,1)
 exten => s,n,Set(DIAL_NUMBER=${ARG2}) ; fixlocalprefix depends on this
 exten => s,n,Set(DIAL_TRUNK_OPTIONS=${DIAL_OPTIONS}) // will be reset to TRUNK_OPTIONS if not intra-company
@@ -731,10 +731,10 @@
 exten => s,n(a3),Read(CALLBACKNUM,agent-user)          ; get callback number from user
 exten => s,n,GotoIf($["${CALLBACKNUM}" != ""]?a7)      ; if user just pressed # or timed out, use cidnum
 exten => s,n(a5),Set(CALLBACKNUM=${AMPUSER})
-exten => s,n,ExecIf($["${CALLBACKNUM}" = ""],Set,CALLBACKNUM=${CALLERID(number)})
+exten => s,n,ExecIf($["${CALLBACKNUM}" = ""]?Set(CALLBACKNUM=${CALLERID(number)}))
 exten => s,n,GotoIf($["${CALLBACKNUM}" = ""]?a3)       ; if still no number, start over
 exten => s,n(a7),GotoIf($["${CALLBACKNUM}" = "${ARG1}"]?invalid)       ; Error, they put in the queue number
-exten => s,n,ExecIf($["${ARG2}" != ""],Authenticate,${ARG2})
+exten => s,n,ExecIf($["${ARG2}" != ""]?Authenticate(${ARG2}))
 exten => s,n(a9),AddQueueMember(${ARG1},Local/${CALLBACKNUM}@from-internal/n)  ; using chan_local allows us to have agents over trunks
 exten => s,n,UserEvent(Agentlogin,Agent: ${CALLBACKNUM})
 exten => s,n,Wait(1)
@@ -753,7 +753,7 @@
 exten => s,n(a3),Read(CALLBACKNUM,agent-user)          ; get callback number from user
 exten => s,n,GotoIf($["${CALLBACKNUM}" = ""]?a5:a7)    ; if user just pressed # or timed out, use cidnum
 exten => s,n(a5),Set(CALLBACKNUM=${AMPUSER})
-exten => s,n,ExecIf($["${CALLBACKNUM}" = ""],Set,CALLBACKNUM=${CALLERID(number)})
+exten => s,n,ExecIf($["${CALLBACKNUM}" = ""]?Set(CALLBACKNUM=${CALLERID(number)}))
 exten => s,n,GotoIf($["${CALLBACKNUM}" = ""]?a3)       ; if still no number, start over
 exten => s,n(a7),RemoveQueueMember(${ARG1},Local/${CALLBACKNUM}@from-internal/n)
 exten => s,n,UserEvent(RefreshQueue)
@@ -764,7 +764,7 @@
 ; arg1 = trunk number, arg2 = number
 [macro-dialout-enum]
 ; Re-written to use enumlookup.agi
-exten => s,1,ExecIf($[$["${ARG3}" != ""] & $["${DB(AMPUSER/${AMPUSER}/pinless)}" != "NOPASSWD"]],Authenticate,${ARG3})
+exten => s,1,ExecIf($[$["${ARG3}" != ""] & $["${DB(AMPUSER/${AMPUSER}/pinless)}" != "NOPASSWD"]]?Authenticate(${ARG3}))
 exten => s,n,Macro(outbound-callerid,${ARG1})
 exten => s,n,Set(GROUP()=OUT_${ARG1})
 exten => s,n,GotoIf($["${OUTMAXCHANS_${ARG1}}foo" = "foo"]?nomax)
@@ -945,7 +945,7 @@
 ;
 exten => s,n,Set(AMPUSER=${IF($["foo${AMPUSER}" = "foo"]?${CALLERID(number)}:${AMPUSER})})
 exten => s,n,GotoIf($["${CHANNEL:0:5}" = "Local"]?report)
-exten => s,n,ExecIf($["${REALCALLERIDNUM:1:2}" = ""],Set,REALCALLERIDNUM=${CALLERID(number)})
+exten => s,n,ExecIf($["${REALCALLERIDNUM:1:2}" = ""]?Set(REALCALLERIDNUM=${CALLERID(number)}))
 exten => s,n(start),NoOp(REALCALLERIDNUM is ${REALCALLERIDNUM})
 exten => s,n,Set(AMPUSER=${DB(DEVICE/${REALCALLERIDNUM}/user)})
 exten => s,n,Set(AMPUSERCIDNAME=${DB(AMPUSER/${AMPUSER}/cidname)})
@@ -958,7 +958,7 @@
 exten => s,n,Set(AMPUSERCID=${IF($["${DB_EXISTS(AMPUSER/${AMPUSER}/cidnum)}" = "1"]?${DB_RESULT}:${AMPUSER})})
 exten => s,n,Set(CALLERID(all)="${AMPUSERCIDNAME}" <${AMPUSERCID}>)
 exten => s,n,Set(REALCALLERIDNUM=${DB(DEVICE/${REALCALLERIDNUM}/user)})
-exten => s,n,ExecIf($[ "${DB(AMPUSER/${AMPUSER}/language)}" != "" ],Set,LANGUAGE()=${DB(AMPUSER/${AMPUSER}/language)})
+exten => s,n,ExecIf($["${DB(AMPUSER/${AMPUSER}/language)}" != ""]?Set(LANGUAGE()=${DB(AMPUSER/${AMPUSER}/language)}))
 exten => s,n(report),Noop(TTL: ${TTL} ARG1: ${ARG1})
 exten => s,n,GotoIf($[ "${ARG1}" = "SKIPTTL" ]?continue)
 exten => s,n(report2),Set(__TTL=${IF($["foo${TTL}" = "foo"]?64:$[ ${TTL} - 1 ])})
@@ -1014,7 +1014,7 @@
 exten => s,n,Set(CALLERID(all)=${USEROUTCID})
 exten => s,n,GotoIf($["x${CALLERID(name)}"!="xhidden"]?checkname:hidecid) ; check CID blocking for extension
 exten => s,n(hidecid),SetCallerPres(prohib_passed_screen) ; Only works with ISDN (T1/E1/BRI)
-exten => s,n(checkname),ExecIf($[ $[ "${CALLERID(number)}" = "${REALCALLERIDNUM}" ] & $[ "${CALLERID(name)}" = "" ] ],Set,CALLERID(name)=${REALCALLERIDNAME})
+exten => s,n(checkname),ExecIf($[ $[ "${CALLERID(number)}" = "${REALCALLERIDNUM}" ] & $[ "${CALLERID(name)}" = "" ] ]?Set(CALLERID(name)=${REALCALLERIDNAME}))
 exten => s,n(report),NoOp(CallerID set to ${CALLERID(all)})

 ; Privacy Manager Macro makes sure that any calls that don't pass the privacy manager are presented

Attachments

execif.diff (34.8 kB) - added by pnlarsson on 12/15/07 19:08:46.
Complete patch for support of ExecIf? for asterisk trunk

Change History

12/15/07 11:50:23 changed by pnlarsson

Improved ExecIf? class: Index: extensions.class.php =================================================================== --- extensions.class.php (revision 5498) +++ extensions.class.php (arbetskopia) @@ -575,17 +575,27 @@

class ext_execif {

var $expr;

- var $app; - var $data; + var $app_true; + var $data_true; + var $app_false; + var $data_false;

- function ext_execif($expr, $app, $data=) { + function ext_execif($expr, $app_true, $data_true=, $app_false = 'Noop', $data_false = ) {

$this->expr = $expr;

- $this->app = $app; - $this->data = $data; + $this->app_true = $app_true; + $this->data_true = $data_true; + $this->app_false = $app_false; + $this->data_false = $data_false;

}

function output() {

- return "ExecIf?(".$this->expr.",".$this->app.",".$this->data.")"; + global $version; + + if (version_compare($version, "1.6", "ge")) { + return "ExecIf?(".$this->expr."?".$this->app_true."(".$this->data_true."):".$this->app_false."(".$this->data_false.")"; + } else { + return "ExecIf?(".$this->expr.",".$this->app_true.",".$this->data_true.")"; + }

}

}

}}}

12/15/07 11:53:06 changed by pnlarsson

Ooops:

Index: extensions.class.php
===================================================================
--- extensions.class.php        (revision 5498)
+++ extensions.class.php        (arbetskopia)
@@ -575,17 +575,27 @@

 class ext_execif {
        var $expr;
-       var $app;
-       var $data;
+       var $app_true;
+       var $data_true;
+       var $app_false;
+       var $data_false;

-       function ext_execif($expr, $app, $data='') {
+       function ext_execif($expr, $app_true, $data_true='', $app_false = 'Noop', $data_false = '') {
                $this->expr = $expr;
-               $this->app = $app;
-               $this->data = $data;
+               $this->app_true = $app_true;
+               $this->data_true = $data_true;
+               $this->app_false = $app_false;
+               $this->data_false = $data_false;
        }

        function output() {
-               return "ExecIf(".$this->expr.",".$this->app.",".$this->data.")";
+               global $version;
+
+               if (version_compare($version, "1.6", "ge")) {
+                       return "ExecIf(".$this->expr."?".$this->app_true."(".$this->data_true."):".$this->app_false."(".$this->data_false.")";
+               } else {
+                       return "ExecIf(".$this->expr.",".$this->app_true.",".$this->data_true.")";
+               }
        }
 }

12/15/07 12:31:26 changed by p_lindheimer

  • confirmation changed from Unreviewed to Need Feedback.
  • milestone changed from Cut Line to 2.4.

unless I'm missing something, defaults for false should be null and if null, should not even be generated - putting a noop there simply adds more overhead and work to Asterisk - or does it require a second parameter in 1.6?

(follow-up: ↓ 5 ) 12/15/07 13:37:29 changed by pnlarsson

Well, without the second application argument, execif will return -1 and terminate the script. Thats why i posted a patch http://bugs.digium.com/view.php?id=11564 to solve that issue. Thats why the extensions.conf above works on my system.

12/15/07 19:08:46 changed by pnlarsson

  • attachment execif.diff added.

Complete patch for support of ExecIf? for asterisk trunk

(in reply to: ↑ 4 ) 12/15/07 19:56:44 changed by p_lindheimer

Replying to pnlarsson:

Well, without the second application argument, execif will return -1 and terminate the script. Thats why i posted a patch http://bugs.digium.com/view.php?id=11564 to solve that issue. Thats why the extensions.conf above works on my system.

Do you anticipate the patch being put in? I would much rather not generate un-necessary noop() commands in the execif. It may be fine to do it until they get the code fixed but I would want that backed off so that it is generated much like the gotoif.

12/16/07 01:05:53 changed by p_lindheimer

  • engine changed from Asterisk 1.4.x to Asterisk 1.6.
  • status changed from new to closed.
  • resolution set to fixed.

r5504 (extensions.class.php changes/additions) r5505 (macro-dialout-trunk, macro-user-callerid, macro-dialout-enum, macro-outbound-callerid, macro-agent-add, macro-agent-del)

moved to core auto-generation to deal with syntax change in execif command in Asterisk 1.6.