Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
drupal
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
drupal
Commits
2c8f0995
Commit
2c8f0995
authored
12 years ago
by
Daniel Wehner
Committed by
Tim Plunkett
12 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#1792852
by dawehner: Cleanup naming of resultskey, outputkey.
parent
09a407f4
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!7452
Issue #1797438. HTML5 validation is preventing form submit and not fully...
,
!789
Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/Drupal/views/Plugin/views/cache/CachePluginBase.php
+56
-23
56 additions, 23 deletions
lib/Drupal/views/Plugin/views/cache/CachePluginBase.php
lib/Drupal/views/Plugin/views/cache/Time.php
+2
-1
2 additions, 1 deletion
lib/Drupal/views/Plugin/views/cache/Time.php
with
58 additions
and
24 deletions
lib/Drupal/views/Plugin/views/cache/CachePluginBase.php
+
56
−
23
View file @
2c8f0995
...
...
@@ -8,6 +8,7 @@
namespace
Drupal\views\Plugin\views\cache
;
use
Drupal\views\ViewExecutable
;
use
Drupal\Core\Cache\CacheBackendInterface
;
use
Drupal\views\Plugin\views\PluginBase
;
use
Drupal\Core\Database\Query\Select
;
...
...
@@ -38,22 +39,25 @@ abstract class CachePluginBase extends PluginBase {
var
$table
=
'views_results'
;
/**
* Stores the cache id used for the results cache, once get_results_key() got
* executed.
* Stores the cache ID used for the results cache.
*
* The cache ID is stored in generateResultsKey() got executed.
*
* @see views_plugin_cache::get_results_key
* @var string
*
* @see Drupal\views\Plugin\views\cache\CachePluginBase::generateResultsKey()
*/
p
ublic
$
_
results
_k
ey
;
p
rotected
$results
K
ey
;
/**
* Stores the cache
id
used for the output cache, once ge
t_o
utput
_k
ey() got
* Stores the cache
ID
used for the output cache, once ge
nerateO
utput
K
ey() got
* executed.
*
* @see views_plugin_cache::get_output_key
* @var string
*
* @see Drupal\views\Plugin\views\cache\CachePluginBase::generateOutputKey()
*/
p
ublic
$
_
output
_k
ey
;
p
rotected
$output
K
ey
;
/**
* Initialize the plugin.
...
...
@@ -71,6 +75,26 @@ public function init(ViewExecutable $view, &$display, $options = NULL) {
$this
->
unpackOptions
(
$this
->
options
,
$options
);
}
/**
* Returns the outputKey property.
*
* @return string
* The outputKey property.
*/
public
function
getOutputKey
()
{
return
$this
->
outputKey
;
}
/**
* Returns the resultsKey property.
*
* @return string
* The resultsKey property.
*/
public
function
getResultsKey
()
{
return
$this
->
resultsKey
;
}
/**
* Return a string to display as the clickable title for the
* access control.
...
...
@@ -99,7 +123,7 @@ function cache_expire($type) { }
* The cache type, either 'query', 'result' or 'output'.
*/
function
cache_set_expire
(
$type
)
{
return
CACHE_PERMANENT
;
return
CacheBackendInterface
::
CACHE_PERMANENT
;
}
...
...
@@ -119,12 +143,12 @@ function cache_set($type) {
'total_rows'
=>
isset
(
$this
->
view
->
total_rows
)
?
$this
->
view
->
total_rows
:
0
,
'current_page'
=>
$this
->
view
->
getCurrentPage
(),
);
cache
(
$this
->
table
)
->
set
(
$this
->
ge
t_r
esults
_k
ey
(),
$data
,
$this
->
cache_set_expire
(
$type
));
cache
(
$this
->
table
)
->
set
(
$this
->
ge
nerateR
esults
K
ey
(),
$data
,
$this
->
cache_set_expire
(
$type
));
break
;
case
'output'
:
$this
->
gather_headers
();
$this
->
storage
[
'output'
]
=
$this
->
view
->
display_handler
->
output
;
cache
(
$this
->
table
)
->
set
(
$this
->
ge
t_o
utput
_k
ey
(),
$this
->
storage
,
$this
->
cache_set_expire
(
$type
));
cache
(
$this
->
table
)
->
set
(
$this
->
ge
nerateO
utput
K
ey
(),
$this
->
storage
,
$this
->
cache_set_expire
(
$type
));
break
;
}
}
...
...
@@ -144,7 +168,7 @@ function cache_get($type) {
case
'results'
:
// Values to set: $view->result, $view->total_rows, $view->execute_time,
// $view->current_page.
if
(
$cache
=
cache
(
$this
->
table
)
->
get
(
$this
->
ge
t_r
esults
_k
ey
()))
{
if
(
$cache
=
cache
(
$this
->
table
)
->
get
(
$this
->
ge
nerateR
esults
K
ey
()))
{
if
(
!
$cutoff
||
$cache
->
created
>
$cutoff
)
{
$this
->
view
->
result
=
$cache
->
data
[
'result'
];
$this
->
view
->
total_rows
=
$cache
->
data
[
'total_rows'
];
...
...
@@ -155,7 +179,7 @@ function cache_get($type) {
}
return
FALSE
;
case
'output'
:
if
(
$cache
=
cache
(
$this
->
table
)
->
get
(
$this
->
ge
t_o
utput
_k
ey
()))
{
if
(
$cache
=
cache
(
$this
->
table
)
->
get
(
$this
->
ge
nerateO
utput
K
ey
()))
{
if
(
!
$cutoff
||
$cache
->
created
>
$cutoff
)
{
$this
->
storage
=
$cache
->
data
;
$this
->
view
->
display_handler
->
output
=
$cache
->
data
[
'output'
];
...
...
@@ -268,15 +292,18 @@ function restore_headers() {
}
}
function
get_results_key
()
{
/**
* Calculates and sets a cache ID used for the result cache.
*
* @return string
* The generated cache ID.
*/
public
function
generateResultsKey
()
{
global
$user
;
if
(
!
isset
(
$this
->
_results_key
))
{
if
(
!
isset
(
$this
->
resultsKey
))
{
$build_info
=
$this
->
view
->
build_info
;
$query_plugin
=
$this
->
view
->
display_handler
->
getPlugin
(
'query'
);
foreach
(
array
(
'query'
,
'count_query'
)
as
$index
)
{
// If the default query back-end is used generate SQL query strings from
// the query objects.
...
...
@@ -299,15 +326,21 @@ function get_results_key() {
}
}
$this
->
_
results
_k
ey
=
$this
->
view
->
storage
->
name
.
':'
.
$this
->
displayHandler
->
display
[
'id'
]
.
':results:'
.
md5
(
serialize
(
$key_data
));
$this
->
results
K
ey
=
$this
->
view
->
storage
->
name
.
':'
.
$this
->
displayHandler
->
display
[
'id'
]
.
':results:'
.
md5
(
serialize
(
$key_data
));
}
return
$this
->
_
results
_k
ey
;
return
$this
->
results
K
ey
;
}
function
get_output_key
()
{
/**
* Calculates and sets a cache ID used for the output cache.
*
* @return string
* The generated cache ID.
*/
public
function
generateOutputKey
()
{
global
$user
;
if
(
!
isset
(
$this
->
_
output
_k
ey
))
{
if
(
!
isset
(
$this
->
output
K
ey
))
{
$key_data
=
array
(
'result'
=>
$this
->
view
->
result
,
'roles'
=>
array_keys
(
$user
->
roles
),
...
...
@@ -317,10 +350,10 @@ function get_output_key() {
'base_url'
=>
$GLOBALS
[
'base_url'
],
);
$this
->
_
output
_k
ey
=
$this
->
view
->
storage
->
name
.
':'
.
$this
->
displayHandler
->
display
[
'id'
]
.
':output:'
.
md5
(
serialize
(
$key_data
));
$this
->
output
K
ey
=
$this
->
view
->
storage
->
name
.
':'
.
$this
->
displayHandler
->
display
[
'id'
]
.
':output:'
.
md5
(
serialize
(
$key_data
));
}
return
$this
->
_
output
_k
ey
;
return
$this
->
output
K
ey
;
}
}
...
...
This diff is collapsed.
Click to expand it.
lib/Drupal/views/Plugin/views/cache/Time.php
+
2
−
1
View file @
2c8f0995
...
...
@@ -8,6 +8,7 @@
namespace
Drupal\views\Plugin\views\cache
;
use
Drupal\Core\Annotation\Plugin
;
use
Drupal\Core\Cache\CacheBackendInterface
;
use
Drupal\Core\Annotation\Translation
;
/**
...
...
@@ -123,7 +124,7 @@ function cache_set_expire($type) {
return
time
()
+
$lifespan
;
}
else
{
return
CACHE_PERMANENT
;
return
CacheBackendInterface
::
CACHE_PERMANENT
;
}
}
...
...
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