Skip to content

Commit

Permalink
Merge branch '6.2' into 7.0
Browse files Browse the repository at this point in the history
# Conflicts:
#	core/src/main/java/lucee/runtime/config/ConfigAdmin.java
#	core/src/main/java/lucee/runtime/config/ConfigWebFactory.java
#	loader/build.xml
#	loader/pom.xml
  • Loading branch information
michaeloffner committed Dec 13, 2024
2 parents 5101522 + 3d5667c commit 9fb8d36
Show file tree
Hide file tree
Showing 10 changed files with 200 additions and 20 deletions.
11 changes: 10 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,15 @@ on:
- '**' # thus ignoring tagging
pull_request:
workflow_dispatch:
inputs:
LUCEE_BUILD_JAVA_VERSION:
required: true
type: string
default: '21'
LUCEE_TEST_JAVA_VERSION:
description: Optional Java Test version, default is the build java version
required: false
type: string

#concurrency:
# group: ${{ github.head_ref }}
Expand Down Expand Up @@ -301,4 +310,4 @@ jobs:
echo "Trigger Docker Build on Travis https://travis-ci.com/github/lucee/lucee-dockerfiles"
chmod +x travis-docker-build.sh
./travis-docker-build.sh
8 changes: 4 additions & 4 deletions core/src/main/java/lucee/runtime/config/ConfigAdmin.java
Original file line number Diff line number Diff line change
Expand Up @@ -980,7 +980,7 @@ public void removeRestMapping(String virtual) throws ExpressionException, Securi
public void removeCustomTag(String virtual) throws SecurityException {
checkWriteAccess();

Array mappings = ConfigUtil.getAsArray("customTagMappings", root);
Array mappings = ConfigUtil.getAsArray(root, true, KeyConstants._virtual, KeyConstants._physical, false, "customTagMappings", "customTagPaths");
Key[] keys = mappings.keys();
Struct data;
String v;
Expand Down Expand Up @@ -1019,7 +1019,7 @@ private void _removeScheduledTask(String name) throws ExpressionException {
public void removeComponentMapping(String virtual) throws SecurityException {
checkWriteAccess();

Array mappings = ConfigUtil.getAsArray("componentMappings", root);
Array mappings = ConfigUtil.getAsArray(root, true, KeyConstants._virtual, KeyConstants._physical, false, "componentMappings", "componentPaths");
Key[] keys = mappings.keys();
Struct data;
String v;
Expand Down Expand Up @@ -1070,7 +1070,7 @@ private void _updateCustomTag(String virtual, String physical, String archive, S
throw new ExpressionException("physical must have a value when primary has value physical");
}

Array mappings = ConfigUtil.getAsArray("customTagMappings", root);
Array mappings = ConfigUtil.getAsArray(root, true, KeyConstants._virtual, KeyConstants._physical, false, "customTagMappings", "customTagPaths");
Key[] keys = mappings.keys();
// Update
String v;
Expand Down Expand Up @@ -1169,7 +1169,7 @@ private void _updateComponentMapping(String virtual, String physical, String arc
throw new ExpressionException("physical must have a value when primary has value physical");
}

Array componentMappings = ConfigUtil.getAsArray("componentMappings", root);
Array componentMappings = ConfigUtil.getAsArray(root, true, KeyConstants._virtual, KeyConstants._physical, false, "componentMappings", "componentPaths");
Key[] keys = componentMappings.keys();
Struct el;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2048,7 +2048,8 @@ private static void setDatasource(ConfigImpl config, Map<String, DataSource> dat
public static Mapping[] loadCustomTagsMappings(ConfigImpl config, Struct root) {
Mapping[] mappings = null;
try {
Array ctMappings = ConfigUtil.getAsArray("customTagMappings", root);
Array ctMappings = ConfigUtil.getAsArray(root, true, KeyConstants._virtual, KeyConstants._physical, true, "customTagMappings", "customTagPaths");

boolean hasDefault = false;

// Web Mapping
Expand Down Expand Up @@ -3509,7 +3510,7 @@ public static Mapping[] loadComponentMappings(ConfigImpl config, Struct root) {
boolean hasSet = false;

// Web Mapping
Array compMappings = ConfigUtil.getAsArray("componentMappings", root);
Array compMappings = ConfigUtil.getAsArray(root, true, KeyConstants._virtual, KeyConstants._physical, false, "componentMappings", "componentPaths");
hasSet = false;
boolean hasDefault = false;
if (compMappings.size() > 0) {
Expand Down
76 changes: 76 additions & 0 deletions core/src/main/java/lucee/runtime/config/ConfigUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -943,6 +943,82 @@ public static Array getAsArray(String name, Struct sct) {
return tmp;
}

/**
* get an array that matches oe of the given key or creates the array in place
*
* @param input struct to look for the names
* @param convertStructToArray if true and the value is a struct, convert it to an array
* @param convertKey if the value is a struct the key of that strcut will be copied to the array
* with that name
* @param stringKey in case the array contains string values and this key is set, create a struct
* containing a key with the string as value
* @param names
* @return
* @throws PageException
*/
public static Array getAsArray(Struct input, boolean convertStructToArray, Key convertKey, Key stringKey, boolean replacePlaceHolder, String... names) {
Array arr = null;
if (input == null) return arr;

Object obj;
for (String name: names) {
obj = input.get(KeyImpl.init(name), null);
if (obj instanceof Array && (arr = (Array) obj).size() > 0) {
if (name != names[0]) {
input.setEL(KeyImpl.init(names[0]), arr);
input.removeEL(KeyImpl.init(name));
}
break;
}
if (arr == null && convertStructToArray && obj instanceof Struct) {
Struct sct = (Struct) obj;
arr = new ArrayImpl();
input.setEL(KeyImpl.init(name), arr);
if (name != names[0]) {
input.setEL(KeyImpl.init(names[0]), arr);
input.removeEL(KeyImpl.init(name));
}
Iterator<Entry<Key, Object>> it = sct.entryIterator();
Entry<Key, Object> e;
Struct s;
Object v;
while (it.hasNext()) {
e = it.next();
v = e.getValue();
if (convertKey != null && v instanceof Struct) {
s = (Struct) v;
if (!s.containsKey(convertKey)) s.setEL(convertKey, e.getKey().getString());
}
arr.appendEL(v);
}
break;
}
}

// validate the array values
if (arr != null && stringKey != null) {
Key[] keys = arr.keys();
Object val;
for (Key k: keys) {
val = arr.get(k, null);
if (val instanceof CharSequence) {
Struct sct = new StructImpl();
sct.setEL(stringKey, val);
arr.setEL(k, sct);
}
}
}
else if (arr == null) {
arr = new ArrayImpl();
input.setEL(KeyImpl.init(names[0]), arr);
return arr;
}

if (replacePlaceHolder) return (Array) replaceConfigPlaceHolders(arr);

return arr;
}

public static String getAsString(String name, Struct sct, String defaultValue) {
if (sct == null) return defaultValue;
Object obj = sct.get(KeyImpl.init(name), null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3007,6 +3007,7 @@ public class KeyConstants {
public static final Key _stream = KeyImpl._const("stream");
public static final Key _temperature = KeyImpl._const("temperature");
public static final Key _purpose = KeyImpl._const("purpose");
public static final Key _physical = KeyImpl._const("physical");

private static Map<String, Key> _____keys;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ component output="false" extends="HelperBase" accessors="true"{

if(structKeyExists(arguments,"sql") && len(arguments.sql)){
this.setSql(arguments.sql);
trace type="warning" var="arguments.sql";
// trace type="warning" var="arguments.sql";
}

//parse the sql into an array and save it
Expand Down
2 changes: 1 addition & 1 deletion loader/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<project default="core" basedir="." name="Lucee"
xmlns:resolver="antlib:org.apache.maven.resolver.ant">

<property name="version" value="7.0.0.74-SNAPSHOT"/>
<property name="version" value="7.0.0.75-SNAPSHOT"/>

<taskdef uri="antlib:org.apache.maven.resolver.ant" resource="org/apache/maven/resolver/ant/antlib.xml">
<classpath>
Expand Down
2 changes: 1 addition & 1 deletion loader/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<groupId>org.lucee</groupId>
<artifactId>lucee</artifactId>
<version>7.0.0.74-SNAPSHOT</version>
<version>7.0.0.75-SNAPSHOT</version>
<packaging>jar</packaging>

<name>Lucee Loader Build</name>
Expand Down
47 changes: 37 additions & 10 deletions test/tickets/LDEV0224_1.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ component extends="org.lucee.cfml.test.LuceeTestCase" labels="qoq"{
}

function run( testResults , testBox ) {
describe( title='selecting 2 rows from QoQ' , body=function() {
//describe( title='selecting 2 rows from QoQ' , body=function() {
describe( title='is possible using a hard coded list' , body=function() {
it( title='of numerics' , body=function( currentSpec ) {
var actual = QueryExecute(
Expand All @@ -28,6 +28,7 @@ component extends="org.lucee.cfml.test.LuceeTestCase" labels="qoq"{
"
);
expect( actual.RecordCount ).toBe( ListLen( interestingNumbersAsAList , ',' ) );
expect( queryColumnData( actual, "id" ).toList() ).toBe( interestingNumbersAsAList );
});

it( title='of strings' , body=function( currentSpec ) {
Expand All @@ -44,11 +45,12 @@ component extends="org.lucee.cfml.test.LuceeTestCase" labels="qoq"{
"
);
expect( actual.RecordCount ).toBe( ListLen( interestingStringsAsAQuotedList , ',' ) );
expect( queryColumnData( actual, "value" ).toList() ).toBe( interestingStringsAsAList );
});
});

describe( title='using param list=true' , body=function() {
describe( title='with new Query()' , body=function() {
//describe( title='using param list=true' , body=function() {
describe( title='using param list=true, with new Query()' , body=function() {
beforeEach( function( currentSpec ) {
q = new Query(
dbtype = 'query',
Expand All @@ -64,9 +66,11 @@ component extends="org.lucee.cfml.test.LuceeTestCase" labels="qoq"{
value
FROM queryWithDataIn
WHERE id IN ( :needle )
ORDER BY ID
" ).getResult();

expect( actual.RecordCount ).toBe( ListLen( interestingNumbersAsAList , ',' ) );
expect( queryColumnData( actual, "id" ).toList() ).toBe( interestingNumbersAsAList );
});

it( title='when using numeric params and a custom separator' , body=function( currentSpec ) {
Expand All @@ -77,9 +81,11 @@ component extends="org.lucee.cfml.test.LuceeTestCase" labels="qoq"{
value
FROM queryWithDataIn
WHERE id IN ( :needle )
ORDER BY ID
" ).getResult();

expect( actual.RecordCount ).toBe( ListLen( interestingNumbersAsAList , ',' ) );
expect( queryColumnData( actual, "id" ).toList() ).toBe( interestingNumbersAsAList );
});

it( title='when using string params' , body=function( currentSpec ) {
Expand All @@ -90,12 +96,14 @@ component extends="org.lucee.cfml.test.LuceeTestCase" labels="qoq"{
value
FROM queryWithDataIn
WHERE value IN ( :needle )
ORDER BY ID
" ).getResult();
expect( actual.RecordCount ).toBe( ListLen( interestingStringsAsAList , ',' ) );
expect( queryColumnData( actual, "value" ).toList() ).toBe( interestingStringsAsAList );
});
});

describe( title='with query{} ( cfquery )' , body=function() {
describe( title='using param list=true, with query{} ( cfquery )' , body=function() {
it( title='when using numeric params' , body=function( currentSpec ) {
query
name = 'actual'
Expand All @@ -111,9 +119,12 @@ component extends="org.lucee.cfml.test.LuceeTestCase" labels="qoq"{
value = interestingNumbersAsAList
sqltype = 'integer'
list = true;
WriteOutput( " )" );
WriteOutput( " )
ORDER BY ID
" );
}
expect( actual.RecordCount ).toBe( ListLen( interestingNumbersAsAList , ',' ) );
expect( queryColumnData( actual, "id" ).toList() ).toBe( interestingNumbersAsAList );
});

it( title='when using numeric params and a custom separator' , body=function( currentSpec ) {
Expand All @@ -132,9 +143,12 @@ component extends="org.lucee.cfml.test.LuceeTestCase" labels="qoq"{
sqltype = 'integer'
list = true
separator = '|';
WriteOutput( " )" );
WriteOutput( " )
ORDER BY ID
" );
}
expect( actual.RecordCount ).toBe( ListLen( interestingNumbersAsAList , ',' ) );
expect( queryColumnData( actual, "id" ).toList() ).toBe( interestingNumbersAsAList );
});

it( title='when using string params' , body=function( currentSpec ) {
Expand All @@ -152,14 +166,17 @@ component extends="org.lucee.cfml.test.LuceeTestCase" labels="qoq"{
value = interestingStringsAsAList
sqltype = 'varchar'
list = true;
WriteOutput( " )" );
WriteOutput( " )
ORDER BY ID
" );
}
expect( actual.RecordCount ).toBe( ListLen( interestingStringsAsAList , ',' ) );
expect( queryColumnData( actual, "value" ).toList() ).toBe( interestingStringsAsAList );
});

});

describe( title='with QueryExecute' , body=function() {
describe( title='using param list=true, with QueryExecute' , body=function() {
it( title='when using an array of numeric params' , body=function( currentSpec ) {
var actual = QueryExecute(
params = [
Expand All @@ -174,9 +191,11 @@ component extends="org.lucee.cfml.test.LuceeTestCase" labels="qoq"{
value
FROM queryWithDataIn
WHERE id IN ( :needle )
ORDER BY ID
"
);
expect( actual.RecordCount ).toBe( ListLen( interestingNumbersAsAList , ',' ) );
expect( queryColumnData( actual, "id" ).toList() ).toBe( interestingNumbersAsAList );
});

it( title='when using a struct of numeric params' , body=function( currentSpec ) {
Expand All @@ -193,9 +212,11 @@ component extends="org.lucee.cfml.test.LuceeTestCase" labels="qoq"{
value
FROM queryWithDataIn
WHERE id IN ( :needle )
ORDER BY ID
"
);
expect( actual.RecordCount ).toBe( ListLen( interestingNumbersAsAList , ',' ) );
expect( queryColumnData( actual, "id" ).toList() ).toBe( interestingNumbersAsAList );
});

it( title='when using an array of string params' , body=function( currentSpec ) {
Expand All @@ -212,9 +233,11 @@ component extends="org.lucee.cfml.test.LuceeTestCase" labels="qoq"{
value
FROM queryWithDataIn
WHERE value IN ( :needle )
ORDER BY ID
"
);
expect( actual.RecordCount ).toBe( ListLen( interestingStringsAsAList , ',' ) );
expect( queryColumnData( actual, "value" ).toList() ).toBe( interestingStringsAsAList );
});

it( title='when using a struct of string params' , body=function( currentSpec ) {
Expand All @@ -231,9 +254,11 @@ component extends="org.lucee.cfml.test.LuceeTestCase" labels="qoq"{
value
FROM queryWithDataIn
WHERE value IN ( :needle )
ORDER BY ID
"
);
expect( actual.RecordCount ).toBe( ListLen( interestingStringsAsAList , ',' ) );
expect( queryColumnData( actual, "value" ).toList() ).toBe( interestingStringsAsAList );
});

it( title='when using numeric params and a custom separator' , body=function( currentSpec ) {
Expand All @@ -250,12 +275,14 @@ component extends="org.lucee.cfml.test.LuceeTestCase" labels="qoq"{
value
FROM queryWithDataIn
WHERE id IN ( :needle )
ORDER BY ID
"
);
expect( actual.RecordCount ).toBe( ListLen( interestingNumbersAsAList , ',' ) );
expect( queryColumnData( actual, "id" ).toList() ).toBe( interestingNumbersAsAList );
});
});
});
});
// });
//});
}
}
Loading

0 comments on commit 9fb8d36

Please sign in to comment.