Skip to content

Commit c2c62d0

Browse files
fix scoping issues
1 parent aeb755b commit c2c62d0

File tree

1 file changed

+16
-15
lines changed

1 file changed

+16
-15
lines changed

components/cfsolrlib.cfc

+16-15
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,11 @@
7979
<cfargument name="coreName" type="string" required="true" hint="Solr core name" />
8080

8181
<cfscript>
82-
h = new http();
82+
var h = new http();
8383
h.setMethod("get");
8484
h.setURL("#THIS.solrURL#/#ARGUMENTS.coreName#/admin/ping");
85-
pingResponse = h.send().getPrefix().statusCode;
86-
coreCheckResponse = structNew();
85+
var pingResponse = h.send().getPrefix().statusCode;
86+
var coreCheckResponse = structNew();
8787
if (pingResponse eq "200 OK"){
8888
coreCheckResponse.success = true;
8989
coreCheckResponse.statusCode = pingResponse;
@@ -104,7 +104,7 @@
104104
<cfargument name="schemaName" type="string" required="false" hint="Name of schema file" />
105105

106106
<cfscript>
107-
URLString = "#THIS.host#:#THIS.port#/solr/admin/cores?action=CREATE&name=#ARGUMENTS.coreName#&instanceDir=#instanceDir#";
107+
var URLString = "#THIS.host#:#THIS.port#/solr/admin/cores?action=CREATE&name=#ARGUMENTS.coreName#&instanceDir=#instanceDir#";
108108
if (structKeyExists(ARGUMENTS, "dataDir")){
109109
URLString = "#URLString#&dataDir=#ARGUMENTS.dataDir#";
110110
}
@@ -114,11 +114,11 @@
114114
if (structKeyExists(ARGUMENTS, "schemaName")){
115115
URLString = "#URLString#&schema=#ARGUMENTS.schemaName#";
116116
}
117-
newCoreRequest = new http();
117+
var newCoreRequest = new http();
118118
newCoreRequest.setMethod("get");
119119
newCoreRequest.setURL("#URLString#");
120-
response = newCoreRequest.send().getPrefix();
121-
coreCreationResponse = structNew();
120+
var response = newCoreRequest.send().getPrefix();
121+
var coreCreationResponse = structNew();
122122
if (response.statusCode eq "200 OK"){
123123
coreCreationResponse.success = true;
124124
return coreCreationResponse;
@@ -148,6 +148,7 @@
148148
<cfset var suggestions = "" />
149149
<cfset var thisSuggestion = "" />
150150
<cfset var iSuggestion = "" />
151+
<cfset var currentResult = {} />
151152

152153
<cfif NOT arrayIsEmpty(ARGUMENTS.facetFields)>
153154
<cfset thisQuery.setFacet(true)>
@@ -225,7 +226,7 @@
225226
<!--- Remove any leading spaces in the search term --->
226227
<cfset ARGUMENTS.term = "#trim(ARGUMENTS.term)#">
227228
<cfscript>
228-
h = new http();
229+
var h = new http();
229230
h.setMethod("get");
230231
h.setURL("#THIS.solrURL#/suggest?q=#ARGUMENTS.term#");
231232
local.suggestResponse = h.send().getPrefix().Filecontent;
@@ -234,11 +235,11 @@
234235
local.wordList = "";
235236
if (ArrayLen(XMLResponse.response.lst) gt 1 AND structKeyExists(XMLResponse.response.lst[2].lst, "lst")){
236237
local.wordCount = ArrayLen(XMLResponse.response.lst[2].lst.lst);
237-
For (j=1;j LTE local.wordCount; j=j+1){
238+
For (var j=1;j LTE local.wordCount; j=j+1){
238239
if(j eq local.wordCount){
239240
local.resultCount = XMLResponse.response.lst[2].lst.lst[j].int[1].XmlText;
240241
local.resultList = arrayNew(1);
241-
For (i=1;i LTE local.resultCount; i=i+1){
242+
For (var i=1;i LTE local.resultCount; i=i+1){
242243
arrayAppend(local.resultList, local.wordList & XMLResponse.response.lst[2].lst.lst[j].arr.str[i].XmlText);
243244
}
244245
}else{
@@ -462,22 +463,22 @@
462463
var thisValueRaw = "";
463464
var thisValueProcessed = "";
464465

465-
if ( isSolrNamedListType(varToParse) ) {
466+
if ( isSolrNamedListType(arguments.varToParse) ) {
466467

467-
for (i=0; i lt varToParse.size(); i=i+1) {
468+
for (i=0; i lt arguments.varToParse.size(); i=i+1) {
468469
try {
469-
thisValueRaw = varToParse.getVal(i);
470+
thisValueRaw = arguments.varToParse.getVal(i);
470471
if ( isSolrNamedListType(thisValueRaw) ) { // do we need to call this function recursively? (these lists are often nested.)
471472
thisValueProcessed = parseSolrNamedListType(thisValueRaw);
472473
} else { // just a regular object (that cf knows how to work with)
473474
thisValueProcessed = thisValueRaw;
474475
}
475476
// build the structure to return
476-
outSct[varToParse.getName(i)] = thisValueProcessed;
477+
outSct[arguments.varToParse.getName(i)] = thisValueProcessed;
477478
} catch (any e) {
478479
writeLog(
479480
type="information",
480-
text="Solr response parsing failed on: " &varToParse.getName(i) &"- " &thisValueRaw.toString() &" type: " &getMetaData(thisValueRaw).getName()
481+
text="Solr response parsing failed on: " &arguments.varToParse.getName(i) &"- " &thisValueRaw.toString() &" type: " &getMetaData(thisValueRaw).getName()
481482
);
482483
}
483484
}

0 commit comments

Comments
 (0)