Is anyone else having a problem with cidlookup?

Hi,

Since I installed freepbx (various versions, currently ver 2.3.1 and 2.4.0) the cidlookup function (which I use a lot) seems to have an issue.

When a number is looked up that doesnt exist in the database, it returns mostly the same name (one not related to it at all). The conditions seem to be when there is no CID info at all (Im in Australia if that makes any difference using an E1 line. AU only provide the phone number in CID).

Some calls that have blocked CID info returns a ‘0’ for the CID. This result seems to work and results in an empty string for the CID, however, for an empty CID of ‘’ it seems to pick the same record even though it shouldnt have resulted in anything except an empty string.

The CID code in our extensions_additional.conf looks like this

[cidlookup]
include => cidlookup-custom
exten => cidlookup_1,1,Gosub(CIDFixup,1,1)
exten => cidlookup_1,n,MYSQL(Connect connid localhost root lartsek Kestral)
exten => cidlookup_1,n,MYSQL(Query resultid ${connid} SELECT\ name\ FROM\ CIDLookup\ WHERE\ Phone=’${CALLERID(num)}’)
exten => cidlookup_1,n,MYSQL(Fetch fetchid ${resultid} CALLERID(name))
exten => cidlookup_1,n,MYSQL(Clear ${resultid})
exten => cidlookup_1,n,MYSQL(Disconnect ${connid})
exten => cidlookup_1,n,Return()
exten => cidlookup_return,1,LookupCIDName
exten => cidlookup_return,n,Return()

I have reduced the select statement as its quite a long one, but where I believe the problem lies is there is no check to see if the Fetch actually resulted in any data. Shouldn’t fetchid be checked for a 0 or 1 and appropriate action be taken ?

I’m asking here as I’m not sure if I have missed something that would somehow produce the desired empty string, but looking at the voip-info.org docs on the Fetch statement, it says that if it fails to retrieve a row, fetchid would be 0 and the variables would be left unchanged (hence they may have anything in them as they weren’t initialised to empty (or do they default to empty rather than uninitialised).

Thanks,
Andrew