Skip to content

Commit f3d0ab3

Browse files
committed
fix: make $applyConstraintToLastRoute public and remove unreliable method-indexed route scan
- Change $applyConstraintToLastRoute from private to public in matching.cfc so Lucee 7's mixin system can resolve calls from public constraint helpers (whereNumber, whereAlpha, etc.) - Remove Fast Path 2 (method-indexed route scan) from Dispatch.cfc which returned stale wildcard routes instead of correct specific routes. Keep Fast Path 1 (static O(1) lookup) and the linear fallback scan. https://claude.ai/code/session_01BwY32HMZKTCitF9f3BSSJL
1 parent 6942400 commit f3d0ab3

File tree

2 files changed

+3
-22
lines changed

2 files changed

+3
-22
lines changed

vendor/wheels/Dispatch.cfc

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -128,27 +128,8 @@ component output="false" extends="wheels.Global"{
128128
}
129129
}
130130

131-
// --- Fast path 2: Method-indexed route scan ---
132-
// Instead of scanning ALL routes, only scan routes registered for this HTTP method.
133-
// For a typical app with 100+ routes across all methods, this reduces the search space by ~5x.
134-
if (!StructKeyExists(local, "rv") && StructKeyExists(application.wheels, "routeIndex") && StructKeyExists(application.wheels.routeIndex, local.methodKey)) {
135-
local.methodRoutes = application.wheels.routeIndex[local.methodKey];
136-
for (local.route in local.methodRoutes) {
137-
// Make sure route has been converted to regular expression.
138-
if (!StructKeyExists(local.route, "regex")) {
139-
local.route.regex = arguments.mapper.$patternToRegex(local.route.pattern);
140-
}
141-
142-
// If route matches regular expression, set it for return.
143-
if (ReFindNoCase(local.route.regex, arguments.path) || (!Len(arguments.path) && local.route.pattern == "/")) {
144-
local.rv = Duplicate(local.route);
145-
break;
146-
}
147-
}
148-
}
149-
150-
// --- Fallback: Full linear scan (backward compatibility) ---
151-
// Used when route indexes are not available (e.g., routes defined outside the mapper).
131+
// --- Fallback: Full linear scan ---
132+
// Scan all routes in registration order, filtering by HTTP method.
152133
if (!StructKeyExists(local, "rv")) {
153134
for (local.route in arguments.routes) {
154135
// If method doesn't match, skip this route.

vendor/wheels/mapper/matching.cfc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,7 @@ component {
527527
* Applies a regex constraint to the specified variable(s) on the most recently added route(s).
528528
* Supports comma-delimited variable names to constrain multiple variables at once.
529529
*/
530-
private struct function $applyConstraintToLastRoute(required string variableName, required string pattern) {
530+
public struct function $applyConstraintToLastRoute(required string variableName, required string pattern) {
531531
local.routeCount = ArrayLen(application[$appKey()].routes);
532532
if (local.routeCount == 0) {
533533
Throw(

0 commit comments

Comments
 (0)