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
888e87f4
Commit
888e87f4
authored
7 months ago
by
Alberto Paderno
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3462024
: Change apc_drush_flush() to use two parameters instead of one
parent
669da123
No related branches found
No related tags found
1 merge request
!10
Issue #3462024: Change apc_drush_flush() to use two parameters instead of one
Pipeline
#228769
passed
7 months ago
Stage: build
Stage: validate
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
apc.module
+22
-20
22 additions, 20 deletions
apc.module
drupal_apc_cache.inc
+15
-14
15 additions, 14 deletions
drupal_apc_cache.inc
with
37 additions
and
34 deletions
apc.module
+
22
−
20
View file @
888e87f4
...
...
@@ -64,44 +64,46 @@ function apc_clear_apcu_cache() {
*/
function
apc_xmlrpc
()
{
$methods
[]
=
array
(
'apc
_drush_flush
'
,
'apc_
drush_flush
'
,
'apc
.clear_cache
'
,
'apc_
clear_cache
'
,
array
(
'array'
,
'string'
,
'array'
,
),
t
(
'
XMLRPC callback to enable cache clear from Drush/CLI
.'
),
t
(
'
Clears the APCu cache
.'
),
);
return
$methods
;
}
/**
* XMLRPC callback to clear the cache from Drush/CLI.
* XML-RPC callback to clear the cache.
*
* @see apc_xmlrpc()
*/
function
apc_
drush_flush
(
$variables
)
{
$cron_key
=
isset
(
$
variable
s
[
'cron_key'
])
?
$variables
[
'cron_key'
]
:
NULL
;
$clears
=
isset
(
$variables
[
'clears'
])
?
$variables
[
'clears'
]
:
array
(
);
function
apc_
clear_cache
(
$key
,
$bins
=
array
()
)
{
if
(
empty
(
$key
)
||
variable
_get
(
'cron_key'
,
'drupal'
)
!=
$key
)
{
watchdog
(
'apc'
,
'An invalid key was passed to apc_clear_cache().'
,
array
(),
WATCHDOG_ERROR
);
if
(
empty
(
$cron_key
)
||
variable_get
(
'cron_key'
,
'drupal'
)
!=
$cron_key
)
{
watchdog
(
'apc'
,
'APC could not flush cache(s) because an invalid key was used.'
,
array
(),
WATCHDOG_ERROR
);
return
array
(
'success'
=>
FALSE
,
'message'
=>
t
(
'
APC could not flush cache(s) because an invalid key was used
.'
),
'message'
=>
t
(
'
Invalid key for apc.clear_cache
.'
),
);
}
else
{
foreach
(
$clears
as
$bin
=>
$cids
)
{
foreach
(
$cids
as
$serialized_cid
=>
$wildcard
)
{
cache_clear_all
(
unserialize
(
$serialized_cid
),
$bin
,
$wildcard
);
}
}
return
array
(
'success'
=>
TRUE
,
'message'
=>
t
(
'APC all requested flushes done.'
),
);
// Clear the APCu cache.
foreach
(
$bins
as
$bin
=>
$cids
)
{
foreach
(
$cids
as
$cid
=>
$wildcard
)
{
// $cid has been serialized in DrupalAPCCache::clear().
cache_clear_all
(
unserialize
(
$cid
),
$bin
,
$wildcard
);
}
}
return
array
(
'success'
=>
TRUE
,
'message'
=>
t
(
'The cache has been cleared.'
),
);
}
/**
...
...
This diff is collapsed.
Click to expand it.
drupal_apc_cache.inc
+
15
−
14
View file @
888e87f4
...
...
@@ -87,7 +87,7 @@ class DrupalAPCCache implements DrupalCacheInterface {
*
* @var array
*/
protected
static
$remote
Clear
s
=
array
();
protected
static
$remote
Request
s
=
array
();
/**
* Gets the prefix to use for the cache bin.
...
...
@@ -140,9 +140,9 @@ public function __construct($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
// getPrefixForBin() function in order to decouple the unified
prefix
// variable logic and custom module related security logic,
that is not
// necessary for all backends.
// getPrefix
Settings
ForBin() 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'
]
.
'::'
;
}
else
{
...
...
@@ -331,7 +331,7 @@ public function clear($cid = NULL, $wildcard = FALSE) {
if
(
$this
->
drush
)
{
// APC uses a separate storage for CLI. Send these requests to the server,
// via XMLRPC.
self
::
$remote
Clear
s
[
$this
->
bin
][
serialize
(
$cid
)]
=
$wildcard
;
self
::
$remote
Request
s
[
$this
->
bin
][
serialize
(
$cid
)]
=
$wildcard
;
return
;
}
...
...
@@ -384,22 +384,23 @@ public static function remoteFlush() {
return
;
}
if
(
!
empty
(
self
::
$remote
Clear
s
))
{
if
(
!
empty
(
self
::
$remote
Request
s
))
{
// Optimize '*' clears.
$star
=
serialize
(
'*'
);
foreach
(
self
::
$remoteClears
as
$bin
=>
$clears
)
{
if
(
!
empty
(
$clears
[
$star
]))
{
self
::
$remoteClears
[
$bin
]
=
array
(
$star
=>
TRUE
);
foreach
(
self
::
$remoteRequests
as
$bin
=>
$cids
)
{
if
(
!
empty
(
$cids
[
$star
]))
{
self
::
$remoteRequests
[
$bin
]
=
array
(
$star
=>
TRUE
);
}
}
$args
=
array
(
'apc_drush_flush'
=>
array
(
array
(
'clears'
=>
self
::
$remoteClears
,
'cron_key'
=>
variable_get
(
'cron_key'
,
'drupal'
),
),
'apc.clear_cache'
=>
array
(
variable_get
(
'cron_key'
,
'drupal'
),
self
::
$remoteRequests
,
),
);
$uri
=
$base_url
.
'/xmlrpc.php'
;
$response
=
xmlrpc
(
$uri
,
$args
);
...
...
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