Skip to content

Commit

Permalink
Merge branch 'hotfix-10.24.16' into stable
Browse files Browse the repository at this point in the history
  • Loading branch information
DominicWatson committed Sep 11, 2023
2 parents 106644d + e1ffe5d commit 8b5ce02
Show file tree
Hide file tree
Showing 14 changed files with 404 additions and 37 deletions.
1 change: 1 addition & 0 deletions system/coldboxModifications/RequestContextDecorator.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -1176,6 +1176,7 @@ component accessors=true extends="preside.system.coldboxModifications.RequestCon
// Threading
public boolean function isBackgroundThread( boolean value ) {
if ( structKeyExists( arguments, "value" ) ) {
request.__isbgthread = arguments.value;
getRequestContext().setValue( name="_isBackgroundThread", value=arguments.value, private=true );
}
return getRequestContext().getValue( name="_isBackgroundThread", defaultValue=false, private=true );
Expand Down
10 changes: 8 additions & 2 deletions system/config/Config.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,7 @@ component {
, systemInformation = [ "navigate" ]
, urlRedirects = [ "navigate", "read", "addRule", "editRule", "deleteRule" ]
, formbuilder = [ "navigate", "addform", "editform", "deleteForm" ,"lockForm", "activateForm", "deleteSubmissions", "editformactions" ]
, formquestions = [ "navigate", "read", "add", "edit", "delete", "batchdelete", "batchedit", "clone" ]
, formquestions = [ "navigate", "read", "add", "edit", "delete", "batchdelete", "batchedit", "clone", "managefilters", "usefilters" ]
, taskmanager = [ "navigate", "run", "toggleactive", "viewlogs", "configure" ]
, adhocTaskManager = [ "navigate", "viewtask", "canceltask" ]
, savedExport = [ "navigate", "read", "add", "edit", "delete" ]
Expand Down Expand Up @@ -726,6 +726,11 @@ component {
settings.autoRestoreDeprecatedFields = true;
settings.useQueryCacheDefault = true;
settings.mssql = { useVarcharMaxForText = false }

settings.queryTimeout = {
default = Val( settings.env.QUERY_TIMEOUT ?: 0 )
, backgroundThreadDefault = Val( settings.env.BACKGROUND_QUERY_TIMEOUT ?: ( settings.env.QUERY_TIMEOUT ?: 0 ) )
};
}

private void function __setupGlobalDataFilters() {
Expand Down Expand Up @@ -961,7 +966,8 @@ component {
};

settings.csrf = {
tokenExpiryInSeconds = 1200
tokenExpiryInSeconds = 1200
, authenticatedSessionsOnly = IsBoolean( settings.env.CSRF_AUTHENTICATED_ONLY ?: "" ) && settings.env.CSRF_AUTHENTICATED_ONLY
};
}

Expand Down
1 change: 1 addition & 0 deletions system/handlers/admin/DataManager.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -2845,6 +2845,7 @@ component extends="preside.system.base.AdminHandler" {
, adminOwner = event.getAdminUserId()
, title = "cms:datamanager.batchdelete.task.title"
, returnUrl = event.buildAdminLink( objectName=objectName, operation="listing" )
, resultUrl = postActionUrl
, discardAfterInterval = CreateTimeSpan( 0, 0, 5, 0 )
, args = {
objectName = objectName
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/**
* Dynamic expression handler for checking whether or not a preside object
* record matches one or more specific Ids
*
*/
component extends="preside.system.base.AutoObjectExpressionHandler" {

property name="presideObjectService" inject="presideObjectService";

private boolean function evaluateExpression(
required string objectName
, string value = ""
, boolean _is = true
) {
return presideObjectService.dataExists(
objectName = arguments.objectName
, id = payload[ arguments.objectName ].id ?: ""
, extraFilters = prepareFilters( argumentCollection=arguments )
);
}

private array function prepareFilters(
required string objectName
, string value = ""
, boolean _is = true
){
var paramName = "recordMatchesId" & CreateUUId().lCase().replace( "-", "", "all" );
var operator = _is ? "in" : "not in";
var filterSql = "#arguments.objectName#.id #operator# (:#paramName#)";
var params = { "#paramName#" = { value=arguments.value, type="cf_sql_varchar", list=true } };

return [ { filter=filterSql, filterParams=params } ];
}

private string function getLabel(
required string objectName
) {
var objectLabelSingular = translateObjectName( arguments.objectName );

return translateResource( uri="rules.dynamicExpressions:recordMatchesId.label", data=[ objectLabelSingular ] );
}

private string function getText(
required string objectName

){
var objectLabelSingular = translateObjectName( arguments.objectName );

return translateResource( uri="rules.dynamicExpressions:recordMatchesId.text", data=[ objectLabelSingular ] );
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ component extends="preside.system.base.AutoObjectExpressionHandler" {
}
}
if ( Len( enumFilterSql ) ) {
filterSql = "( #filterSql# ) #enumDelim# ( #enumFilterSql# )";
filterSql = "( ( #filterSql# ) #enumDelim# ( #enumFilterSql# ) )";
}
}

Expand Down
4 changes: 4 additions & 0 deletions system/i18n/rules/dynamicExpressions.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ recordMatchesFilters.label={1} matches saved filters
recordMatchesFilters.text={1} {_does} match the selected filter(s): {value}
recordMatchesFilters.value.default.label=select filter(s)

recordMatchesId.label={1} matches specific records
recordMatchesId.text= {_is} one of the following: {value}
recordMatchesId.value.default.label=select record(s)

PropertyIsNull.isEmpty.label={1} is empty
PropertyIsNull.isEmpty.text={1} {_is} empty
PropertyIsNull.isSet.label={1} is set
Expand Down
3 changes: 3 additions & 0 deletions system/i18n/rules/dynamicExpressions_de.properties
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,6 @@ translationExists.value.default.label=bitte w\u00E4hlen Sie mindestens eine Spra
translationExists.savedFilter.default.label=Filter ausw\u00E4hlen
related.translationExists.label={3}: {2} \u00DCbersetzungen in bestimmte Sprachen
related.translationExists.text={2}: {_possesses} \u00DCbersetzungen f\u00FCr {value}, die dem optionalen Filter entsprechen: {savedFilter}
recordMatchesId.label={1} passt zu bestimmten Datens\u00E4tzen
recordMatchesId.text={1} {_is} einer dieser Datens\u00E4tze: {value}
recordMatchesId.value.default.label=Wert(e) ausw\u00E4hlen
50 changes: 42 additions & 8 deletions system/services/database/SqlRunner.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,31 @@ component singleton=true {

// CONSTRUCTOR
/**
* @logger.inject defaultLogger
* @logger.inject defaultLogger
* @defaultQueryTimeout.inject coldbox:setting:queryTimeout.default
* @defaultBgQueryTimeout.inject coldbox:setting:queryTimeout.backgroundThreadDefault
*/
public any function init( required any logger ) output=false {
public any function init(
required any logger
, numeric defaultQueryTimeout = 0
, numeric defaultBgQueryTimeout = 0
) {
_setLogger( arguments.logger );
_setDefaultQueryTimeout( arguments.defaultQueryTimeout );
_setDefaultBgQueryTimeout( arguments.defaultBgQueryTimeout );

return this;
}

// PUBLIC API METHODS
public any function runSql(
required string sql
, required string dsn
, array params
, string returntype = "recordset"
, string columnKey = ""
) output=false {
required string sql
, required string dsn
, array params
, string returntype = "recordset"
, string columnKey = ""
, numeric timeout = _getDefaultTimeout()
) {
var result = "";
var params = {};
var options = { datasource=arguments.dsn, name="result" };
Expand All @@ -36,6 +45,10 @@ component singleton=true {
options.columnKey = arguments.columnKey;
}

if ( arguments.timeout > 0 ) {
options.timeout = arguments.timeout;
}

if ( StructKeyExists( arguments, "params" ) ) {
for( var param in arguments.params ){
param.value = param.value ?: "";
Expand Down Expand Up @@ -133,11 +146,32 @@ component singleton=true {
return matched;
}

private numeric function _getDefaultTimeout() {
if ( StructKeyExists( request, "__isbgthread" ) && IsBoolean( request.__isbgthread ) && request.__isbgthread ) {
return _getDefaultBgQueryTimeout();
}
return _getDefaultQueryTimeout();
}

// GETTERS AND SETTERS
private any function _getLogger() output=false {
return _logger;
}
private void function _setLogger( required any logger ) output=false {
_logger = arguments.logger;
}

private numeric function _getDefaultQueryTimeout() {
return _defaultQueryTimeout;
}
private void function _setDefaultQueryTimeout( required numeric defaultQueryTimeout ) {
_defaultQueryTimeout = arguments.defaultQueryTimeout;
}

private numeric function _getDefaultBgQueryTimeout() {
return _defaultBgQueryTimeout;
}
private void function _setDefaultBgQueryTimeout( required numeric defaultBgQueryTimeout ) {
_defaultBgQueryTimeout = arguments.defaultBgQueryTimeout;
}
}
Loading

0 comments on commit 8b5ce02

Please sign in to comment.