Commit 6ffc61f5 authored by catch's avatar catch

Issue #2443485 by Berdir, dawehner: Remove extension:views cache tag and other...

Issue #2443485 by Berdir, dawehner: Remove extension:views cache tag and other views related cache improvements
parent bbc47f05
......@@ -60,16 +60,6 @@ function system_list_reset() {
drupal_static_reset('system_list');
drupal_static_reset('system_rebuild_module_data');
\Drupal::cache('bootstrap')->delete('system_list');
// Clear the library info cache.
// Libraries may be provided by all extension types, and may be altered by any
// other extensions (types) due to the nature of
// \Drupal\Core\Extension\ModuleHandler::alter() and the fact that profiles
// are recorded and handled as modules.
// @todo Trigger an event upon module install/uninstall and theme
// enable/disable, and move this into an event subscriber.
// @see https://drupal.org/node/2206347
Cache::invalidateTags(['config:core.extension']);
}
/**
......
......@@ -87,7 +87,7 @@ public function query($group_by = FALSE) {
// Use the table definition to correctly add this user ID condition.
if ($this->table != 'comment') {
$subselect = $this->database->select('comment', 'c');
$subselect = $this->database->select('comment_field_data', 'c');
$subselect->addField('c', 'cid');
$subselect->condition('c.uid', $this->argument);
......
......@@ -22,7 +22,7 @@ class UserUid extends FilterPluginBase {
public function query() {
$this->ensureMyTable();
$subselect = db_select('comment', 'c');
$subselect = db_select('comment_field_data', 'c');
$subselect->addField('c', 'cid');
$subselect->condition('c.uid', $this->value, $this->operator);
......
......@@ -7,6 +7,8 @@
namespace Drupal\comment\Tests\Views;
use Drupal\comment\Entity\Comment;
use Drupal\user\Entity\User;
use Drupal\views\Views;
/**
......@@ -24,6 +26,19 @@ class ArgumentUserUIDTest extends CommentTestBase {
public static $testViews = array('test_comment_user_uid');
function testCommentUserUIDTest() {
// Add an additional comment which is not created by the user.
$new_user = User::create(['name' => 'new user']);
$new_user->save();
$comment = Comment::create([
'uid' => $new_user->uid->value,
'entity_id' => $this->nodeUserCommented->id(),
'entity_type' => 'node',
'field_name' => 'comment',
'subject' => 'if a woodchuck could chuck wood.',
]);
$comment->save();
$view = Views::getView('test_comment_user_uid');
$this->executeView($view, array($this->account->id()));
$result_set = array(
......
......@@ -7,6 +7,8 @@
namespace Drupal\comment\Tests\Views;
use Drupal\comment\Entity\Comment;
use Drupal\user\Entity\User;
use Drupal\views\Views;
/**
......@@ -30,6 +32,19 @@ function testCommentUserUIDTest() {
$view->setDisplay();
$view->removeHandler('default', 'argument', 'uid_touch');
// Add an additional comment which is not created by the user.
$new_user = User::create(['name' => 'new user']);
$new_user->save();
$comment = Comment::create([
'uid' => $new_user->uid->value,
'entity_id' => $this->nodeUserCommented->id(),
'entity_type' => 'node',
'field_name' => 'comment',
'subject' => 'if a woodchuck could chuck wood.',
]);
$comment->save();
$options = array(
'id' => 'uid_touch',
'table' => 'node_field_data',
......
......@@ -59,7 +59,7 @@ public function __construct($handler_type, \Traversable $namespaces, ViewsData $
}
parent::__construct("Plugin/views/$handler_type", $namespaces, $module_handler, $plugin_interface, $plugin_definition_annotation_name);
$this->setCacheBackend($cache_backend, "views:$handler_type", array('config:core.extension', 'extension:views'));
$this->setCacheBackend($cache_backend, "views:$handler_type");
$this->alterInfo('views_plugins_' . $handler_type);
$this->viewsData = $views_data;
......
......@@ -43,7 +43,7 @@ public function __construct($type, \Traversable $namespaces, CacheBackendInterfa
);
$this->alterInfo('views_plugins_' . $type);
$this->setCacheBackend($cache_backend, "views:$type", array('config:core.extension', 'extension:views'));
$this->setCacheBackend($cache_backend, "views:$type");
}
}
......@@ -186,7 +186,7 @@ public function initDisplay(ViewExecutable $view, array &$display, array &$optio
}
else {
$this->unpackOptions($this->options, $options);
\Drupal::cache('data')->set($cid, $this->options, Cache::PERMANENT, Cache::mergeTags(array('config:core.extension', 'extension:views'), $this->view->storage->getCacheTags()));
\Drupal::cache('data')->set($cid, $this->options, Cache::PERMANENT, $this->view->storage->getCacheTags());
}
static::$unpackOptions[$cid] = $this->options;
}
......
......@@ -86,8 +86,6 @@ protected function setUp() {
$this->addDefaultCommentField('node', 'page');
$this->container->get('views.views_data')->clear();
for ($i = 0; $i <= 10; $i++) {
$user = $this->drupalCreateUser();
$term = $this->createTerm($vocabulary);
......
......@@ -45,8 +45,6 @@ public function testGetEntity() {
$account->save();
$this->drupalCreateContentType(array('type' => 'page'));
$this->addDefaultCommentField('node', 'page');
// Force a flush of the in-memory storage.
$this->container->get('views.views_data')->clear();
$node = entity_create('node', array('uid' => $account->id(), 'type' => 'page'));
$node->save();
......
......@@ -81,8 +81,6 @@ public function testCalculateDependencies() {
'label' => $this->randomMachineName() . '_body',
'settings' => array('display_summary' => TRUE),
))->save();
// Force a flush of the in-memory storage.
$this->container->get('views.views_data')->clear();
$expected = [];
$expected['test_field_get_entity'] = [
......
......@@ -36,8 +36,6 @@ protected function setUp() {
);
$nodes[] = $this->drupalCreateNode($edit);
}
$this->container->get('views.views_data')->clear();
}
/**
......
......@@ -61,8 +61,6 @@ protected function setUp() {
'bundle' => $node_type->id(),
);
entity_create('field_config', $field)->save();
$this->container->get('views.views_data')->clear();
}
/**
......
......@@ -34,11 +34,6 @@ abstract class ViewTestBase extends WebTestBase {
protected function setUp($import_test_views = TRUE) {
parent::setUp();
// Ensure that the plugin definitions are cleared.
foreach (ViewExecutable::getPluginTypes() as $plugin_type) {
$this->container->get("plugin.manager.views.$plugin_type")->clearCachedDefinitions();
}
if ($import_test_views) {
ViewTestData::createTestViews(get_class($this), array('views_test_config'));
}
......
......@@ -200,7 +200,7 @@ protected function cacheGet($cid) {
* The data that will be cached.
*/
protected function cacheSet($cid, $data) {
return $this->cacheBackend->set($this->prepareCid($cid), $data, Cache::PERMANENT, array('views_data', 'config:core.extension', 'extension:views'));
return $this->cacheBackend->set($this->prepareCid($cid), $data, Cache::PERMANENT, array('views_data', 'config:core.extension'));
}
/**
......
......@@ -462,33 +462,27 @@ function views_add_contextual_links(&$render_element, $location, ViewExecutable
* Implements hook_ENTITY_TYPE_create() for 'field_config'.
*/
function views_field_config_create(FieldConfigInterface $field) {
// @todo: Is this necessary? Use cache tags to only delete Views' cache data?
\Drupal::cache('discovery')->deleteAll();
Views::viewsData()->clear();
}
/**
* Implements hook_ENTITY_TYPE_update() for 'field_config'.
*/
function views_field_config_update(FieldConfigInterface $field) {
Cache::invalidateTags(['extension:views']);
\Drupal::cache('render')->deleteAll();
Views::viewsData()->clear();
}
/**
* Implements hook_ENTITY_TYPE_delete() for 'field_config'.
*/
function views_field_config_delete(FieldConfigInterface $field) {
Cache::invalidateTags(['extension:views']);
\Drupal::cache('render')->deleteAll();
Views::viewsData()->clear();
}
/**
* Invalidate the views cache, forcing a rebuild on the next grab of table data.
*/
function views_invalidate_cache() {
// Clear Views' info cache entries.
Cache::invalidateTags(['extension:views']);
// Set the menu as needed to be rebuilt.
\Drupal::service('router.builder_indicator')->setRebuildNeeded();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment