tracker issue : CF-3038578

select a category, or use search below
(searches all categories and all time range)
Title:

Bug 77255:StructKeyExists() evalutes to true when the key doesn't exist

| View in Tracker

Status/Resolution/Reason: Closed/Fixed/

Reporter/Name(from Bugbase): Tariq Ahmed / Tariq Ahmed (CFLEX.Net)

Created: 05/14/2009

Components: Language, Datastructure

Versions: 9.0

Failure Type: Unspecified

Found In Build/Fixed In Build: 0000 / 234883

Priority/Frequency: Major / Most users will encounter

Locale/System: English / Win All

Vote Count: 0

Problem:

StructKeyExists() evalutes to true when the key doesn't exist.

In Using ColdBox 2.6.3 I get some strange errors that don't make sense with CF9 Beta 2, that I believe worked in Beta 1 (not 100% sure of that, I'd have to double check).
Method:

Example 1:
==============================================
coldbox\system\controller.cfc : line 469
Element RESULTS is undefined in REFLOCAL.

Which is this:
468: <cfif structKeyExists(refLocal,"results")>
469:      <cfreturn refLocal.results>
470:  </cfif>

It makes it past line 468 which indicates results exists (when it fact it doesn't). So when it gets to 469, CF tries to access it and the code bombs.

However if I change the if statement to:
isDefined("refLocal.results")

That seems to fix it. 

Example 2:
==============================================
Element TMPOBJ is undefined in REFLOCAL.
 
\coldbox\system\cache\CacheManager.cfc: line 155

Code Snippet:
150: if( not structKeyExists(refLocal,"tmpObj") ){
151:   refLocal.needCleanup = true;
152:   getCacheStats().miss();
153: }
154: else{
155:   refLocal.targetObject = refLocal.tmpObj;
156:   getCacheStats().hit();
157: }

Line 150 is evaluating incorrectly, so the else statement kicks in and then the code bombs. If I change the if statement to:

if( not isDefined("refLocal.tmpObj") )

This fixed the issue.
Result:

----------------------------- Additional Watson Details -----------------------------

Watson Bug ID:	3038578

Deployment Phase:	Release Candidate

External Customer Info:
External Company:  
External Customer Name: Tariq Ahmed
External Customer Email: 7B121E0E452ADAEE99201549
External Test Config: 05/14/2009

Attachments:

Comments: