Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
project
drupal
Commits
d8181f8f
Commit
d8181f8f
authored
Nov 22, 2013
by
Angie Byron
Browse files
Issue
#2140051
by damiankloip: Remove views_cache_get/set functions.
parent
78c933eb
Changes
3
Hide whitespace changes
Inline
Side-by-side
core/modules/views/lib/Drupal/views/Plugin/views/display/DisplayPluginBase.php
View file @
d8181f8f
...
...
@@ -102,6 +102,13 @@ abstract class DisplayPluginBase extends PluginBase {
*/
protected
$usesAreas
=
TRUE
;
/**
* Static cache for unpackOptions, but not if we are in the UI.
*
* @var array
*/
protected
static
$unpackOptions
=
array
();
/**
* Constructs a new DisplayPluginBase object.
*
...
...
@@ -124,12 +131,10 @@ public function initDisplay(ViewExecutable $view, array &$display, array &$optio
// Load extenders as soon as possible.
$this
->
extender
=
array
();
$extenders = views_get_enabled_display_extenders();
if (!empty($extenders)) {
if
(
$extenders
=
Views
::
getEnabledDisplayExtenders
())
{
$manager
=
Views
::
pluginManager
(
'display_extender'
);
foreach
(
$extenders
as
$extender
)
{
$plugin = $manager->createInstance($extender);
if ($plugin) {
if
(
$plugin
=
$manager
->
createInstance
(
$extender
))
{
$plugin
->
init
(
$this
->
view
,
$this
);
$this
->
extender
[
$extender
]
=
$plugin
;
}
...
...
@@ -148,23 +153,23 @@ public function initDisplay(ViewExecutable $view, array &$display, array &$optio
unset
(
$options
[
'defaults'
]);
}
// Cache for unpackOptions, but not if we are in the ui.
static $unpack_options = array();
if (empty($view->editing)) {
$cid = 'unpackOptions:' . hash('sha256', serialize(array($this->options, $options)));
if (empty($unpack
_o
ptions[$cid])) {
$cache =
views_cache_
get($cid
, TRUE
);
$skip_cache
=
\
Drupal
::
config
(
'views.settings'
)
->
get
(
'skip_cache'
);
if
(
empty
(
$view
->
editing
)
||
!
$skip_cache
)
{
$cid
=
'unpackOptions:'
.
hash
(
'sha256'
,
serialize
(
array
(
$this
->
options
,
$options
)))
.
':'
.
\
Drupal
::
languageManager
()
->
getLanguage
()
->
id
;
if
(
empty
(
static
::
$unpack
O
ptions
[
$cid
]))
{
$cache
=
\
Drupal
::
cache
(
'views_info'
)
->
get
(
$cid
);
if
(
!
empty
(
$cache
->
data
))
{
$this
->
options
=
$cache
->
data
;
}
else
{
$this
->
unpackOptions
(
$this
->
options
,
$options
);
views_cache_
set($cid, $this->options
, TRUE
);
\
Drupal
::
cache
(
'views_info'
)
->
set
(
$cid
,
$this
->
options
);
}
$unpack
_o
ptions[$cid] = $this->options;
static
::
$unpack
O
ptions
[
$cid
]
=
$this
->
options
;
}
else
{
$this->options = $unpack
_o
ptions[$cid];
$this
->
options
=
static
::
$unpack
O
ptions
[
$cid
];
}
}
else
{
...
...
core/modules/views/tests/Drupal/views/Tests/Plugin/display/PathPluginBaseTest.php
View file @
d8181f8f
...
...
@@ -67,18 +67,28 @@ protected function setUp() {
->
setConstructorArgs
(
array
(
array
(),
'path_base'
,
array
(),
$this
->
routeProvider
,
$this
->
state
))
->
setMethods
(
NULL
)
->
getMock
();
$this
->
setup
AccessPluginManag
er
();
$this
->
setup
Contain
er
();
}
/**
* Setup access plugin manager
in a
Drupal class.
* Setup access plugin manager
and config factory in the
Drupal class.
*/
public
function
setup
AccessPluginManag
er
()
{
public
function
setup
Contain
er
()
{
$this
->
accessPluginManager
=
$this
->
getMockBuilder
(
'\Drupal\views\Plugin\ViewsPluginManager'
)
->
disableOriginalConstructor
()
->
getMock
();
$container
=
new
ContainerBuilder
();
$container
->
set
(
'plugin.manager.views.access'
,
$this
->
accessPluginManager
);
$config
=
array
(
'views.settings'
=>
array
(
'skip_cache'
=>
TRUE
,
'display_extenders'
=>
array
(),
),
);
$container
->
set
(
'config.factory'
,
$this
->
getConfigFactoryStub
(
$config
));
\
Drupal
::
setContainer
(
$container
);
}
...
...
core/modules/views/views.module
View file @
d8181f8f
...
...
@@ -1355,52 +1355,3 @@ function views_element_validate_tags($element, &$form_state) {
}
}
}
/**
* Set a cached item in the views cache.
*
* This is just a convenience wrapper around cache_set().
*
* @param $cid
* The cache ID of the data to store.
* @param $data
* The data to store in the cache. Complex data types will be automatically serialized before insertion.
* Strings will be stored as plain text and not serialized.
* @param $use_language
* If TRUE, the data will be cached specific to the currently active language.
*/
function
views_cache_set
(
$cid
,
$data
,
$use_language
=
FALSE
)
{
if
(
\
Drupal
::
config
(
'views.settings'
)
->
get
(
'skip_cache'
))
{
return
;
}
if
(
$use_language
)
{
$cid
.
=
':'
.
language
(
Language
::
TYPE_INTERFACE
)
->
id
;
}
cache
(
'views_info'
)
->
set
(
$cid
,
$data
);
}
/**
* Return data from the persistent views cache.
*
* This is just a convenience wrapper around cache_get().
*
* @param int $cid
* The cache ID of the data to retrieve.
* @param bool $use_language
* If TRUE, the data will be requested specific to the currently active language.
*
* @return stdClass|bool
* The cache or FALSE on failure.
*/
function
views_cache_get
(
$cid
,
$use_language
=
FALSE
)
{
if
(
\
Drupal
::
config
(
'views.settings'
)
->
get
(
'skip_cache'
))
{
return
FALSE
;
}
if
(
$use_language
)
{
$cid
.
=
':'
.
language
(
Language
::
TYPE_INTERFACE
)
->
id
;
}
return
cache
(
'views_info'
)
->
get
(
$cid
);
}
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment