core/modules/rest/src/Plugin/views/style/Serializer.php | 16 ++++++++++++---- core/modules/system/src/Plugin/views/field/BulkForm.php | 15 +++++++++++---- core/modules/user/src/Plugin/views/access/Permission.php | 16 ++++++++++++---- core/modules/user/src/Plugin/views/access/Role.php | 15 +++++++++++---- .../Plugin/views/exposed_form/ExposedFormPluginBase.php | 16 ++++++++++++---- core/modules/views/src/Plugin/views/pager/SqlBase.php | 16 ++++++++++++---- core/modules/views/src/Plugin/views/sort/Random.php | 2 -- core/modules/views/src/Plugin/views/style/Table.php | 15 +++++++++++---- 8 files changed, 81 insertions(+), 30 deletions(-) diff --git a/core/modules/rest/src/Plugin/views/style/Serializer.php b/core/modules/rest/src/Plugin/views/style/Serializer.php index 67a8364..ceccd61 100644 --- a/core/modules/rest/src/Plugin/views/style/Serializer.php +++ b/core/modules/rest/src/Plugin/views/style/Serializer.php @@ -7,8 +7,9 @@ namespace Drupal\rest\Plugin\views\style; +use Drupal\Core\Cache\Cache; +use Drupal\Core\Cache\CacheableDependencyInterface; use Drupal\Core\Form\FormStateInterface; -use Drupal\views\Plugin\CacheablePluginInterface; use Drupal\views\ViewExecutable; use Drupal\views\Plugin\views\display\DisplayPluginBase; use Drupal\views\Plugin\views\style\StylePluginBase; @@ -27,7 +28,7 @@ * display_types = {"data"} * ) */ -class Serializer extends StylePluginBase implements CacheablePluginInterface { +class Serializer extends StylePluginBase implements CacheableDependencyInterface { /** * Overrides \Drupal\views\Plugin\views\style\StylePluginBase::$usesRowPlugin. @@ -153,8 +154,8 @@ public function getFormats() { /** * {@inheritdoc} */ - public function isCacheable() { - return TRUE; + public function getCacheMaxAge() { + return Cache::PERMANENT; } /** @@ -164,4 +165,11 @@ public function getCacheContexts() { return ['request_format']; } + /** + * {@inheritdoc} + */ + public function getCacheTags() { + return []; + } + } diff --git a/core/modules/system/src/Plugin/views/field/BulkForm.php b/core/modules/system/src/Plugin/views/field/BulkForm.php index 609d4c0..3a3b65c 100644 --- a/core/modules/system/src/Plugin/views/field/BulkForm.php +++ b/core/modules/system/src/Plugin/views/field/BulkForm.php @@ -7,6 +7,7 @@ namespace Drupal\system\Plugin\views\field; +use Drupal\Core\Cache\CacheableDependencyInterface; use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Entity\RevisionableInterface; @@ -15,7 +16,6 @@ use Drupal\Core\Routing\RedirectDestinationTrait; use Drupal\Core\TypedData\TranslatableInterface; use Drupal\views\Entity\Render\EntityTranslationRenderTrait; -use Drupal\views\Plugin\CacheablePluginInterface; use Drupal\views\Plugin\views\display\DisplayPluginBase; use Drupal\views\Plugin\views\field\FieldPluginBase; use Drupal\views\Plugin\views\field\UncacheableFieldHandlerTrait; @@ -29,7 +29,7 @@ * * @ViewsField("bulk_form") */ -class BulkForm extends FieldPluginBase implements CacheablePluginInterface { +class BulkForm extends FieldPluginBase implements CacheableDependencyInterface { use RedirectDestinationTrait; use UncacheableFieldHandlerTrait; @@ -114,10 +114,10 @@ public function init(ViewExecutable $view, DisplayPluginBase $display, array &$o /** * {@inheritdoc} */ - public function isCacheable() { + public function getCacheMaxAge() { // @todo Consider making the bulk operation form cacheable. See // https://www.drupal.org/node/2503009. - return FALSE; + return 0; } /** @@ -130,6 +130,13 @@ public function getCacheContexts() { /** * {@inheritdoc} */ + public function getCacheTags() { + return []; + } + + /** + * {@inheritdoc} + */ public function getEntityTypeId() { return $this->getEntityType(); } diff --git a/core/modules/user/src/Plugin/views/access/Permission.php b/core/modules/user/src/Plugin/views/access/Permission.php index 18f0275..49a6875 100644 --- a/core/modules/user/src/Plugin/views/access/Permission.php +++ b/core/modules/user/src/Plugin/views/access/Permission.php @@ -8,11 +8,12 @@ namespace Drupal\user\Plugin\views\access; use Drupal\Component\Utility\SafeMarkup; +use Drupal\Core\Cache\Cache; +use Drupal\Core\Cache\CacheableDependencyInterface; use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Session\AccountInterface; use Drupal\user\PermissionHandlerInterface; -use Drupal\views\Plugin\CacheablePluginInterface; use Drupal\views\Plugin\views\access\AccessPluginBase; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\Routing\Route; @@ -28,7 +29,7 @@ * help = @Translation("Access will be granted to users with the specified permission string.") * ) */ -class Permission extends AccessPluginBase implements CacheablePluginInterface { +class Permission extends AccessPluginBase implements CacheableDependencyInterface { /** * Overrides Drupal\views\Plugin\Plugin::$usesOptions. @@ -136,8 +137,8 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) { /** * {@inheritdoc} */ - public function isCacheable() { - return TRUE; + public function getCacheMaxAge() { + return Cache::PERMANENT; } /** @@ -147,4 +148,11 @@ public function getCacheContexts() { return ['user.permissions']; } + /** + * {@inheritdoc} + */ + public function getCacheTags() { + return []; + } + } diff --git a/core/modules/user/src/Plugin/views/access/Role.php b/core/modules/user/src/Plugin/views/access/Role.php index 9686d08..3b272fc 100644 --- a/core/modules/user/src/Plugin/views/access/Role.php +++ b/core/modules/user/src/Plugin/views/access/Role.php @@ -8,9 +8,9 @@ namespace Drupal\user\Plugin\views\access; use Drupal\Component\Utility\SafeMarkup; +use Drupal\Core\Cache\CacheableDependencyInterface; use Drupal\Core\Form\FormStateInterface; use Drupal\user\RoleStorageInterface; -use Drupal\views\Plugin\CacheablePluginInterface; use Drupal\views\Plugin\views\access\AccessPluginBase; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\Routing\Route; @@ -27,7 +27,7 @@ * help = @Translation("Access will be granted to users with any of the specified roles.") * ) */ -class Role extends AccessPluginBase implements CacheablePluginInterface { +class Role extends AccessPluginBase implements CacheableDependencyInterface { /** * Overrides Drupal\views\Plugin\Plugin::$usesOptions. @@ -149,8 +149,8 @@ public function calculateDependencies() { /** * {@inheritdoc} */ - public function isCacheable() { - return TRUE; + public function getCacheMaxAge() { + return 0; } /** @@ -160,5 +160,12 @@ public function getCacheContexts() { return ['user.roles']; } + /** + * {@inheritdoc} + */ + public function getCacheTags() { + return []; + } + } diff --git a/core/modules/views/src/Plugin/views/exposed_form/ExposedFormPluginBase.php b/core/modules/views/src/Plugin/views/exposed_form/ExposedFormPluginBase.php index 11a3e2d..f89bc0c 100644 --- a/core/modules/views/src/Plugin/views/exposed_form/ExposedFormPluginBase.php +++ b/core/modules/views/src/Plugin/views/exposed_form/ExposedFormPluginBase.php @@ -8,10 +8,11 @@ namespace Drupal\views\Plugin\views\exposed_form; use Drupal\Component\Utility\SafeMarkup; +use Drupal\Core\Cache\Cache; +use Drupal\Core\Cache\CacheableDependencyInterface; use Drupal\Core\Form\FormState; use Drupal\Core\Form\FormStateInterface; use Drupal\views\Form\ViewsExposedForm; -use Drupal\views\Plugin\CacheablePluginInterface; use Drupal\views\ViewExecutable; use Drupal\views\Plugin\views\display\DisplayPluginBase; use Drupal\views\Plugin\views\PluginBase; @@ -35,7 +36,7 @@ /** * Base class for Views exposed filter form plugins. */ -abstract class ExposedFormPluginBase extends PluginBase implements CacheablePluginInterface { +abstract class ExposedFormPluginBase extends PluginBase implements CacheableDependencyInterface { /** * Overrides Drupal\views\Plugin\Plugin::$usesOptions. @@ -336,8 +337,8 @@ public function resetForm(&$form, FormStateInterface $form_state) { /** * {@inheritdoc} */ - public function isCacheable() { - return TRUE; + public function getCacheMaxAge() { + return Cache::PERMANENT; } /** @@ -364,6 +365,13 @@ public function getCacheContexts() { return $contexts; } + /** + * {@inheritdoc} + */ + public function getCacheTags() { + return 0; + } + } /** diff --git a/core/modules/views/src/Plugin/views/pager/SqlBase.php b/core/modules/views/src/Plugin/views/pager/SqlBase.php index 4eda114..8bd61be 100644 --- a/core/modules/views/src/Plugin/views/pager/SqlBase.php +++ b/core/modules/views/src/Plugin/views/pager/SqlBase.php @@ -7,13 +7,14 @@ namespace Drupal\views\Plugin\views\pager; +use Drupal\Core\Cache\Cache; +use Drupal\Core\Cache\CacheableDependencyInterface; use Drupal\Core\Form\FormStateInterface; -use Drupal\views\Plugin\CacheablePluginInterface; /** * A common base class for sql based pager. */ -abstract class SqlBase extends PagerPluginBase implements CacheablePluginInterface { +abstract class SqlBase extends PagerPluginBase implements CacheableDependencyInterface { protected function defineOptions() { $options = parent::defineOptions(); @@ -374,8 +375,8 @@ public function exposedFormValidate(&$form, FormStateInterface $form_state) { /** * {@inheritdoc} */ - public function isCacheable() { - return TRUE; + public function getCacheMaxAge() { + return Cache::PERMANENT; } /** @@ -392,4 +393,11 @@ public function getCacheContexts() { return $contexts; } + /** + * {@inheritdoc} + */ + public function getCacheTags() { + return []; + } + } diff --git a/core/modules/views/src/Plugin/views/sort/Random.php b/core/modules/views/src/Plugin/views/sort/Random.php index 0ab0011..54436c6 100644 --- a/core/modules/views/src/Plugin/views/sort/Random.php +++ b/core/modules/views/src/Plugin/views/sort/Random.php @@ -26,8 +26,6 @@ public function usesGroupBy() { public function query() { $this->query->addOrderBy('rand'); - // @todo Replace this once https://www.drupal.org/node/2464427 is in. - $this->view->element['#cache']['max-age'] = 0; } public function buildOptionsForm(&$form, FormStateInterface $form_state) { diff --git a/core/modules/views/src/Plugin/views/style/Table.php b/core/modules/views/src/Plugin/views/style/Table.php index 3089703..8c02364 100644 --- a/core/modules/views/src/Plugin/views/style/Table.php +++ b/core/modules/views/src/Plugin/views/style/Table.php @@ -9,8 +9,8 @@ use Drupal\Component\Plugin\Discovery\DiscoveryInterface; use Drupal\Component\Utility\Html; +use Drupal\Core\Cache\CacheableDependencyInterface; use Drupal\Core\Form\FormStateInterface; -use Drupal\views\Plugin\CacheablePluginInterface; use Drupal\views\Plugin\views\wizard\WizardInterface; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpFoundation\Request; @@ -28,7 +28,7 @@ * display_types = {"normal"} * ) */ -class Table extends StylePluginBase implements CacheablePluginInterface { +class Table extends StylePluginBase implements CacheableDependencyInterface { /** * Does the style plugin for itself support to add fields to it's output. @@ -432,8 +432,8 @@ public function wizardSubmit(&$form, FormStateInterface $form_state, WizardInter /** * {@inheritdoc} */ - public function isCacheable() { - return TRUE; + public function getCacheMaxAge() { + return 0; } /** @@ -453,4 +453,11 @@ public function getCacheContexts() { return $contexts; } + /** + * {@inheritdoc} + */ + public function getCacheTags() { + return []; + } + }