CF 2018.0.13.329786 `writedump(isObject(url.get('b...
# cfml-general
j
CF 2018.0.13.329786
writedump(isObject(url.get('bogus')));
returns
YES
--- shouldn't it return
NO
for
undefined
?
t
From trycf.com, Lucee throws an error which also seems reasonable. But Adobe returns true, in all versions from 10 up through 2021.
b
@John Varady A simpler example is
Copy code
isObject(javaCast('null',''))
It seems
isObject()
returns
true
when passed a
null
.
I'd enter a ticket
Is there a reason you're using an underlying, undocumented method on the
url
scope? in CF 2018, the
url
scope is an instance of the
coldfusion.filter.UrlScope
class, so when you call
get()
you're just calling an undocumented method on that java class.
t
Oddly,
writeDump(isObject(StructGet("url.bogus")))
does return false.
b
That's because
StructGet("url.bogus")
returns a struct
t
you'd think that it'd be using the member functions, and return the same thing for both.
b
What member functions?
a
URL is not a struct
b
Oh, you mean treating url as a struct?
a
the
get
method is a method of the underlying URL scope implementation
I am astounded how this has come up three times in the last week
😀 1
t
sigh... it's one of those?
keyExists
works. Accessing vai struct notation works.
b
CF engine support for treating scopes as first-class structs (in regard to member functions) has been spotty over the years. I'm honestly not sure if Adobe CF uses struct member functions for scopes or not.
t
why oh why do stucty things work on non-structs?
a
yes. They have implemented a
keyExists
method. This is just... OOP
class UrlImpl implements Structish {}
And I am guessing the initial scope implementation has its own get method already
Adobe never claimed to have implemented the member function stuff on scopes.
So that they do implement some stuff (most stuff?) is just "luck"
But that these questions keep getting asked is just a fundamental lack of understanding of OOP around here. It's embarrassing, if I'm to be frank.
t
useful luck... But ugh. I get it. but it seems like if they're going to have
Scope implements Structish
, they could maybe go all the way, and
Scope implements Struct
and save us all a lot having to remember exceptions.
a
Oh that was pseudocode on my part (hopefully obviously)
t
yeah, of course. Mine is too.
a
The URL scope implementation predates the notion of member functions though. They clearly need the get method to do something else.
What they should do (ping @Mark Takata (Adobe) and @saghosh) is do DOCUMENT THINGS PROPERLY
💯 1
"we have implemented these struct-ish member functions on scopes. But not these other ones because [reasons]"
What I don't get - and this makes me really really angry @ the Adobe CF Team - is they are Java devs and they spend all day every day looking at proper, decent javadoc style docs for everything they do. But the CFML docs are just shite
They treat their own paying clients like second-class citizens.
rrarrrr!!!!
phew. That's better.
m
Adam, I always think of you as my own personal 1.5 citizen ❤️
a
@saghosh I also don't see any explanation in https://helpx.adobe.com/coldfusion/cfml-reference/coldfusion-functions/functions-in-k/isobject.html as to why
isObject
returns
true
for
null
?
Plus WTH does this mean (down the bottom): Output YES NO
@Mark Takata (Adobe) is that 1.5 citizen on the same scale that a 10x developer is?
I think I am insulted. 😉
m
I can't count that high, but I'll take your word for it. 😄
So, hilariously, the output is not correct
The ACTUAL output is (I wish I was kidding) YESNO
Which I think is a city in California near Fresno
b
When we're done yelling at the docs, let's not forget
Copy code
isObject( javacast('null','') )
is still returning
YES
when passed a null.
2
interestingly enough, so does Lucee, but perhaps just for compat?? 🤷
At least I can go poke at the source code there to fine out
Here's Lucee's implementation of isObject (open source FTW!)
Copy code
/**
	 * returns if object is a CFML object
	 * 
	 * @param o Object to check
	 * @return is or not
	 */
	public static boolean isObject(Object o) {
		return isComponent(o)

				|| (!isArray(o) && !isQuery(o) && !isSimpleValue(o) && !isStruct(o) && !isUserDefinedFunction(o) && !isXML(o));
	}
Which is • the input is a CFC instance • OR it's NOT an (array, query, simple value, struct, UDF, or XML)
So it's the second bullet not matching any of those. Personally I think the lack of a null check is just an oversight here.
2
I'm pretty sure the second part of the if was simply meant to match any java object that wasn't a baked in CF type
The OP has gone dark (we probably scare him off...). I'll toss in a couple tickets so, even if the behavior is kept, it's documented as on purpose somewhere
👻 1
2
a
we probably scare him off...)
So polite of you to say "we" there, Brad.
😉 1
a
Can't wait to read how both vendors wriggle their way out of these ones. Voted, anyhow.
m
I prefer the term "politically twerk" over wriggle. Uses more ink on the printer.
🤣 3
j
Thanks for all the replies and for opening tickets. I didn't go dark so much as stir the pot and check back later to see what rises.
a
the scum rose to the top, as expected.
Hey I gotta be top of something
a
Does anyone remember when we could suggest edits (like a wiki) to the Adobe docs or am I just imagining that?