Updated: Comment #N

Problem/Motivation

We still have views_cache_get and views_cache_set functions in views.module. This is only used on displayPluginBase class, once each.

Proposed resolution

Move any logic we need to into displayPluginBase::initDisplay. Remove the mentioned methods above.

Remaining tasks

Do it.

User interface changes

None.

API changes

None really, no one really has uses for views cache methods. This is something that was internal to views.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Status: Needs review » Needs work

The last submitted patch, vdc.remove-views-cache-functions.patch, failed testing.

damiankloip’s picture

Status: Needs work » Needs review
FileSize
6.24 KB
1.86 KB

That unit test needs adapting.

dawehner’s picture

Nice work!

  1. +++ b/core/modules/views/lib/Drupal/views/Plugin/views/display/DisplayPluginBase.php
    @@ -148,23 +153,23 @@ public function initDisplay(ViewExecutable $view, array &$display, array &$optio
    -    static $unpack_options = array();
    ...
    +        static::$unpackOptions[$cid] = $this->options;
    ...
    +        $this->options = static::$unpackOptions[$cid];
    

    It feels wrong to still have static functions but I agree that this is out of scope here.

  2. +++ b/core/modules/views/lib/Drupal/views/Plugin/views/display/DisplayPluginBase.php
    @@ -148,23 +153,23 @@ public function initDisplay(ViewExecutable $view, array &$display, array &$optio
    +      $cid = 'unpackOptions:' . hash('sha256', serialize(array($this->options, $options))) . ':' . language(Language::TYPE_INTERFACE)->id;
    

    You can also use the languageManager service as alternative to this function call.

  3. +++ b/core/modules/views/lib/Drupal/views/Plugin/views/display/DisplayPluginBase.php
    @@ -148,23 +153,23 @@ public function initDisplay(ViewExecutable $view, array &$display, array &$optio
    +        $cache = cache('views_info')->get($cid);
    ...
    +          cache('views_info')->set($cid, $this->options);
    

    Can we replace that with \Drupal::cache() right now?

olli’s picture

+++ b/core/modules/views/tests/Drupal/views/Tests/Plugin/display/PathPluginBaseTest.php
@@ -67,18 +67,41 @@ protected function setUp() {
+    $value_map = array(
+      array('skip_cache', TRUE),
+      array('display_extenders', array()),
+    );
+
+    $config = $this->getMockBuilder('Drupal\Core\Config\Config')
+      ->disableOriginalConstructor()
+      ->getMock();
+    $config->expects($this->any())
+      ->method('get')
+      ->will($this->returnValueMap($value_map));
+
+    $config_factory = $this->getMockBuilder('Drupal\Core\Config\ConfigFactory')
+      ->disableOriginalConstructor()
+      ->getMock();
+    $config_factory->expects($this->any())
+      ->method('get')
+      ->with('views.settings')
+      ->will($this->returnValue($config));

This looks like it could be replaced with $this->getConfigFactoryStub().

damiankloip’s picture

FileSize
5.81 KB
2.86 KB

It feels wrong to still have static functions but I agree that this is out of scope here.

You mean a static variable I guess? :)

Good point olli! I can totally use that!

Made the other changes too.

dawehner’s picture

olli++ seriously, great catch!

dawehner’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: +VDC

Wonderful!

webchick’s picture

Status: Reviewed & tested by the community » Fixed
Issue tags: +Approved API change

Seems like this is pretty self-contained, so should be safe to commit.

Committed and pushed to 8.x. Thanks!

I guess this doesn't need a change notice if it's internal to views?

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.