Skip to main content
Inspiring
June 20, 2016
Answered

GetMetaData Returns phantom Parameters

  • June 20, 2016
  • 2 replies
  • 463 views

I'm playing around with GetMetaData to do a little introspection of my CFC's when I ran into an anomaly I don't understand.

My CFC has multiple functions embedded within it.  One of these functions is defined as follows:

<cffunction name="getMyDenied" access="public" returntype="query">

  <cfargument name="userid" type="string" required="yes">

  <cfargument name="environment" type="string" required="no" default="0" hint="Pass in 0 for Development and 1 for Production">

...

</CFFUNCTION>

When I exam the CFC using GetMetaData I get this output for the getMyDenied function:

The thing that confuses me is why the HINT parameter is showing up in the userid argument. 

The weird thing about this is if I exam the HINT parameter using #Len(TRIM(CFC_Functions.functions[cc].Parameters[1].Hint))# I get the number 6. If I copy the value into a new array or structure and then CFDUMP the results it shows up as an "Empty String".

Then in the same CFC I also have this function:

<cffunction name="getMyPurchaseOrders" access="public" returntype="query">

  <cfargument name="userid" type="numeric" required="yes">

  <cfargument name="environment" type="string" required="no" default="0" hint="Pass in 0 for Development and 1 for Production">

  ...

</CFFUNCTION>

When I exam the CFC using GetMetaData I get this output for the getMyPurchaseOrders function:

So my two questions are:

  1. Why does the getMyPurchaseOrders function return properly where as the getMyDenied function returns a phantom HINT parameter?
  2. How do I trap the phantom HINT parameter?  What I can tell is:
    • if I run IsValid('String',CFC_Functions.functions[cc].Parameters[xx].Hint) against the variable the return is TRUE. 
    • <CFSET z = ToString(CFC_Functions.functions[cc].Parameters[xx].Hint)> #Len(TRIM(z))#  returns 6.
    • <CFIF CFC_Functions.functions[cc].Parameters[xx].Hint EQ '      '>WTF<CFELSE>Nada</CFIF> always returns Nada even though I entered 6 spaces in the EQ clause.

Any thoughts or suggestions are welcome!!!

This topic has been closed for replies.
Correct answer KomputerMan_com-L7dcfe

@BKBK, I'm using CF Server 9,0,0,251028.  I expected to see something similar to what you displayed too, which is why I was confused.

Still not sure why the GetMetaData call is returning the phantom parameter but I finally figured out what the returned value was!  Of course once the light came on I felt a little like a dumba$$.  :O

Question: What takes 6 characters to display a blank space? Answer: "& nbsp ;"  (without the spaces so it will display in this form) of course.  Once I built my trap to look for those 6 characters I was able to programmatically deal with the phantom parameter.

2 replies

KomputerMan_com-L7dcfeAuthorCorrect answer
Inspiring
June 20, 2016

@BKBK, I'm using CF Server 9,0,0,251028.  I expected to see something similar to what you displayed too, which is why I was confused.

Still not sure why the GetMetaData call is returning the phantom parameter but I finally figured out what the returned value was!  Of course once the light came on I felt a little like a dumba$$.  :O

Question: What takes 6 characters to display a blank space? Answer: "& nbsp ;"  (without the spaces so it will display in this form) of course.  Once I built my trap to look for those 6 characters I was able to programmatically deal with the phantom parameter.

BKBK
Community Expert
Community Expert
June 20, 2016

Weird. What is your ColdFusion version? How do you display the metadata?

I am on Coldfusion 2016. I wrote a CFC based on your 2 functions, and called it test.cfc. Then I ran this code in a page on the same directory:

<cfset obj=createobject("component","test")>

<cfdump var="#getMetadata(obj).functions#">

The result is as expected.