Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
project
drupal
Commits
99fc3faa
Commit
99fc3faa
authored
Nov 11, 2013
by
webchick
Browse files
Issue
#2120505
by tstoeckler, dawehner: Remove MatcherDumper::MAX_PARTS.
parent
c435b714
Changes
3
Hide whitespace changes
Inline
Side-by-side
core/lib/Drupal/Core/Routing/MatcherDumper.php
View file @
99fc3faa
...
...
@@ -16,11 +16,6 @@
*/
class
MatcherDumper
implements
MatcherDumperInterface
{
/**
* The maximum number of path elements for a route pattern;
*/
const
MAX_PARTS
=
9
;
/**
* The database connection to which to dump route information.
*
...
...
core/lib/Drupal/Core/Routing/RouteProvider.php
View file @
99fc3faa
...
...
@@ -181,7 +181,7 @@ public function getRoutesByNames($names, $parameters = array()) {
public
function
getCandidateOutlines
(
array
$parts
)
{
$number_parts
=
count
(
$parts
);
$ancestors
=
array
();
$length
=
$number_parts
-
1
;
$length
=
$number_parts
-
1
;
$end
=
(
1
<<
$number_parts
)
-
1
;
// The highest possible mask is a 1 bit for every part of the path. We will
...
...
@@ -240,9 +240,9 @@ public function getRoutesByPattern($pattern) {
protected
function
getRoutesByPath
(
$path
)
{
// Filter out each empty value, though allow '0' and 0, which would be
// filtered out by empty().
$parts
=
array_
slice
(
array_filter
(
explode
(
'/'
,
$path
),
function
(
$value
)
{
$parts
=
array_
values
(
array_filter
(
explode
(
'/'
,
$path
),
function
(
$value
)
{
return
$value
!==
NULL
&&
$value
!==
''
;
})
,
0
,
MatcherDumper
::
MAX_PARTS
);
}));
$ancestors
=
$this
->
getCandidateOutlines
(
$parts
);
...
...
core/modules/system/lib/Drupal/system/Tests/Routing/RouteProviderTest.php
View file @
99fc3faa
...
...
@@ -397,4 +397,26 @@ protected function testRouteByName() {
$this
->
assertEqual
(
$routes
[
'route_d'
]
->
getPath
(),
'/path/three'
);
}
/**
* Ensures that the routing system is capable of extreme long patterns.
*/
public
function
testGetRoutesByPatternWithLongPatterns
()
{
$connection
=
Database
::
getConnection
();
$provider
=
new
RouteProvider
(
$connection
,
'test_routes'
);
$this
->
fixtures
->
createTables
(
$connection
);
$dumper
=
new
MatcherDumper
(
$connection
,
'test_routes'
);
$collection
=
new
RouteCollection
();
$collection
->
add
(
'long_pattern'
,
new
Route
(
'/test/{v1}/test2/{v2}/test3/{v3}/{v4}/{v5}/{v6}/test4'
));
$dumper
->
addRoutes
(
$collection
);
$dumper
->
dump
();
$result
=
$provider
->
getRoutesByPattern
(
'/test/1/test2/2/test3/3/4/5/6/test4'
);
$this
->
assertEqual
(
$result
->
count
(),
1
);
// We can't compare the values of the routes directly, nor use
// spl_object_hash() because they are separate instances.
$this
->
assertEqual
(
serialize
(
$result
->
get
(
'long_pattern'
)),
serialize
(
$collection
->
get
(
'long_pattern'
)),
'The right route was found.'
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment