[SR-Dev] new operators & if($v) behaviour

Henning Westerholt henning.westerholt at 1und1.de
Fri Apr 24 18:36:29 CEST 2009


On Friday 24 April 2009, Andrei Pelinescu-Onciul wrote:
> Right now we have a problem with old scripts that use things like
> if ($v)  (where $v could be avp, pseudovar or select).
>
> $v can evaluate to a int, a string or undefined.
>
> Now for string and undefined the if will evaluate to false (string
> being an error) and an error will be logged.
> If the type of $v can be found prior to runtime (e.g. @select is always
> string) you'll even get a parse error.
>
> I plan to add some new operators, to properly deal with these cases:
>
> defined($v)
>
> strempty($v)
> strlen($v)
>
> but the question still remains if we should preserve compatibility and
> still support things like if (@to.tag), instead of if (!strempty(@to.tag))
> or if (@to.tag!="").

Hi Andrei,

does this also apply to kamailio pseudo-variables that evaluates to a string, 
like this:

if ($hdr(X-Foobar)) { # do something on this hdr }

If yes, then i'd vote for keeping this functionality, as its more easier to 
read and understand as using another operator, as Miklos already said.

Cheers,

Henning



More information about the sr-dev mailing list