Strict Standards: Redefining already defined constructor for class Object in /home1/ryansh/public_html/ryanhafer.info/cake/libs/object.php on line 54

Strict Standards: Non-static method Configure::getInstance() should not be called statically in /home1/ryansh/public_html/ryanhafer.info/cake/bootstrap.php on line 38
Ryan Hafer | Of Coldfusion, Components, Variables and Confusion!?
Ryanhafer.info thumb

Of Coldfusion, Components, Variables and Confusion!?

2/20/12

The scenario:

 

  • A coldfusion application.
  • A component to process PayPal transactions.
  • A new function to process refunds by transaction ID.

 

So I had everything tested on the developer site. Things couldn't look better even. I am a great programmer... Until American Express cards keep failing with a peculiar message about invalid field "ORIGID". I pour through the code and see nothing.

But when the component is reloaded into the CF application, credit card processing works again. How strange is that? It must be something with the struct getting messed up.

Not until the next day does it fully dawn on me!

The Explanation:

Every PayPal transaction request used the same variable name. The peculiar thing about Coldfusion is that a variable set in one component function is available to the other functions in the component UNLESS specified in the <cfset> declaration. On the development site, this was never exibited because the component is reloaded on every call. When on the live site, the component and it's variables are cached in the application.

The Fix:

Just reseting the struct before setting it's properties with a simple StructNew() call. So simple, but such an unexpected behavior of coldfusion. I suppose the best programmer would always redeclare their variable anyways, but this is a continuous learning process.

 

 

Read Comments

Post A Comment

 
Switch themes | © 2017 RyanHafer.info. All Rights Reserved
xhtml validated css validated