Skip to content

Commit 00a568a

Browse files
committed
Merge branch 'hotfix-10.27.35' into stable
2 parents bfc0cd3 + 1770fa1 commit 00a568a

File tree

4 files changed

+27
-1
lines changed

4 files changed

+27
-1
lines changed

system/services/presideObjects/VersioningService.cfc

+2-1
Original file line numberDiff line numberDiff line change
@@ -697,7 +697,8 @@ component {
697697
}
698698

699699
if ( StructKeyExists( objMeta.properties, idField ) ) {
700-
objMeta.indexes[ "ix_#arguments.versionedObjectName#_record_id" ] = { unique=false, fields="#idField#,_version_number" };
700+
objMeta.indexes[ "ix_#arguments.versionedObjectName#_record_id_solo" ] = { unique=false, fields=idField };
701+
objMeta.indexes[ "ix_#arguments.versionedObjectName#_record_id" ] = { unique=false, fields="#idField#,_version_number" }; // naming here off, but backwards compatible issue. See https://presidecms.atlassian.net/browse/PRESIDECMS-3022
701702
}
702703
}
703704

system/services/taskmanager/AdHocTaskManagerService.cfc

+4
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,10 @@ component displayName="Ad-hoc Task Manager Service" {
136136
return true;
137137
}
138138

139+
if ( Len( task.web_owner ?: "" ) ) {
140+
$getWebsiteLoginService().spoofUserLoginInBgThread( task.web_owner );
141+
}
142+
139143
if ( task.status == "running" || !markTaskAsRunning( taskId=arguments.taskId ) ) {
140144
$raiseError( error={
141145
type = "AdHoTaskManagerService.task.already.running"

system/services/websiteUsers/WebsiteLoginService.cfc

+18
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,21 @@ component displayName="Website login service" {
8989
return false;
9090
}
9191

92+
/**
93+
* For background threads, allows the thread to assume that a specific user is logged in
94+
*
95+
*/
96+
public function spoofUserLoginInBgThread( required string userId ) {
97+
var user = _getUserDao().selectData(
98+
filter = { id=arguments.userId, active=true }
99+
, useCache = false
100+
);
101+
102+
if ( user.recordCount ) {
103+
request._bgThreadUser = $helpers.queryRowToStruct( user );
104+
}
105+
}
106+
92107
/**
93108
* Impersonates a login
94109
*
@@ -205,6 +220,9 @@ component displayName="Website login service" {
205220
* If no user is logged in, an empty structure will be returned.
206221
*/
207222
public struct function getLoggedInUserDetails() autodoc=true {
223+
if ( $getRequestContext().isBackgroundThread() ) {
224+
return request._bgThreadUser ?: {};
225+
}
208226
var userDetails = _getSessionStorage().getVar( name=_getSessionKey(), default={} );
209227

210228
return !IsNull( local.userDetails ) && IsStruct( userDetails ) ? userDetails : {};

tests/unit/api/websiteUsers/WebsiteLoginServiceTest.cfc

+3
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,7 @@ component output="false" extends="tests.resources.HelperObjects.PresideTestCase"
471471
mockUserDao = getMockbox().createStub();
472472
mockResetDao = getMockbox().createStub();
473473
mockUserLoginTokenDao = getMockbox().createStub();
474+
mockRequestContext = getMockbox().createStub();
474475
mockBCryptService = getMockBox().createEmptyMock( "preside.system.services.encryption.bcrypt.BCryptService" );
475476
mockSysConfigService = getMockBox().createEmptyMock( "preside.system.services.configuration.SystemConfigurationService" );
476477
mockEmailService = getMockBox().createEmptyMock( "preside.system.services.email.EmailService" );
@@ -490,10 +491,12 @@ component output="false" extends="tests.resources.HelperObjects.PresideTestCase"
490491
mockActionsService.$( "promoteVisitorActionsToUserActions", 1 );
491492
service.$( "$recordWebsiteUserAction" );
492493
service.$( "$announceInterception" );
494+
service.$( "$getRequestContext", mockRequestContext );
493495
mockSessionStorage.$( "rotate" );
494496
service.$( "$getPresideObject" ).$args( "website_user_reset_token" ).$results( mockResetDao );
495497
mockResetDao.$( "insertData", 1 );
496498
mockResetDao.$( "deleteData", 1 );
499+
mockRequestContext.$( "isBackgroundThread", false );
497500

498501
return service;
499502
}

0 commit comments

Comments
 (0)