Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
apc
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
apc
Commits
3b05593f
Verified
Commit
3b05593f
authored
7 months ago
by
Alberto Paderno
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#2898530
: HTTP_HOST is not a reliable default prefix
parent
6caedf3a
No related branches found
No related tags found
1 merge request
!20
Issue #2898530: HTTP_HOST is not a reliable default prefix
Pipeline
#230903
passed
7 months ago
Stage: build
Stage: validate
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
apc.install
+7
-0
7 additions, 0 deletions
apc.install
drupal_apc_cache.inc
+25
-10
25 additions, 10 deletions
drupal_apc_cache.inc
with
32 additions
and
10 deletions
apc.install
+
7
−
0
View file @
3b05593f
...
...
@@ -66,3 +66,10 @@ function apc_requirements($phase) {
return
$requirements
;
}
/**
* Clear the APCu storage since the prefix used for the cache bins has changed.
*/
function
apc_update_7101
()
{
apcu_clear_cache
();
}
This diff is collapsed.
Click to expand it.
drupal_apc_cache.inc
+
25
−
10
View file @
3b05593f
...
...
@@ -94,22 +94,37 @@ protected static function getPrefixSettingForBin($bin) {
}
public
function
__construct
(
$bin
)
{
global
$databases
;
$this
->
bin
=
$bin
;
$this
->
drush
=
(
drupal_is_cli
()
&&
function_exists
(
'drush_log'
));
// First we determine the prefix from a setting.
$prefix
=
self
::
getPrefixSettingForBin
(
$this
->
bin
);
// If we do not have a configured prefix we use the HTTP_HOST.
if
(
empty
(
$prefix
)
&&
isset
(
$_SERVER
[
'HTTP_HOST'
]))
{
// Provide a fallback for multisite. This is on purpose not inside the
// getPrefixSettingsForBin() function in order to decouple the unified
// prefix variable logic and custom module related security logic, which
// is not necessary for all backends.
$prefix
=
$_SERVER
[
'HTTP_HOST'
]
.
'::'
;
// As fallback for a multisite installation, use the database connection
// information to generate a prefix.
if
(
empty
(
$prefix
)
&&
isset
(
$databases
)
&&
is_array
(
$databases
))
{
$db_info
=
''
;
if
(
isset
(
$databases
[
'default'
][
'default'
])
&&
is_array
(
$databases
[
'default'
][
'default'
]))
{
if
(
isset
(
$databases
[
'default'
][
'default'
][
'host'
]))
{
$db_info
.
=
$databases
[
'default'
][
'default'
][
'prefix'
];
}
if
(
isset
(
$databases
[
'default'
][
'default'
][
'database'
]))
{
$db_info
.
=
$databases
[
'default'
][
'default'
][
'database'
];
}
if
(
isset
(
$databases
[
'default'
][
'default'
][
'prefix'
]))
{
$db_info
.
=
serialize
(
$databases
[
'default'
][
'default'
][
'prefix'
]);
}
}
$hash
=
substr
(
hash
(
'sha256'
,
$db_info
,
TRUE
),
0
,
16
);
$prefix
=
drupal_base64_encode
(
$hash
);
}
else
{
$prefix
=
$prefix
.
'::'
;
if
(
!
empty
(
$prefix
)
&&
substr
(
$prefix
,
-
2
)
!==
'::'
)
{
$prefix
.
=
'::'
;
}
// When we are in testing mode we add the test prefix.
...
...
@@ -117,7 +132,7 @@ public function __construct($bin) {
$prefix
=
$test_prefix
.
'::'
.
$prefix
;
}
$this
->
prefix
=
"apc_cache_
$prefix
"
;
$this
->
prefix
=
empty
(
$prefix
)
?
'apc_cache::'
:
"apc_cache_
$prefix
"
;
}
/**
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment