DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
  1. DZone
  2. Data Engineering
  3. Data
  4. A highly unusual ColdFusion arguments error

A highly unusual ColdFusion arguments error

Raymond Camden user avatar by
Raymond Camden
·
Feb. 28, 13 · Interview
Like (0)
Save
Tweet
Share
2.12K Views

Join the DZone community and get the full member experience.

Join For Free

This one is weird. I don't mean kinda weird. I mean bat-crap insane what-the-hell type weird. Earlier today Jeremy Tan sent me some code that acted a bit odd. Let's take a look at it.

<cfscript>
test = {firstName="Bob in line 2"};
i=1;
transaction {
     new mycfc().set(Text1:"hello",something:"Bob in text");
     i++;
     new mycfc().set(Text1:"hello",something:"Bob in text again");
     new mycfc().set(Text1:"hello",something:test);
     new mycfc().set(Text1:"hello",something:{firstName="Bob in line 9"});
     test2 = {firstName="Merry"};
     writeDump(var=test2,label="line 11" );
     new mycfc().set(Text1:"hello",something:{firstName="Jenny"});
     i++;
     new mycfc().set(Text1:"hello",something:{firstName="Jenny 2"});
}
writeDump("i = #i#");
</cfscript>

In the code snippet above, you can see some data being passed to a CFC within a transaction. Note - there are no actual database calls here, but that doesn't matter. The CFC is simply doing a dump of the Arguments scope:

<cfcomponent  output="true">

     <cffunction name="set" output="true" returntype="void">
          <cfargument name="text1" type="string" required="true">
          <cfargument name="something" type="any" required="true">
          <cfdump var="#arguments#">
     </cffunction>

</cfcomponent>

Now let's look at the output. There should be 6 dumps from the set() call and one in the middle for test2.

Um... ok. We have 8 dumps. We don't have the dump of test2. Also note the third dump, which should have "Bob in line 2", has it as 9. Oh, and even better, i is 2, not 3.

Things get weirder if we simplify. I commented out everything but the last two calls:

new test().set(Text1:"hello",something:{firstName="Jenny"});
new test().set(Text1:"hello",something:{firstName="Jenny 2"});

Yep, three dumps. Here is where things get even more weird. Jeremy found that if he simply stopped using named arguments and switched to ordered ones, everything worked fine.

If there was a bug with the data being displayed (oh wait, there is that too), then I'd maybe think it made sense. Again, as a bug. But the additional calls just don't make sense at all.

Obviously this is could be really bad for anyone doing CFC calls inside a transaction. You can find Jeremy's forum post on the topic here: Weird transaction issue with implicit struct (and possible array). I've also asked him to fill out a bug report and post the link here.



Dump (program) Data (computing) POST (HTTP) Snippet (programming) Database Links Data structure

Published at DZone with permission of Raymond Camden, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • How to Secure Your CI/CD Pipeline
  • Cloud Native London Meetup: 3 Pitfalls Everyone Should Avoid With Cloud Data
  • Handling Automatic ID Generation in PostgreSQL With Node.js and Sequelize
  • A Beginner's Guide to Back-End Development

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: