Skip to content

Commit b055f90

Browse files
committed
- Updates for MySQL indexes on version 8+ and index keys to avoid max key length issues with long VARCHAR fields. The DBLogger model now creates indexes with a 255 character prefix for userAgent, host, path, and referer fields when using MySQL to prevent exceeding the 3072 byte key limit.
1 parent 13fb5df commit b055f90

3 files changed

Lines changed: 12 additions & 2 deletions

File tree

box.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name":"ColdBox Security",
3-
"version":"3.8.0",
3+
"version":"3.7.2",
44
"location":"https://downloads.ortussolutions.com/ortussolutions/coldbox-modules/cbsecurity/@build.version@/cbsecurity-@build.version@.zip",
55
"author":"Ortus Solutions.com <info@ortussolutions.com>",
66
"slug":"cbsecurity",

changelog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
## [Unreleased]
1111

12+
### 🐛 Fixed
13+
14+
- Updates for MySQL indexes on version 8+ and index keys to avoid max key length issues with long VARCHAR fields. The `DBLogger` model now creates indexes with a 255 character prefix for `userAgent`, `host`, `path`, and `referer` fields when using MySQL to prevent exceeding the 3072 byte key limit.
15+
1216
## [3.7.1] - 2026-05-21
1317

1418
### Fixed

models/util/DBLogger.cfc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,8 +449,14 @@ component accessors="true" singleton threadsafe {
449449
];
450450

451451
indexColumns.each( ( key ) => {
452+
var indexDefinition = "#key#";
453+
// For MySQL, limit VARCHAR(1024) index prefix to avoid exceeding 3072 byte key limit
454+
var longVarcharCols = [ "userAgent", "host", "path", "referer" ];
455+
if ( getDatabaseVendor() == "MySQL" && longVarcharCols.find( key ) > 0 ) {
456+
indexDefinition = "#key#(255)";
457+
}
452458
queryExecute(
453-
"CREATE INDEX idx_cbsecurity_#key# ON #getTable()# (#key#)",
459+
"CREATE INDEX idx_cbsecurity_#key# ON #getTable()# (#indexDefinition#)",
454460
{},
455461
{ datasource : variables.settings.firewall.logs.dsn }
456462
);

0 commit comments

Comments
 (0)