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
42a86ff3
Commit
42a86ff3
authored
Jun 24, 2010
by
Dries
Browse files
- Patch
#561990
by catch, mikeytown2, nnewton: avoid variable_set() and variable_del() stampedes.
parent
41abf46f
Changes
1
Hide whitespace changes
Inline
Side-by-side
includes/bootstrap.inc
View file @
42a86ff3
...
...
@@ -743,13 +743,26 @@ function drupal_get_filename($type, $name, $filename = NULL) {
* file.
*/
function
variable_initialize
(
$conf
=
array
())
{
// NOTE: caching the variables improves performance by 20% when serving cached pages.
// NOTE: caching the variables improves performance by 20% when serving
// cached pages.
if
(
$cached
=
cache_get
(
'variables'
,
'cache_bootstrap'
))
{
$variables
=
$cached
->
data
;
}
else
{
$variables
=
array_map
(
'unserialize'
,
db_query
(
'SELECT name, value FROM {variable}'
)
->
fetchAllKeyed
());
cache_set
(
'variables'
,
$variables
,
'cache_bootstrap'
);
// Cache miss. Avoid a stampede.
$name
=
'variable_init'
;
if
(
!
lock_acquire
(
$name
,
1
))
{
// Another request is building the variable cache.
// Wait, then re-run this function.
lock_wait
(
$name
);
return
variable_initialize
(
$conf
);
}
else
{
// Proceed with variable rebuild.
$variables
=
array_map
(
'unserialize'
,
db_query
(
'SELECT name, value FROM {variable}'
)
->
fetchAllKeyed
());
cache_set
(
'variables'
,
$variables
,
'cache_bootstrap'
);
lock_release
(
$name
);
}
}
foreach
(
$conf
as
$name
=>
$value
)
{
...
...
@@ -2169,6 +2182,10 @@ function _drupal_bootstrap_database() {
function
_drupal_bootstrap_variables
()
{
global
$conf
;
// Initialize the lock system.
require_once
DRUPAL_ROOT
.
'/'
.
variable_get
(
'lock_inc'
,
'includes/lock.inc'
);
lock_initialize
();
// Load variables from the database, but do not overwrite variables set in settings.php.
$conf
=
variable_initialize
(
isset
(
$conf
)
?
$conf
:
array
());
// Load bootstrap modules.
...
...
@@ -2182,10 +2199,6 @@ function _drupal_bootstrap_variables() {
function
_drupal_bootstrap_page_header
()
{
bootstrap_invoke_all
(
'boot'
);
// Prepare for non-cached page workflow.
require_once
DRUPAL_ROOT
.
'/'
.
variable_get
(
'lock_inc'
,
'includes/lock.inc'
);
lock_initialize
();
if
(
!
drupal_is_cli
())
{
ob_start
();
drupal_page_header
();
...
...
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