The <CF Deprecated Features page> includes this: `...
# cfml-general
d
The CF Deprecated Features page includes this:
Copy code
cfscript support for script-based CFCs, such as query and storedproc
What does that mean exactly?
e
Use tags! Deprecated to Adobe means they recommend against it, will not enhance it, and eventually plan on doing away with it.
a
new Query()
has been deprecated for a while. I raised tickets about it as it has scoping issues and was told "won't fix" as it's deprecated.
You can use
QueryExecute
instead of
new Query()
or even better https://qb.ortusbooks.com/
Its a valid bug but there is no active development on these CFCs and we recommend to use QueryExecute function. So closing this issue.
Meh
Would have taken 30 mins tops to scope the variables but hey-ho. Too much effort.
d
How can we tell which BIFs are implemented as script-based CFCs? (assuming my understanding of the issue is correct...)
e
its outsourced development, my epic rant will not be placed here, but rest assured it does play into their "bug fixes"
a
There is a folder with them all in. Can't recall where but that's how I found the unscoped variables when looking at their source code.
e
you can do something like this... <cfset directoryPath = "W:\path2cfweb\"> <cffile action="list" directory="#directoryPath#" name="files"> <cfoutput query="files"> <cfset filePath = directoryPath & name> <cffile action="read" file="#filePath#" variable="fileContent"> <cfset unscopedVariables = reFindAllNoCase("([^\.\w])\b(\w+)(?=\W|\.|$)", fileContent)> <h2>Unscoped Variables in #name#:</h2> <ul> <cfloop index="variable" array="#unscopedVariables#"> <li>#variable[2]#</li> </cfloop> </ul> </cfoutput>
a
or just use cflint šŸ™‚
ā¤ļø 1
e
Cflint is not approved, as you know, approvals
šŸ™ƒ 1
d
So there are a bunch of deprecated built-in functions, but they're not actually listed in the deprecation notice, or far as I can tell from this conversation, anywhere else? Each developer is responsible for digging that list out of the CF source themselves? Not to be a fussbudget, but that's totally lame. @Mark Takata (Adobe)
m
Long thread, sum it up for me please. You are asking for a piece of documentation with all non-deprecated BIFs which are implemented as CFScript? Is that correct?
d
Sorry for the blah blah, and thanks for checking in. What I'm looking for personally is a list of the DEPRECATED built-in functions referred to on this page in the 2nd line of the table, "cfscript support for script-based CFCs, such as query and storedproc". I want to know what we need to look for and remove from our code.
m
Got it, no issues, let me move this to #documentation and ping Saurav.
s
@Dave Merrill It's a very poorly worded sentence. Back in CF9 (I think), when Adobe added cfscript support for "most" tags, they opted to implement cfquery, cfhttp, cfmail, and a few others as CFCs that were shipped with the product. You used them from cfscript just like any other CFC -- they were just "built-in". The community criticized the (tag-based) source code of these CFCs because they were buggy and fairly poorly designed. Eventually, they all got equivalent cfscript syntax instead (mostly through the awful
cf<tag> { }
syntax!) and then the CFCs stopped getting updates and the guidance was "don't use them -- switch to the "native" cfscript stuff instead. The community guidance has pretty much always been "don't use them -- they're buggy!" šŸ™‚ The "deprecated" code in question is stuff like
new Query(...)
,
new Mail(...)
, `new
Http(...)
(I forget the exact names of those CFCs -- I never used them because they were buggy! -- but you should be able to find
Query.cfc
etc in your CF install somewhere and that will tell you the full list.
(note the link to more of these awful CFCs added in 9.1)
Those docs reminded me that you might also have
createObject("component",<script-as-CFC>)
as well as
new <script-as-CFC>(...)
in your code.
d
Nice archeology Sean, thanks šŸ™‚ I remember all that happening, but it wasn't clear to me that that's what that bit of recent doc was referring to. Just to say it, it's a shame that you (still) have to do tags for stuff like dbinfo.
s
It makes me shudder, remembering those things ever existed... 🤣
a
Be nice if they logged a "deprecated" message to system out or something when functions are deprecated.
In fairness the Code Analyzer is supposed to detect "unsupported and deprecated CFML features"
d
Hmmm, I'll take another swing at our code bases with the Code Analyzer, see what it kicks out. We were clean last time I ran it, which was when we upgraded our two main systems to 2018 and 2021.
a
Yeah - just ran it agains code with
new Query
in it - didn't flag it. So Seems the " Code Analyzer" does not flag all deprecated features šŸ˜ž
d
Wunnerful
Not trying to give you a hard time, just looking into how a comprehensive implementation might be built, if no CF-native version is available. • Where did that list of deprecated functions come from? • It doesn't include the CFC-based functions that started this thread (query(), dbinfo(), etc)
e
The complete list is here: https://helpx.adobe.com/coldfusion/deprecated-features.html - I use tags, its not by any means a complete list, but you can easily append the list with any string you like.
s
@Evil Ware Did you actually test that code? It has
reFindNoCase("<cf" & feature, fileContent)
but the strings in
deprecatedFeatures
already include the
CF
prefix so it won't match anything (and, as @Dave Merrill said, it doesn't address the original question here at all, looking for
new <deprecatedCFC>
or
createObject("component","<deprecatedCFC>")
etc).
Also, if you're going to post code, please use the snippet feature so we don't get a giant wall of unformatted text. I'm going to delete your code above as not helpful/relevant to this thread.
In addition, the page you linked to is the one that the OP complained about in the first place so, again, not a helpful contribution.
e
Test, meeh - code and toss into production and fix what is broken šŸ™‚ As for what I suggest doing, you could just use the UNIX command "find /path/to/directory -type f -exec sed -n '/query/I=filename:{}' " you can even loop it over a list of tags or any other string. I diegress, We could sit here and piss our selves silly with crap I do while sitting on a train or stuck in traffic jams, all the while tapping on a phone trying to producte proper code, in which I would hope, for all that is holy, nobody would ever just cut and paste code they found online into production. I do not, and I can not stress this enough, CFSCRIPT is filled with errors, potential for errors and easily confused by anyone glancing at it as javascript, good; Oh wait, you want the corporate version of this --- OKAY ------ Perform rigorous testing, code review, and deploy to production environment, followed by thorough debugging and issue resolution. Regarding the proposed solution, I recommend utilizing the UNIX command 'find /path/to/directory -type f -exec sed -n '/query/I=filename:{}'.' This command can be efficiently looped over a list of tags or any other specified string. However, it is essential to exercise caution when incorporating code obtained from online sources directly into production, as it may contain errors or be misleading. It is crucial to ensure code quality and avoid potential complications, as CFSCRIPT can be prone to errors and easily mistaken for JavaScript by casual observers, which may lead to confusion."
s
That
find
command is going to have so many false positives that it is useless -- and still doesn't address the OP's question.
(and your
find
command doesn't actually work at all)
find: missing argument to `-exec'
e
@seancorfield It all comes down to how you use the tools you are given, and the ability to understand the limitations of those tools.
d
I appreciate the ideas and testing here, but really, it's simpler than that, in my view as the OP at least. Adobe deprecated a bunch of functions, but didn't list out which ones they were. That right there is not ideal. We shouldn't have to each separately engineer and test a way to discover that info. I think @Mark Takata (Adobe) is already working on a real solution w the documentation folks, so we can all stand down until that shows up I think.