i Know Kung Foo Consulting

How NOT to code a CFLOOP

I've been chasing down a CFLOOP timeout error in one of our apps that escaped our rewrite project. After searching through code for 3 weeks, var scoping a bunch of CFCs and wading through a ton of business logic I think I found the culprit.

Of course, it would have to have been in the last file in my list.

Primary Suspect
<cfloop from="1" to="99999" index="x" >
   
   <cfset a = a + someQueryValue />
   <cfset b = b + anotherQueryValue />
   
   <cfif ( a gt c ) or ( b gte yetAnotherQueryValue )>
      
      <cfset x = 99999 />
      <cfbreak />
      
   </cfif>

</cfloop>

Book 'em Danno!


Comments (Comment Moderation is enabled. Your comment will not appear until approved.)
Ken Sykora's Gravatar Maybe they didn't realize you can use the condition="" attribute? This is a good WTF.
# Posted By Ken Sykora | 4/15/08 7:48 PM