Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
D
drupal
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Custom Issue Tracker
Custom Issue Tracker
Labels
Merge Requests
220
Merge Requests
220
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Analytics
Analytics
Code Review
Insights
Issue
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
project
drupal
Commits
0bba5d06
Commit
0bba5d06
authored
Oct 26, 2012
by
webchick
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue
#1798222
by Berdir: Fixed Use lock around router rebuild to avoid race condition.
parent
36669878
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
6 deletions
+27
-6
core/lib/Drupal/Core/CoreBundle.php
core/lib/Drupal/Core/CoreBundle.php
+2
-1
core/lib/Drupal/Core/Routing/RouteBuilder.php
core/lib/Drupal/Core/Routing/RouteBuilder.php
+22
-4
core/update.php
core/update.php
+3
-1
No files found.
core/lib/Drupal/Core/CoreBundle.php
View file @
0bba5d06
...
...
@@ -67,7 +67,8 @@ public function build(ContainerBuilder $container) {
$container
->
register
(
'router.dumper'
,
'Drupal\Core\Routing\MatcherDumper'
)
->
addArgument
(
new
Reference
(
'database'
));
$container
->
register
(
'router.builder'
,
'Drupal\Core\Routing\RouteBuilder'
)
->
addArgument
(
new
Reference
(
'router.dumper'
));
->
addArgument
(
new
Reference
(
'router.dumper'
))
->
addArgument
(
new
Reference
(
'lock'
));
$container
->
register
(
'matcher'
,
'Drupal\Core\Routing\ChainMatcher'
);
$container
->
register
(
'legacy_url_matcher'
,
'Drupal\Core\LegacyUrlMatcher'
)
...
...
core/lib/Drupal/Core/Routing/RouteBuilder.php
View file @
0bba5d06
...
...
@@ -7,8 +7,7 @@
namespace
Drupal\Core\Routing
;
use
Symfony\Component\Routing\RouteCompilerInterface
;
use
Symfony\Component\Routing\Route
;
use
Drupal\Core\Lock\LockBackendInterface
;
use
Symfony\Component\Routing\Matcher\Dumper\MatcherDumperInterface
;
/**
...
...
@@ -26,20 +25,38 @@ class RouteBuilder {
*/
protected
$dumper
;
/**
* The used lock backend instance.
*
* @var \Drupal\Core\Lock\LockBackendInterface $lock
*/
protected
$lock
;
/**
* Construcs the RouteBuilder using the passed MatcherDumperInterface.
*
* @param Symfony\Component\Routing\Matcher\Dumper\MatcherDumperInterface $dumper
* @param
\
Symfony\Component\Routing\Matcher\Dumper\MatcherDumperInterface $dumper
* The matcher dumper used to store the route information.
* @param \Drupal\Core\Lock\LockBackendInterface $lock
* The lock backend.
*/
public
function
__construct
(
MatcherDumperInterface
$dumper
)
{
public
function
__construct
(
MatcherDumperInterface
$dumper
,
LockBackendInterface
$lock
)
{
$this
->
dumper
=
$dumper
;
$this
->
lock
=
$lock
;
}
/**
* Rebuilds the route info and dumps to dumper.
*/
public
function
rebuild
()
{
if
(
!
$this
->
lock
->
acquire
(
'router_rebuild'
))
{
// Wait for another request that is already doing this work.
// We choose to block here since otherwise the routes might not be
// available, resulting in a 404.
$this
->
lock
->
wait
(
'router_rebuild'
);
return
;
}
// We need to manually call each module so that we can know which module
// a given item came from.
...
...
@@ -49,6 +66,7 @@ public function rebuild() {
$this
->
dumper
->
addRoutes
(
$routes
);
$this
->
dumper
->
dump
(
array
(
'route_set'
=>
$module
));
}
$this
->
lock
->
release
(
'router_rebuild'
);
}
}
core/update.php
View file @
0bba5d06
...
...
@@ -452,10 +452,12 @@ function update_check_requirements($skip_warnings = FALSE) {
->
setFactoryClass
(
'Drupal\Core\Database\Database'
)
->
setFactoryMethod
(
'getConnection'
)
->
addArgument
(
'default'
);
$container
->
register
(
'lock'
,
'Drupal\Core\Lock\DatabaseLockBackend'
);
$container
->
register
(
'router.dumper'
,
'\Drupal\Core\Routing\MatcherDumper'
)
->
addArgument
(
new
Reference
(
'database'
));
$container
->
register
(
'router.builder'
,
'Drupal\Core\Routing\RouteBuilder'
)
->
addArgument
(
new
Reference
(
'router.dumper'
));
->
addArgument
(
new
Reference
(
'router.dumper'
))
->
addArgument
(
new
Reference
(
'lock'
));
// Turn error reporting back on. From now on, only fatal errors (which are
// not passed through the error handler) will cause a message to be printed.
...
...
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