Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion box.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"cbmessagebox":"2.2.0+10",
"cbstorages":"1.3.0+14",
"cbjavaloader":"1.5.0+35",
"coldbox":"5.4.0",
"coldbox":"8.1.0-snapshot",
"cfconcurrent":"3.0.0",
"JSONPrettyPrint":"1.4.1",
"cfflow":"0.8.0"
Expand Down
45 changes: 44 additions & 1 deletion system/coldboxModifications/Controller.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@ component extends="coldbox.system.web.Controller" {
services.routingService = new preside.system.coldboxModifications.services.RoutingService( this );
variables.wireBox = CreateObject( "preside.system.coldboxModifications.ioc.Injector" );
variables.cacheBox = CreateObject( "preside.system.coldboxModifications.cachebox.CacheFactory" );

}

function getRenderer(){
try {
return variables._renderer;
} catch( any e ) {
variables._renderer = variables.wireBox.getInstance( "presideRenderer" );
variables._renderer.startup();
}
return variables._renderer;
}
Expand Down Expand Up @@ -258,9 +260,50 @@ component extends="coldbox.system.web.Controller" {
return getRequestService().getContext();
}

public any function getSetting( required string name, boolean fwSetting=false, any defaultValue ) {
/**
* Compatibility shim: setNextEvent() was removed in ColdBox 7.0.
* Delegates to relocate() which is the replacement.
*/
void function setNextEvent(
event
, URL
, URI
, queryString
, persist
, struct persistStruct
, boolean addToken
, boolean ssl
, baseURL
, boolean postProcessExempt
, numeric statusCode
){
relocate( argumentCollection=arguments );
}

/**
* Compatibility shim: getSettingStructure() was removed in ColdBox 6.0
* Delegates to the configSettings/coldboxSettings structs directly.
*/
public struct function getSettingStructure( boolean fwSetting=false, boolean deepCopyFlag=false ) {
var target = arguments.fwSetting ? variables.coldboxSettings : variables.configSettings;
return arguments.deepCopyFlag ? duplicate( target ) : target;
}

public any function getSetting( required string name, any fwSetting=false, any defaultValue ) {
// CB 6.0+ signature: getSetting( name, defaultValue ). If fwSetting
// is not a boolean, treat it as defaultValue for compatibility.
if ( !IsBoolean( arguments.fwSetting ) ) {
arguments.defaultValue = arguments.fwSetting;
arguments.fwSetting = false;
}
var target = arguments.fwSetting ? variables.coldboxSettings : variables.configSettings;

// CB 6.0 removed viewsRefMap and layoutsRefMap from config settings.
// Preside's custom Renderer still uses them. Lazy-init on first access.
if ( !arguments.fwSetting && ListFindNoCase( "viewsRefMap,layoutsRefMap", arguments.name ) && !StructKeyExists( target, arguments.name ) ) {
target[ arguments.name ] = {};
}

if ( StructKeyExists( target, arguments.name ) ) {
return target[ arguments.name ];
}
Expand Down
2 changes: 1 addition & 1 deletion system/coldboxModifications/DelayedInjectorDsl.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ component implements="coldbox.system.ioc.dsl.IDSLBuilder" {
return this;
}

public any function process( required any definition, any targetObject ) {
public any function process( required any definition, any targetObject, any targetID ) {
var thisType = arguments.definition.dsl;
var thisTypeLen = ListLen( thisType, ":" );
var injectorDsl = "";
Expand Down
88 changes: 88 additions & 0 deletions system/coldboxModifications/EventHandler.cfc
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
/**
* Preside compatibility shim for ColdBox 6.0+
*
* ColdBox 6.0 removed setNextEvent() and getModel() from FrameworkSupertype.
* This shim adds them back so that all Preside handlers continue to work
* without needing to update 400+ call sites.
*/
component extends="coldbox.system.EventHandler" {

/**
* Compatibility: setNextEvent() was removed in ColdBox 6.0.
* Delegates to relocate() which is the replacement.
*/
void function setNextEvent(
event
, URL
, URI
, queryString
, persist
, struct persistStruct
, boolean addToken
, boolean ssl
, baseURL
, boolean postProcessExempt
, numeric statusCode
){
controller.relocate( argumentCollection=arguments );
}

/**
* Compatibility: getModel() was removed in ColdBox 6.0.
* Delegates to getInstance() which is the replacement.
*/
function getModel( name, dsl, initArguments={} ){
return getInstance( argumentCollection=arguments );
}

/**
* CB 8.0: FrameworkSupertype added getSystemSetting(key, defaultValue) which
* shadows Preside's getSystemSetting(category, setting, default) helper.
* Restore Preside's version.
*/
function getSystemSetting(){
return getInstance( "systemConfigurationService" ).getSetting( argumentCollection=arguments );
}

/**
* CB 7.0: renderView() deprecated and no longer returns a value.
* Restore the return so Preside handlers get their rendered content.
*/
function renderView(){
return getRenderer().renderView( argumentCollection=arguments );
}

/**
* CB 7.0: renderLayout() deprecated and no longer returns a value.
* Restore the return so Preside handlers get their rendered content.
*/
function renderLayout(){
return getRenderer().renderLayout( argumentCollection=arguments );
}

/**
* CB 7.0: renderExternalView() deprecated and no longer returns a value.
*/
function renderExternalView(){
return getRenderer().renderExternalView( argumentCollection=arguments );
}

/**
* CB 7.0: layout(), view(), externalView() replaced the render* versions.
* These MUST be private to prevent virtual inheritance from overwriting
* handler-defined private viewlets with the same name (e.g. webflow
* handler's private layout() viewlet). FrameworkSupertype's public
* layout()/view() would otherwise be mixed into the handler's variables
* scope via injectMixin, shadowing the handler's own private method.
*/
private function layout(){
return getRenderer().renderLayout( argumentCollection=arguments );
}
private function view(){
return getRenderer().renderView( argumentCollection=arguments );
}
private function externalView(){
return getRenderer().renderExternalView( argumentCollection=arguments );
}

}
2 changes: 1 addition & 1 deletion system/coldboxModifications/FeatureDependentDsl.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ component implements="coldbox.system.ioc.dsl.IDSLBuilder" {
return this;
}

public any function process( required any definition, any targetObject ) {
public any function process( required any definition, any targetObject, any targetID ) {
var dsl = ListRest( arguments.definition.dsl ?: "", ":" );

if ( ListLen( dsl, ":" ) < 2 ) {
Expand Down
65 changes: 65 additions & 0 deletions system/coldboxModifications/Interceptor.cfc
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/**
* Preside Interceptor shim for ColdBox 6.0+/7.0+
*
* 1. ColdBox 6.0+ moved loadApplicationHelpers() from the constructor to a
* lazy cbLoadInterceptorHelpers event. This shim eagerly loads helpers
* via cbLoadInterceptorHelpers so they're available for startup interceptions.
*
* 2. ColdBox 6.0 removed getModel() from FrameworkSupertype. This shim
* restores it as a passthrough to getInstance().
*/
component extends="coldbox.system.Interceptor" {

/**
* Override cbLoadInterceptorHelpers to ensure helpers are loaded
* immediately when called, restoring CB 5.4 eager-loading behaviour.
*/
function cbLoadInterceptorHelpers( event, interceptData ){
loadApplicationHelpers( force: true );
}

/**
* Compatibility shim: getModel() was removed in ColdBox 6.0
*/
function getModel( name, dsl, initArguments={} ){
return getInstance( argumentCollection=arguments );
}

/**
* CB 8.0: FrameworkSupertype added getSystemSetting(key, defaultValue) which
* shadows Preside's getSystemSetting(category, setting, default) helper.
*/
function getSystemSetting(){
return getInstance( "systemConfigurationService" ).getSetting( argumentCollection=arguments );
}

/**
* CB 7.0: renderView() deprecated and no longer returns a value.
*/
function renderView(){
return getRenderer().renderView( argumentCollection=arguments );
}

function renderLayout(){
return getRenderer().renderLayout( argumentCollection=arguments );
}

function renderExternalView(){
return getRenderer().renderExternalView( argumentCollection=arguments );
}

/**
* CB 7.0: layout(), view(), externalView() replaced the render* versions.
* Private to avoid shadowing interceptor-defined methods of the same name.
*/
private function layout(){
return getRenderer().renderLayout( argumentCollection=arguments );
}
private function view(){
return getRenderer().renderView( argumentCollection=arguments );
}
private function externalView(){
return getRenderer().renderExternalView( argumentCollection=arguments );
}

}
13 changes: 10 additions & 3 deletions system/coldboxModifications/InterceptorState.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -45,25 +45,32 @@ component {

public any function process(
required any event
, required any interceptData
, any data = {}
, any interceptData
, required any buffer
, boolean async = false
, boolean asyncAll = false
, boolean asyncAllJoin = true
, string asyncPriority = "NORMAL"
, numeric asyncJoinTimeout = 0
) {
// ColdBox 6.0+ uses 'data', Preside uses 'interceptData' — normalise
if ( !isNull( arguments.interceptData ) ) {
arguments.data = arguments.interceptData;
}

if ( arguments.async && !instance.utility.inThread() ) {
return processAsync(
event = arguments.event
, interceptData = arguments.interceptData
, interceptData = arguments.data
, asyncPriority = arguments.asyncPriority
, buffer = arguments.buffer
);
} else if ( arguments.asyncAll AND NOT instance.utility.inThread() ) {
arguments.interceptData = arguments.data;
return processAsyncAll( argumentCollection=arguments );
} else {
processSync( event=arguments.event, interceptData=arguments.interceptData, buffer=arguments.buffer );
processSync( event=arguments.event, interceptData=arguments.data, buffer=arguments.buffer );
}
}

Expand Down
2 changes: 1 addition & 1 deletion system/coldboxModifications/LegacyDslBuilder.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ component {
return this;
}

function process( required any definition, targetObject ) {
function process( required any definition, targetObject, targetID ) {
var dsl = arguments.definition.dsl;

if( reFindNoCase( '^coldbox:myplugin:.*', dsl ) ) {
Expand Down
2 changes: 1 addition & 1 deletion system/coldboxModifications/PresideWireboxDsl.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ component implements="coldbox.system.ioc.dsl.IDSLBuilder" {
return this;
}

public any function process( required any definition, any targetObject ) {
public any function process( required any definition, any targetObject, any targetID ) {
var dsl = ListRest( definition.dsl, ":" );
var namespace = ListFirst( dsl, ":" );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,14 @@ component extends="coldbox.system.cache.store.ConcurrentSoftReferenceStore" impl
} );
}

public struct function getCachedObjectMetadata( required any objectKey ) {
var meta = variables.indexer.getObjectMetadata( arguments.objectKey );
if ( IsNull( local.meta ) || !IsStruct( local.meta ) ) {
return {};
}
return meta;
}

public any function clear( required any objectKey ) {
var isSR = variables.indexer.getObjectMetadataProperty( arguments.objectKey, "isSoftReference" );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,14 @@ component extends="coldbox.system.cache.store.ConcurrentStore" implements="" {
} );
}

public struct function getCachedObjectMetadata( required any objectKey ) {
var meta = indexer.getObjectMetadata( arguments.objectKey );
if ( IsNull( local.meta ) || !IsStruct( local.meta ) ) {
return {};
}
return meta;
}

public any function clear( required any objectKey ) {
var removedObj = pool.remove( arguments.objectKey );
var removedMeta = indexer.clear( arguments.objectKey );
Expand Down
19 changes: 18 additions & 1 deletion system/coldboxModifications/cachebox/store/DiskStore.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ component implements="coldbox.system.cache.store.IObjectStore" accessors="true"{
// Prepare instance
variables.cacheProvider = arguments.cacheProvider;
variables.storeID = createObject( 'java', 'java.lang.System' ).identityHashCode( this );
variables.indexer = new coldbox.system.cache.store.indexers.MetadataIndexer( fields );
variables.indexer = new preside.system.coldboxModifications.cachebox.store.indexers.MetadataIndexer( fields );
variables.converter = new coldbox.system.core.conversion.ObjectMarshaller();
variables.directoryPath = "";

Expand Down Expand Up @@ -306,6 +306,23 @@ component implements="coldbox.system.cache.store.IObjectStore" accessors="true"{
return variables.indexer.getSize();
}

/**
* CB 7.0: IObjectStore now requires getSortedKeys()
*/
array function getSortedKeys( required property, sortType="text", sortOrder="asc" ) {
return getKeys();
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getSortedKeys stub ignores sorting requirements for eviction

Low Severity

getSortedKeys() ignores all parameters (property, sortType, sortOrder) and returns unsorted keys via getKeys(). ColdBox cache eviction policies rely on sorted keys (e.g., by lastAccessed or hits) to determine which entries to evict. Returning unsorted keys could cause arbitrary eviction instead of proper LRU/LFU behavior.

Fix in Cursor Fix in Web


/**
* CB 7.0: IObjectStore now requires getCachedObjectMetadata()
*/
struct function getCachedObjectMetadata( required objectKey ){
if ( variables.indexer.objectExists( arguments.objectKey ) ) {
return variables.indexer.getObjectMetadata( arguments.objectKey );
}
return {};
}

//********************************* PRIVATE ************************************//

/**
Expand Down
Loading
Loading