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
4f8168c3
Commit
4f8168c3
authored
Nov 29, 2008
by
webchick
Browse files
#338184
by Damien Tournoud: Remove special workarounds for serialize() in the registry.
parent
bc719d0c
Changes
2
Hide whitespace changes
Inline
Side-by-side
includes/bootstrap.inc
View file @
4f8168c3
...
...
@@ -1480,7 +1480,10 @@ function _registry_check_code($type, $name = NULL) {
static
$lookup_cache
,
$cache_update_needed
;
if
(
!
isset
(
$lookup_cache
))
{
$lookup_cache
=
_registry_get_lookup_cache
();
$lookup_cache
=
array
();
if
(
$cache
=
cache_get
(
'lookup_cache'
,
'cache_registry'
))
{
$lookup_cache
=
$cache
->
data
;
}
}
// When we rebuild the registry, we need to reset this cache so
...
...
@@ -1495,7 +1498,7 @@ function _registry_check_code($type, $name = NULL) {
// changes to the lookup cache for this request.
if
(
$type
==
REGISTRY_WRITE_LOOKUP_CACHE
)
{
if
(
$cache_update_needed
)
{
_registry
_set
_
lookup_cache
(
$lookup_cache
);
cache
_set
(
'
lookup_cache
'
,
$lookup_cache
,
'cache_registry'
);
}
return
;
}
...
...
@@ -1546,38 +1549,6 @@ function registry_rebuild() {
_registry_rebuild
();
}
/**
* Wrapper function to perform array to string conversion of lookup cache.
*/
function
_registry_set_lookup_cache
(
array
$lookup_cache
)
{
// Cache a string, not an array, so we can avoid the memory usage hit
// from serialize() in the cache system.
$key_value_pairs
=
array
();
foreach
(
$lookup_cache
as
$key
=>
$value
)
{
$key_value_pairs
[]
=
"
$key
|"
.
(
$value
?
$value
:
''
);
}
return
cache_set
(
'lookup_cache'
,
implode
(
';'
,
$key_value_pairs
),
'cache_registry'
);
}
/**
* Wrapper function to perform string to array conversion of lookup cache.
*/
function
_registry_get_lookup_cache
()
{
// In _registry_set_lookup_cache, we cache a string, not an array, to avoid
// serialize() in the cache system. serialize() makes a copy, and thus uses
// extra memory, which we are trying to avoid.
$lookup_cache
=
array
();
if
(
$cache
=
cache_get
(
'lookup_cache'
,
'cache_registry'
))
{
// Each item is separated by ';'.
foreach
(
explode
(
';'
,
$cache
->
data
)
as
$lookup
)
{
// Key value pairs are separated by '|'.
list
(
$resource
,
$result
)
=
explode
(
'|'
,
$lookup
);
$lookup_cache
[
$resource
]
=
$result
;
}
}
return
$lookup_cache
;
}
/**
* @} End of "ingroup registry".
*/
includes/registry.inc
View file @
4f8168c3
...
...
@@ -72,7 +72,11 @@ function _registry_rebuild() {
$parsed_files
=
_registry_parse_files
(
$files
);
$unchanged_resources
=
array
();
foreach
(
_registry_get_lookup_cache
()
as
$key
=>
$file
)
{
$lookup_cache
=
array
();
if
(
$cache
=
cache_get
(
'lookup_cache'
,
'cache_registry'
))
{
$lookup_cache
=
$cache
->
data
;
}
foreach
(
$lookup_cache
as
$key
=>
$file
)
{
// If the file for this cached resource is carried over unchanged from
// the last registry build, then we can safely re-cache it.
if
(
$file
&&
in_array
(
$file
,
array_keys
(
$files
))
&&
!
in_array
(
$file
,
$parsed_files
))
{
...
...
@@ -87,7 +91,7 @@ function _registry_rebuild() {
// We have some unchanged resources, warm up the cache - no need to pay
// for looking them up again.
if
(
count
(
$unchanged_resources
)
>
0
)
{
_registry
_set
_
lookup_cache
(
$unchanged_resources
);
cache
_set
(
'
lookup_cache
'
,
$unchanged_resources
,
'cache_registry'
);
}
}
...
...
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