Skip to content

Commit

Permalink
PRESIDECMS-2772 Allow forcing version number in updateLatestVersionWi…
Browse files Browse the repository at this point in the history
…thNonVersionedChangesWithFilters
  • Loading branch information
Pixl8RusselCole committed Jan 26, 2024
1 parent 108c4ab commit 0e79842
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
14 changes: 8 additions & 6 deletions system/services/presideObjects/PresideObjectService.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -772,6 +772,7 @@ component displayName="Preside Object Service" {
, boolean calculateChangedData = false
, struct changedData = {}
, numeric timeout = _getDefaultTimeout()
, string forceNonVersionChangesVersionNumber = ""
) autodoc=true {
var interceptorResult = _announceInterception( "preUpdateObjectData", arguments );

Expand Down Expand Up @@ -910,12 +911,13 @@ component displayName="Preside Object Service" {
);
} else if ( hasAnyFilters ) {
_getVersioningService().updateLatestVersionWithNonVersionedChangesWithFilters(
objectName = arguments.objectName
, data = cleanedData
, filter = arguments.filter
, filterParams = arguments.filterParams
, extraFilters = arguments.extraFilters
, savedFilters = arguments.savedFilters
objectName = arguments.objectName
, data = cleanedData
, filter = arguments.filter
, filterParams = arguments.filterParams
, extraFilters = arguments.extraFilters
, savedFilters = arguments.savedFilters
, forceVersionNumber = arguments.forceNonVersionChangesVersionNumber
);
}
}
Expand Down
16 changes: 11 additions & 5 deletions system/services/presideObjects/VersioningService.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -285,17 +285,19 @@ component {
public numeric function updateLatestVersionWithNonVersionedChangesWithFilters(
required string objectName
, required struct data
, any filter = {}
, struct filterParams = {}
, array extraFilters = []
, array savedFilters = []
, any filter = {}
, struct filterParams = {}
, array extraFilters = []
, array savedFilters = []
, string forceVersionNumber = ""
) {
var poService = $getPresideObjectService();
var versionObjectName = poService.getVersionObjectName( arguments.objectName );
var useDrafts = objectUsesDrafts( arguments.objectName );
var versionExtraFilters = duplicate( arguments.extraFilters );
var versionFilter = "";
var versionParams = { _version_is_latest=true };
var versionData = duplicate( arguments.data );

if ( useDrafts ) {
versionFilter = "_version_is_latest = :_version_is_latest or _version_is_latest_draft = :_version_is_latest_draft";
Expand All @@ -304,14 +306,18 @@ component {
versionFilter = "_version_is_latest = :_version_is_latest";
}

if ( Len( arguments.forceVersionNumber ?: "" ) ) {
versionData._version_number = arguments.forceVersionNumber;
}

arrayAppend( versionExtraFilters, {
filter = versionFilter
, filterParams = versionParams
} );

poService.updateData(
objectName = versionObjectName
, data = arguments.data
, data = versionData
, filter = arguments.filter
, filterParams = arguments.filterParams
, extraFilters = versionExtraFilters
Expand Down

0 comments on commit 0e79842

Please sign in to comment.