Skip to content

Commit

Permalink
Merge branch 'hotfix-10.27.23' into stable
Browse files Browse the repository at this point in the history
  • Loading branch information
DominicWatson committed Dec 2, 2024
2 parents f179bd8 + 5f9eed7 commit 0dc2c68
Show file tree
Hide file tree
Showing 18 changed files with 187 additions and 140 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/autobuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- cfengine: "[email protected]"
jdkVersion: "11"
experimental: false
- cfengine: "lucee@^6.1.1-SNAPSHOT"
- cfengine: "lucee@^6.2.0-SNAPSHOT"
jdkVersion: "21"
experimental: true
continue-on-error: ${{ matrix.experimental }}
Expand Down
6 changes: 4 additions & 2 deletions system/handlers/admin/TaskManager.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
component extends="preside.system.base.AdminHandler" {

property name="taskManagerService" inject="taskManagerService";
property name="cronUtil" inject="cronUtil";
property name="i18n" inject="i18n";
property name="logRendererUtil" inject="logRendererUtil";
property name="taskHistoryDao" inject="presidecms:object:taskmanager_task_history";
property name="systemConfigurationService" inject="systemConfigurationService";
Expand All @@ -23,7 +25,7 @@ component extends="preside.system.base.AdminHandler" {

public void function index( event, rc, prc ) {
prc.activeTaskGroup = 1;
prc.taskGroups = taskManagerService.getAllTaskDetails();
prc.taskGroups = taskManagerService.getAllTaskDetails( i18n.getFWLanguageCode() );
prc.autoRunningEnabled = systemConfigurationService.getSetting( "taskmanager", "scheduledtasks_enabled", false );

if ( len( rc.tab ?: "" ) ) {
Expand Down Expand Up @@ -105,7 +107,7 @@ component extends="preside.system.base.AdminHandler" {
var formName = "taskmanager.task_configuration";
var formData = event.getCollectionForForm( formName );
var validationResult = validateForm( formName, formData );
var crontabError = taskManagerService.getValidationErrorMessageForPotentiallyBadCrontabExpression( formData.crontab_definition ?: "" );
var crontabError = cronUtil.validateExpression( formData.crontab_definition ?: "" );

if ( Len( Trim( crontabError ) ) ) {
validationResult.addError( fieldName="crontab_definition", message=crontabError );
Expand Down
9 changes: 5 additions & 4 deletions system/handlers/admin/datamanager/saved_export.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ component {
property name="customizationService" inject="dataManagerCustomizationService";
property name="datamanagerService" inject="datamanagerService";
property name="messageBox" inject="messagebox@cbmessagebox";
property name="taskManagerService" inject="taskManagerService";
property name="cronUtil" inject="cronUtil";
property name="i18n" inject="i18n";
property name="dataExportTemplateService" inject="dataExportTemplateService";
property name="formsService" inject="FormsService";

Expand All @@ -34,7 +35,7 @@ component {

for ( var record in records ) {
querySetCell( records, "label", _decorateLabelForListing( record.id ), queryCurrentRow( records ) );
querySetCell( records, "schedule", scheduledExportService.cronExpressionToHuman( record.schedule ), queryCurrentRow( records ) );
querySetCell( records, "schedule", cronUtil.describeCronTabExression( record.schedule, i18n.getFwLanguageCode() ), queryCurrentRow( records ) );
}
}

Expand Down Expand Up @@ -84,7 +85,7 @@ component {
var formData = args.formData ?: {};

if ( len( formData.schedule ?: "" ) && formData.schedule != "disabled" ) {
var scheduleValidationMessage = taskManagerService.getValidationErrorMessageForPotentiallyBadCrontabExpression( formData.schedule );
var scheduleValidationMessage = cronUtil.validateExpression( formData.schedule );

if ( len( trim( scheduleValidationMessage ) ) ) {
args.validationResult.addError( fieldName="schedule", message=scheduleValidationMessage );
Expand Down Expand Up @@ -129,7 +130,7 @@ component {
if ( !isEmpty( args.record.schedule ?: "" ) && ( args.record.schedule neq "disabled" ) ) {
args.exportSchedule = {
raw = args.record.schedule
, readable = scheduledExportService.cronExpressionToHuman( args.record.schedule )
, readable = cronUtil.describeCronTabExression( args.record.schedule, i18n.getFwLanguageCode() )
};

if ( !isEmptyString( args.exportSchedule.readable ?: "" ) ) {
Expand Down
5 changes: 3 additions & 2 deletions system/handlers/formcontrols/CronPicker.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
* @feature presideForms
*/
component {
property name="scheduledExportService" inject="ScheduledExportService";
property name="cronUtil" inject="cronUtil";
property name="i18n" inject="i18n";

private string function index( event, rc, prc, args={} ) {
var inputName = args.name ?: "";
Expand Down Expand Up @@ -35,7 +36,7 @@ component {
var expression = rc.expression ?: "";

if ( !isEmpty( expression ) ) {
return scheduledExportService.cronExpressionToHuman( expression );
return cronUtil.describeCronTabExression( expression, i18n.getFWLanguageCode() );
}
return "";
}
Expand Down
12 changes: 10 additions & 2 deletions system/handlers/formcontrols/TimeZoneSelect.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ component {

public string function index( event, rc, prc, args={} ) {
var defaultToSystemTimezone = isTrue( args.defaultToSystemTimezone ?: "" );
var systemTimeZone = getTimezone();
var systemTimeZone = _getTimezoneName();
var timeZones = timeZoneSelectService.getTimeZones();

args.values = [ "" ];
args.labels = [ "" ];

Expand All @@ -24,4 +24,12 @@ component {
return renderView( view="/formcontrols/select/index", args=args );
}

// necessary because Lucee 5 -> 6 has incompatible change due to
// ACF introducing a different getTimeZone() function which we
// used to use
private function _getTimezoneName() {
var tzInfo = getTimezoneInfo();

return tzInfo.id;
}
}
55 changes: 15 additions & 40 deletions system/services/dataExport/ScheduledExportService.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@
*/
component {
/**
* @threadUtil.inject threadUtil
* @threadUtil.inject threadUtil
* @cronUtil.inject cronUtil
*/
public any function init(
required any threadUtil
, required any cronUtil
) {
_setThreadUtil( arguments.threadUtil );
_setCronUtil( arguments.cronUtil );

_setMachineId();
_setRunningExports({});
Expand Down Expand Up @@ -102,31 +105,13 @@ component {
var detail = getExportDetail( arguments.recordId );

if ( !isEmpty( detail ) and !isEmpty( detail.schedule ?: "" ) ) {
$getPresideObject( "saved_export" ).updateData( id=arguments.recordId, data={ next_run=getNextRunDate( detail.schedule ) } );
$getPresideObject( "saved_export" ).updateData( id=arguments.recordId, data={ next_run=_getCronUtil().getNextRunDate( detail.schedule ) } );
}
} catch (any e) {
$raiseError( e );
}
}

public string function getNextRunDate( required string schedule, date lastRun=now() ) {
if ( !Len( Trim( arguments.schedule ) ) || arguments.schedule == "disabled" ) {
return "";
}

var cronTabExpression = _getCrontabExpressionObject( arguments.schedule );
var lastRunJodaTime = _createJodaTimeObject( arguments.lastRun );

return cronTabExpression.nextTimeAfter( lastRunJodaTime ).toDate();
}

public string function cronExpressionToHuman( required string expression ) {
if ( arguments.expression == "disabled" ) {
return "Disabled";
}
return CreateObject( "java", "net.redhogs.cronparser.CronExpressionDescriptor", _getLib() ).getDescription( arguments.expression );
}

public void function sendScheduledExports() {
var nonRunningExports = $getPresideObject( "saved_export" ).selectData(
selectFields = [ "id" ]
Expand Down Expand Up @@ -209,7 +194,7 @@ component {
id = arguments.exportId
, data = {
is_running = true
, next_run = ( ( exportDetail.schedule ?: "" ) eq "disabled" ) ? "" : getNextRunDate( exportDetail.schedule ?: "" )
, next_run = ( ( exportDetail.schedule ?: "" ) eq "disabled" ) ? "" : _getCronUtil().getNextRunDate( exportDetail.schedule ?: "" )
, running_thread = arguments.threadId
, running_machine = _getMachineId()
}
Expand All @@ -233,7 +218,7 @@ component {
, data = {
is_running = false
, last_ran = now()
, next_run = ( ( exportRecord.schedule ?: "" ) eq "disabled" ) ? "" : getNextRunDate( exportRecord.schedule ?: "" )
, next_run = ( ( exportRecord.schedule ?: "" ) eq "disabled" ) ? "" : _getCronUtil().getNextRunDate( exportRecord.schedule ?: "" )
, was_last_run_success = false
, last_run_time_taken = ""
, running_thread = ""
Expand Down Expand Up @@ -264,7 +249,7 @@ component {
, data = {
is_running = false
, last_ran = now()
, next_run = ( ( exportRecord.schedule ?: "" ) eq "disabled" ) ? "" : getNextRunDate( exportRecord.schedule ?: "" )
, next_run = ( ( exportRecord.schedule ?: "" ) eq "disabled" ) ? "" : _getCronUtil().getNextRunDate( exportRecord.schedule ?: "" )
, was_last_run_success = arguments.success
, last_run_time_taken = arguments.timeTaken
, running_thread = ""
Expand Down Expand Up @@ -340,23 +325,6 @@ component {
}

// PRIVATE HELPERS
private array function _getLib() {
return [
"/preside/system/services/taskmanager/lib/cron-parser-2.6-SNAPSHOT.jar"
, "/preside/system/services/taskmanager/lib/commons-lang3-3.3.2.jar"
, "/preside/system/services/taskmanager/lib/joda-time-2.9.4.jar"
, "/preside/system/services/taskmanager/lib/cron-1.0.jar"
];
}

private any function _createJodaTimeObject( required date cfmlDateTime ) {
return CreateObject( "java", "org.joda.time.DateTime", _getLib() ).init( cfmlDateTime );
}

private any function _getCrontabExpressionObject( required string expression ) {
return CreateObject( "java", "fc.cron.CronExpression", _getLib() ).init( arguments.expression );
}

private boolean function _exportIsRunningOnLocalMachine( required any task ){
var runningTasks = _getRunningExports();
var threadRef = runningTasks[ task.running_thread ].thread ?: NullValue();
Expand Down Expand Up @@ -396,4 +364,11 @@ component {
private void function _setThreadUtil( required any threadUtil ) {
_threadUtil = arguments.threadUtil;
}

private any function _getCronUtil() {
return _cronUtil;
}
private void function _setCronUtil( required any cronUtil ) {
_cronUtil = arguments.cronUtil;
}
}
2 changes: 1 addition & 1 deletion system/services/forms/FormsService.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ component displayName="Forms service" {
public boolean function formExists( required string formName, boolean checkSiteTemplates=true ) {
var forms = _getForms();
var existsInMemory = StructKeyExists( forms, arguments.formName ) || ( arguments.checkSiteTemplates && StructKeyExists( forms, _getSiteTemplatePrefix() & arguments.formName ) );
var isDynamic = !existsInMemory && ReFindNoCase( "^dynamicform\-", arguments.formName );
var isDynamic = !existsInMemory && ReFindNoCase( "^dynamicform\-[a-z0-9]$", arguments.formName );

if ( isDynamic ) {
return _lazyLoadOldDynamicForm( arguments.formName );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ component {
return {
filter = filter.filter ?: {}
, filterParams = filter.filterParams ?: {}
, having = filter.having ?: ""
, extraJoins = filter.extraJoins ?: []
};
}

Expand Down
27 changes: 15 additions & 12 deletions system/services/presideObjects/PresideObjectService.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,14 @@ component displayName="Preside Object Service" {
}
}

args.savedFilterList = [];

var filterService = _getFilterService();

for( var savedFilter in arguments.savedFilters ){
ArrayAppend( args.savedFilterList, filterService.getFilter( savedFilter ) );
}

args.extraFilters.append( _expandSavedFilters( argumentCollection=args ), true );

if ( args.useCache ) {
Expand Down Expand Up @@ -3384,10 +3392,10 @@ component displayName="Preside Object Service" {

private array function _convertObjectJoinsToTableJoins(
required array joins
, array extraJoins = []
, array extraFilters = []
, array savedFilters = []
, struct preparedFilter = {}
, array extraJoins = []
, array extraFilters = []
, array savedFilterList = []
, struct preparedFilter = {}
) {
var tableJoins = [];
var objJoin = "";
Expand Down Expand Up @@ -3430,9 +3438,7 @@ component displayName="Preside Object Service" {

tableJoins.append( arguments.extraJoins, true );

for( var savedFilter in arguments.savedFilters ){
savedFilter = _getFilterService().getFilter( savedFilter );

for( var savedFilter in arguments.savedFilterList ){
if ( IsArray( savedFilter.extraJoins ?: "" ) ) {
tableJoins.append( savedFilter.extraJoins, true );
}
Expand Down Expand Up @@ -3832,13 +3838,10 @@ component displayName="Preside Object Service" {
return _relationshipPathCalcCache[ cacheKey ];
}

private array function _expandSavedFilters( required array savedFilters ) {
private array function _expandSavedFilters( required array savedFilterList ) {
var expanded = [];
var filterService = _getFilterService();

for( var savedFilter in arguments.savedFilters ){
savedFilter = filterService.getFilter( savedFilter );

for( var savedFilter in arguments.savedFilterList ){
expanded.append({
filter = savedFilter.filter ?: {}
, filterParams = savedFilter.filterParams ?: {}
Expand Down
44 changes: 13 additions & 31 deletions system/services/systemAlerts/SystemAlertsService.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ component {

// CONSTRUCTOR
/**
* @validAlertLevels.inject coldbox:setting:enum.systemAlertLevel
* @validAlertLevels.inject coldbox:setting:enum.systemAlertLevel
* @cronUtil.inject cronUtil
*
*/
public any function init( required array validAlertLevels ) {
public any function init( required array validAlertLevels, required any cronUtil ) {
_setValidAlertLevels( arguments.validAlertLevels );
_setCronUtil( arguments.cronUtil );

return this;
}
Expand Down Expand Up @@ -470,38 +472,11 @@ component {
}

private string function _getNextRunDate( required string schedule, date lastRun=now() ) {
var cronTabExpression = _getCrontabExpressionObject( arguments.schedule );
var lastRunJodaTime = _createJodaTimeObject( arguments.lastRun );

return cronTabExpression.nextTimeAfter( lastRunJodaTime ).toDate();
return _getCronUtil().getNextRunDate( arguments.schedule, arguments.lastRun );
}

private boolean function _crontabExpressionIsValid( required string crontabExpression ) {
try {
_getCrontabExpressionObject( arguments.cronTabExpression );
} catch ( any e ) {
$raiseError( e );
return false;
}

return true;
}

private any function _getCrontabExpressionObject( required string expression ) {
return CreateObject( "java", "fc.cron.CronExpression", _getSchedulingLib() ).init( arguments.expression );
}

private any function _createJodaTimeObject( required date cfmlDateTime ) {
return CreateObject( "java", "org.joda.time.DateTime", _getSchedulingLib() ).init( cfmlDateTime );
}

private array function _getSchedulingLib() {
return [
"/preside/system/services/taskmanager/lib/cron-parser-2.6-SNAPSHOT.jar"
, "/preside/system/services/taskmanager/lib/commons-lang3-3.3.2.jar"
, "/preside/system/services/taskmanager/lib/joda-time-2.9.4.jar"
, "/preside/system/services/taskmanager/lib/cron-1.0.jar"
];
return Len( _getCronUtil().validateExpression( arguments.crontabExpression ) ) > 0;
}

// GETTERS AND SETTERS
Expand Down Expand Up @@ -533,4 +508,11 @@ component {
variables._validAlertLevels = arguments.validAlertLevels;
}

private any function _getCronUtil() {
return _cronUtil;
}
private void function _setCronUtil( required any cronUtil ) {
_cronUtil = arguments.cronUtil;
}

}
Loading

0 comments on commit 0dc2c68

Please sign in to comment.