updated core to 8.6.1 via composer

This commit is contained in:
2018-09-12 13:58:26 +02:00
parent a9a219f2ed
commit ea56b9fba3
4443 changed files with 112098 additions and 40708 deletions
+2 -2
View File
@@ -31,7 +31,6 @@ class Analyzer {
$this->moduleHandler = $module_handler;
}
/**
* Analyzes a review and return the results.
*
@@ -52,7 +51,8 @@ class Analyzer {
/**
* Formats the analyze result into a message string.
*
* This is based upon the format of drupal_set_message which uses separate
* This is based upon the format of
* \Drupal\Core\Messenger\MessengerInterface::addMessage() which uses separate
* boxes for "ok", "warning" and "error".
*/
public function formatMessages(array $messages) {
@@ -132,7 +132,20 @@ class ViewAjaxController implements ContainerInjectionInterface {
// Remove all of this stuff from the query of the request so it doesn't
// end up in pagers and tablesort URLs.
foreach (['view_name', 'view_display_id', 'view_args', 'view_path', 'view_dom_id', 'pager_element', 'view_base_path', AjaxResponseSubscriber::AJAX_REQUEST_PARAMETER] as $key) {
// @todo Remove this parsing once these are removed from the request in
// https://www.drupal.org/node/2504709.
foreach ([
'view_name',
'view_display_id',
'view_args',
'view_path',
'view_dom_id',
'pager_element',
'view_base_path',
AjaxResponseSubscriber::AJAX_REQUEST_PARAMETER,
FormBuilderInterface::AJAX_FORM_REQUEST,
MainContentViewSubscriber::WRAPPER_FORMAT,
] as $key) {
$request->query->remove($key);
$request->request->remove($key);
}
@@ -152,6 +165,7 @@ class ViewAjaxController implements ContainerInjectionInterface {
// Add all POST data, because AJAX is always a post and many things,
// such as tablesorts, exposed filters and paging assume GET.
$request_all = $request->request->all();
unset($request_all['ajax_page_state']);
$query_all = $request->query->all();
$request->query->replace($request_all + $query_all);
@@ -159,13 +173,7 @@ class ViewAjaxController implements ContainerInjectionInterface {
// @see the redirect.destination service.
$origin_destination = $path;
// Remove some special parameters you never want to have part of the
// destination query.
$used_query_parameters = $request->query->all();
// @todo Remove this parsing once these are removed from the request in
// https://www.drupal.org/node/2504709.
unset($used_query_parameters[FormBuilderInterface::AJAX_FORM_REQUEST], $used_query_parameters[MainContentViewSubscriber::WRAPPER_FORMAT], $used_query_parameters['ajax_page_state']);
$query = UrlHelper::buildQuery($used_query_parameters);
if ($query != '') {
$origin_destination .= '?' . $query;
@@ -80,7 +80,7 @@ class DisplayPluginCollection extends DefaultLazyPluginCollection {
// display plugin isn't found.
catch (PluginException $e) {
$message = $e->getMessage();
drupal_set_message(t('@message', ['@message' => $message]), 'warning');
\Drupal::messenger()->addWarning(t('@message', ['@message' => $message]));
}
// If no plugin instance has been created, return NULL.
+11 -1
View File
@@ -19,6 +19,14 @@ use Drupal\views\ViewEntityInterface;
* @ConfigEntityType(
* id = "view",
* label = @Translation("View", context = "View entity type"),
* label_collection = @Translation("Views", context = "View entity type"),
* label_singular = @Translation("view", context = "View entity type"),
* label_plural = @Translation("views", context = "View entity type"),
* label_count = @PluralTranslation(
* singular = "@count view",
* plural = "@count views",
* context = "View entity type",
* ),
* admin_permission = "administer views",
* entity_keys = {
* "id" = "id",
@@ -317,6 +325,8 @@ class View extends ConfigEntityBase implements ViewEntityInterface {
* An array containing display handlers of a view.
*
* @deprecated in Drupal 8.3.0, will be removed in Drupal 9.0.0.
*
* @see https://www.drupal.org/node/2831499
*/
private function fixTableNames(array &$displays) {
// Fix wrong table names for entity revision metadata fields.
@@ -421,7 +431,7 @@ class View extends ConfigEntityBase implements ViewEntityInterface {
'position' => 0,
'display_options' => [],
],
]
],
];
}
+4 -1
View File
@@ -207,7 +207,7 @@ class EntityViewsData implements EntityHandlerInterface, EntityViewsDataInterfac
$data[$base_table]['table']['join'][$data_table] = [
'left_field' => $base_field,
'field' => $base_field,
'type' => 'INNER'
'type' => 'INNER',
];
$data[$data_table]['table']['group'] = $this->entityType->getLabel();
$data[$data_table]['table']['provider'] = $this->entityType->getProvider();
@@ -253,6 +253,9 @@ class EntityViewsData implements EntityHandlerInterface, EntityViewsDataInterfac
}
$this->addEntityLinks($data[$base_table]);
if ($views_revision_base_table) {
$this->addEntityLinks($data[$views_revision_base_table]);
}
// Load all typed data definitions of all fields. This should cover each of
// the entity base, revision, data tables.
@@ -103,7 +103,7 @@ class ViewsExposedForm extends FormBase {
}
$form['actions'] = [
'#type' => 'actions'
'#type' => 'actions',
];
$form['actions']['submit'] = [
// Prevent from showing up in \Drupal::request()->query.
@@ -183,7 +183,7 @@ class ViewsExposedForm extends FormBase {
// https://www.drupal.org/node/342316 is resolved.
$checked = Checkboxes::getCheckedCheckboxes($value);
foreach ($checked as $option_id) {
$view->exposed_raw_input[$option_id] = $value[$option_id];
$view->exposed_raw_input[$key][] = $value[$option_id];
}
}
else {
@@ -11,6 +11,7 @@ use Drupal\views\Views;
* The derivatives store all base table plugin information.
*/
class DefaultWizardDeriver extends DeriverBase {
/**
* {@inheritdoc}
*/
@@ -25,7 +26,7 @@ class DefaultWizardDeriver extends DeriverBase {
'id' => 'standard',
'base_table' => $table,
'title' => $views_info['table']['base']['title'],
'class' => 'Drupal\views\Plugin\views\wizard\Standard'
'class' => 'Drupal\views\Plugin\views\wizard\Standard',
];
}
}
@@ -91,8 +91,8 @@ class ViewsExposedFilterBlock implements ContainerDeriverInterface {
'config_dependencies' => [
'config' => [
$view->getConfigDependencyName(),
]
]
],
],
];
$this->derivatives[$delta] += $base_plugin_definition;
}
@@ -26,7 +26,7 @@ class ViewsSelection extends SelectionPluginBase implements ContainerFactoryPlug
/**
* The loaded View object.
*
* @var \Drupal\views\ViewExecutable;
* @var \Drupal\views\ViewExecutable
*/
protected $view;
@@ -132,7 +132,7 @@ class ViewsSelection extends SelectionPluginBase implements ContainerFactoryPlug
// Check that the view is valid and the display still exists.
$this->view = Views::getView($view_name);
if (!$this->view || !$this->view->access($display_name)) {
drupal_set_message(t('The reference view %view_name cannot be found.', ['%view_name' => $view_name]), 'warning');
\Drupal::messenger()->addWarning(t('The reference view %view_name cannot be found.', ['%view_name' => $view_name]));
return FALSE;
}
$this->view->setDisplay($display_name);
@@ -126,7 +126,6 @@ class ViewsMenuLink extends MenuLinkBase implements ContainerFactoryPluginInterf
return (bool) $this->loadView()->display_handler->getOption('menu')['expanded'];
}
/**
* {@inheritdoc}
*/
@@ -2,7 +2,7 @@
namespace Drupal\views\Plugin\views;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Component\Render\FormattableMarkup;
use Drupal\Core\Form\FormStateInterface;
/**
@@ -55,7 +55,7 @@ trait BrokenHandlerTrait {
foreach ($this->definition['original_configuration'] as $key => $value) {
if (is_scalar($value)) {
$items[] = SafeMarkup::format('@key: @value', ['@key' => $key, '@value' => $value]);
$items[] = new FormattableMarkup('@key: @value', ['@key' => $key, '@value' => $value]);
}
}
@@ -230,9 +230,9 @@ abstract class HandlerBase extends PluginBase implements ViewsHandlerInterface {
default:
return $string;
case 'upper':
return Unicode::strtoupper($string);
return mb_strtoupper($string);
case 'lower':
return Unicode::strtolower($string);
return mb_strtolower($string);
case 'ucfirst':
return Unicode::ucfirst($string);
case 'ucwords':
@@ -313,6 +313,7 @@ abstract class HandlerBase extends PluginBase implements ViewsHandlerInterface {
public function usesGroupBy() {
return TRUE;
}
/**
* Provide a form for aggregation settings.
*/
@@ -400,7 +400,7 @@ abstract class PluginBase extends ComponentPluginBase implements ContainerFactor
'#post_render' => [
function ($children, $elements) {
return Xss::filterAdmin($children);
}
},
],
];
@@ -115,11 +115,13 @@ class Result extends AreaPluginBase {
// Send the output.
if (!empty($total) || !empty($this->options['empty'])) {
$output .= Xss::filterAdmin(str_replace(array_keys($replacements), array_values($replacements), $format));
// Return as render array.
return [
'#markup' => $output,
];
}
// Return as render array.
return [
'#markup' => $output,
];
return [];
}
}
@@ -118,7 +118,7 @@ class View extends AreaPluginBase {
// Check if the view is part of the parent views of this view
$search = "$view_name:$display_id";
if (in_array($search, $this->view->parent_views)) {
drupal_set_message(t("Recursion detected in view @view display @display.", ['@view' => $view_name, '@display' => $display_id]), 'error');
\Drupal::messenger()->addError(t("Recursion detected in view @view display @display.", ['@view' => $view_name, '@display' => $display_id]));
}
else {
if (!empty($this->options['inherit_arguments']) && !empty($this->view->args)) {
@@ -398,7 +398,6 @@ abstract class ArgumentPluginBase extends HandlerBase implements CacheableDepend
return $output;
}
public function validateOptionsForm(&$form, FormStateInterface $form_state) {
$option_values = &$form_state->getValue('options');
if (empty($option_values)) {
@@ -550,7 +549,7 @@ abstract class ArgumentPluginBase extends HandlerBase implements CacheableDepend
'#type' => 'checkbox',
'#title' => $this->t('Skip default argument for view URL'),
'#default_value' => $this->options['default_argument_skip_url'],
'#description' => $this->t('Select whether to include this default argument when constructing the URL for this view. Skipping default arguments is useful e.g. in the case of feeds.')
'#description' => $this->t('Select whether to include this default argument when constructing the URL for this view. Skipping default arguments is useful e.g. in the case of feeds.'),
];
$form['default_argument_type'] = [
@@ -640,7 +639,7 @@ abstract class ArgumentPluginBase extends HandlerBase implements CacheableDepend
'#default_value' => $this->options['summary']['number_of_records'],
'#options' => [
0 => $this->getSortName(),
1 => $this->t('Number of records')
1 => $this->t('Number of records'),
],
'#states' => [
'visible' => [
@@ -721,6 +720,7 @@ abstract class ArgumentPluginBase extends HandlerBase implements CacheableDepend
$info = $this->defaultActions($this->options['validate']['fail']);
return $this->defaultAction($info);
}
/**
* Default action: ignore.
*
@@ -105,16 +105,16 @@ class NumericArgument extends ArgumentPluginBase {
}
$placeholder = $this->placeholder();
$null_check = empty($this->options['not']) ? '' : "OR $this->tableAlias.$this->realField IS NULL";
$null_check = empty($this->options['not']) ? '' : " OR $this->tableAlias.$this->realField IS NULL";
if (count($this->value) > 1) {
$operator = empty($this->options['not']) ? 'IN' : 'NOT IN';
$placeholder .= '[]';
$this->query->addWhereExpression(0, "$this->tableAlias.$this->realField $operator($placeholder) $null_check", [$placeholder => $this->value]);
$this->query->addWhereExpression(0, "$this->tableAlias.$this->realField $operator($placeholder)" . $null_check, [$placeholder => $this->value]);
}
else {
$operator = empty($this->options['not']) ? '=' : '!=';
$this->query->addWhereExpression(0, "$this->tableAlias.$this->realField $operator $placeholder $null_check", [$placeholder => $this->argument]);
$this->query->addWhereExpression(0, "$this->tableAlias.$this->realField $operator $placeholder" . $null_check, [$placeholder => $this->argument]);
}
}
@@ -2,7 +2,6 @@
namespace Drupal\views\Plugin\views\argument;
use Drupal\Component\Utility\Unicode;
use Drupal\Core\Database\Database;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Plugin\Context\ContextDefinition;
@@ -214,7 +213,7 @@ class StringArgument extends ArgumentPluginBase {
// converting the arguments to lowercase.
if ($this->options['case'] != 'none' && Database::getConnection()->databaseType() == 'pgsql') {
foreach ($this->value as $key => $value) {
$this->value[$key] = Unicode::strtolower($value);
$this->value[$key] = mb_strtolower($value);
}
}
@@ -5,7 +5,7 @@ namespace Drupal\views\Plugin\views\argument_validator;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityManagerInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Plugin\Context\ContextDefinition;
use Drupal\Core\Plugin\Context\EntityContextDefinition;
use Drupal\views\Plugin\views\argument\ArgumentPluginBase;
use Symfony\Component\DependencyInjection\ContainerInterface;
@@ -233,7 +233,9 @@ class Entity extends ArgumentValidatorPluginBase {
* {@inheritdoc}
*/
public function getContextDefinition() {
return new ContextDefinition('entity:' . $this->definition['entity_type'], $this->argument->adminLabel(), FALSE);
return EntityContextDefinition::fromEntityTypeId($this->definition['entity_type'])
->setLabel($this->argument->adminLabel())
->setRequired(FALSE);
}
}
@@ -97,6 +97,9 @@ abstract class CachePluginBase extends PluginBase {
* Save data to the cache.
*
* A plugin should override this to provide specialized caching behavior.
*
* @param $type
* The cache type, either 'query', 'result'.
*/
public function cacheSet($type) {
switch ($type) {
@@ -119,6 +122,12 @@ abstract class CachePluginBase extends PluginBase {
* Retrieve data from the cache.
*
* A plugin should override this to provide specialized caching behavior.
*
* @param $type
* The cache type, either 'query', 'result'.
*
* @return bool
* TRUE if data has been taken from the cache, otherwise FALSE.
*/
public function cacheGet($type) {
$cutoff = $this->cacheExpire($type);
@@ -154,19 +163,22 @@ abstract class CachePluginBase extends PluginBase {
/**
* Post process any rendered data.
*
* This can be valuable to be able to cache a view and still have some level of
* dynamic output. In an ideal world, the actual output will include HTML
* This can be valuable to be able to cache a view and still have some level
* of dynamic output. In an ideal world, the actual output will include HTML
* comment based tokens, and then the post process can replace those tokens.
*
* Example usage. If it is known that the view is a node view and that the
* primary field will be a nid, you can do something like this:
*
* <!--post-FIELD-NID-->
* @code
* <!--post-FIELD-NID-->
* @endcode
*
* And then in the post render, create an array with the text that should
* go there:
*
* strtr($output, array('<!--post-FIELD-1-->', 'output for FIELD of nid 1');
* @code
* strtr($output, array('<!--post-FIELD-1-->', 'output for FIELD of nid 1');
* @endcode
*
* All of the cached result data will be available in $view->result, as well,
* so all ids used in the query should be discoverable.
-1
View File
@@ -19,7 +19,6 @@ class None extends CachePluginBase {
return $this->t('None');
}
/**
* Overrides \Drupal\views\Plugin\views\cache\CachePluginBase::cacheGet().
*
@@ -2,6 +2,8 @@
namespace Drupal\views\Plugin\views\display;
use Drupal\Component\Plugin\Discovery\CachedDiscoveryInterface;
use Drupal\Core\Block\BlockManagerInterface;
use Drupal\Core\Entity\EntityManagerInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\views\Plugin\Block\ViewsBlock;
@@ -42,6 +44,13 @@ class Block extends DisplayPluginBase {
*/
protected $entityManager;
/**
* The block manager.
*
* @var \Drupal\Core\Block\BlockManagerInterface
*/
protected $blockManager;
/**
* Constructs a new Block instance.
*
@@ -53,11 +62,14 @@ class Block extends DisplayPluginBase {
* The plugin implementation definition.
* @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager
* The entity manager.
* @param \Drupal\Core\Block\BlockManagerInterface $block_manager
* The block manager.
*/
public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityManagerInterface $entity_manager) {
public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityManagerInterface $entity_manager, BlockManagerInterface $block_manager) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->entityManager = $entity_manager;
$this->blockManager = $block_manager;
}
/**
@@ -68,7 +80,8 @@ class Block extends DisplayPluginBase {
$configuration,
$plugin_id,
$plugin_definition,
$container->get('entity.manager')
$container->get('entity.manager'),
$container->get('plugin.manager.block')
);
}
@@ -364,6 +377,9 @@ class Block extends DisplayPluginBase {
$block->delete();
}
}
if ($this->blockManager instanceof CachedDiscoveryInterface) {
$this->blockManager->clearCachedDefinitions();
}
}
}
@@ -4,7 +4,7 @@ namespace Drupal\views\Plugin\views\display;
use Drupal\Component\Plugin\DependentPluginInterface;
use Drupal\Component\Utility\Html;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Component\Render\FormattableMarkup;
use Drupal\Core\Cache\Cache;
use Drupal\Core\Cache\CacheableMetadata;
use Drupal\Core\Cache\CacheableDependencyInterface;
@@ -962,7 +962,6 @@ abstract class DisplayPluginBase extends PluginBase implements DisplayPluginInte
return $this->dependencies;
}
/**
* {@inheritdoc}
*/
@@ -1022,7 +1021,7 @@ abstract class DisplayPluginBase extends PluginBase implements DisplayPluginInte
}
if (!empty($class)) {
$text = SafeMarkup::format('<span>@text</span>', ['@text' => $text]);
$text = new FormattableMarkup('<span>@text</span>', ['@text' => $text]);
}
if (empty($title)) {
@@ -1033,13 +1032,13 @@ abstract class DisplayPluginBase extends PluginBase implements DisplayPluginInte
'js' => 'nojs',
'view' => $this->view->storage->id(),
'display_id' => $this->display['id'],
'type' => $section
'type' => $section,
], [
'attributes' => [
'class' => ['views-ajax-link', $class],
'title' => $title,
'id' => Html::getUniqueId('views-' . $this->display['id'] . '-' . $section)
]
'id' => Html::getUniqueId('views-' . $this->display['id'] . '-' . $section),
],
]));
}
@@ -2587,7 +2586,7 @@ abstract class DisplayPluginBase extends PluginBase implements DisplayPluginInte
public function getPagerText() {
return [
'items per page title' => $this->t('Items to display'),
'items per page description' => $this->t('Enter 0 for no limit.')
'items per page description' => $this->t('Enter 0 for no limit.'),
];
}
@@ -457,7 +457,6 @@ interface DisplayPluginInterface {
*/
public function execute();
/**
* Builds a basic render array which can be properly render cached.
*
@@ -20,6 +20,11 @@ namespace Drupal\views\Plugin\views\display;
*/
class Embed extends DisplayPluginBase {
/**
* {@inheritdoc}
*/
protected $usesAttachments = TRUE;
/**
* {@inheritdoc}
*/
@@ -54,9 +54,6 @@ class EntityReference extends DisplayPluginBase {
$options['row']['contains']['type'] = ['default' => 'entity_reference'];
$options['defaults']['default']['row'] = FALSE;
// Make sure the query is not cached.
$options['defaults']['default']['cache'] = FALSE;
// Set the display title to an empty string (not used in this display type).
$options['title']['default'] = '';
$options['defaults']['default']['title'] = FALSE;
@@ -65,13 +62,12 @@ class EntityReference extends DisplayPluginBase {
}
/**
* Overrides \Drupal\views\Plugin\views\display\DisplayPluginBase::optionsSummary().
*
* Disable 'cache' and 'title' so it won't be changed.
* {@inheritdoc}
*/
public function optionsSummary(&$categories, &$options) {
parent::optionsSummary($categories, $options);
unset($options['query']);
// Disable 'title' so it won't be changed from the default set in
// \Drupal\views\Plugin\views\display\EntityReference::defineOptions.
unset($options['title']);
}
@@ -73,7 +73,6 @@ class Feed extends PathPluginBase implements ResponseDisplayPluginInterface {
return $response;
}
/**
* {@inheritdoc}
*/
@@ -141,7 +140,7 @@ class Feed extends PathPluginBase implements ResponseDisplayPluginInterface {
// Overrides for standard stuff.
$options['style']['contains']['type']['default'] = 'rss';
$options['style']['contains']['options']['default'] = ['description' => ''];
$options['style']['contains']['options']['default'] = ['description' => ''];
$options['sitename_title']['default'] = FALSE;
$options['row']['contains']['type']['default'] = 'rss_fields';
$options['defaults']['default']['style'] = FALSE;
@@ -259,7 +259,7 @@ class Page extends PathPluginBase {
'none' => $this->t('No menu entry'),
'normal' => $this->t('Normal menu entry'),
'tab' => $this->t('Menu tab'),
'default tab' => $this->t('Default menu tab')
'default tab' => $this->t('Default menu tab'),
],
'#default_value' => $menu['type'],
];
@@ -532,7 +532,7 @@ class Page extends PathPluginBase {
public function getPagerText() {
return [
'items per page title' => $this->t('Items per page'),
'items per page description' => $this->t('Enter 0 for no limit.')
'items per page description' => $this->t('Enter 0 for no limit.'),
];
}
@@ -8,6 +8,7 @@ use Drupal\Core\Entity\EntityManagerInterface;
use Drupal\Core\Entity\RevisionableInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Language\LanguageManagerInterface;
use Drupal\Core\Messenger\MessengerInterface;
use Drupal\Core\Routing\RedirectDestinationTrait;
use Drupal\Core\TypedData\TranslatableInterface;
use Drupal\views\Entity\Render\EntityTranslationRenderTrait;
@@ -56,6 +57,13 @@ class BulkForm extends FieldPluginBase implements CacheableDependencyInterface {
*/
protected $languageManager;
/**
* The messenger.
*
* @var \Drupal\Core\Messenger\MessengerInterface
*/
protected $messenger;
/**
* Constructs a new BulkForm object.
*
@@ -69,13 +77,18 @@ class BulkForm extends FieldPluginBase implements CacheableDependencyInterface {
* The entity manager.
* @param \Drupal\Core\Language\LanguageManagerInterface $language_manager
* The language manager.
* @param \Drupal\Core\Messenger\MessengerInterface $messenger
* The messenger.
*
* @throws \Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
*/
public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityManagerInterface $entity_manager, LanguageManagerInterface $language_manager) {
public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityManagerInterface $entity_manager, LanguageManagerInterface $language_manager, MessengerInterface $messenger) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->entityManager = $entity_manager;
$this->actionStorage = $entity_manager->getStorage('action');
$this->languageManager = $language_manager;
$this->messenger = $messenger;
}
/**
@@ -87,7 +100,8 @@ class BulkForm extends FieldPluginBase implements CacheableDependencyInterface {
$plugin_id,
$plugin_definition,
$container->get('entity.manager'),
$container->get('language_manager')
$container->get('language_manager'),
$container->get('messenger')
);
}
@@ -356,11 +370,11 @@ class BulkForm extends FieldPluginBase implements CacheableDependencyInterface {
// Skip execution if the user did not have access.
if (!$action->getPlugin()->access($entity, $this->view->getUser())) {
$this->drupalSetMessage($this->t('No access to execute %action on the @entity_type_label %entity_label.', [
$this->messenger->addError($this->t('No access to execute %action on the @entity_type_label %entity_label.', [
'%action' => $action->label(),
'@entity_type_label' => $entity->getEntityType()->getLabel(),
'%entity_label' => $entity->label()
]), 'error');
'%entity_label' => $entity->label(),
]));
continue;
}
@@ -382,7 +396,7 @@ class BulkForm extends FieldPluginBase implements CacheableDependencyInterface {
// Don't display the message unless there are some elements affected and
// there is no confirmation form.
if ($count) {
drupal_set_message($this->formatPlural($count, '%action was applied to @count item.', '%action was applied to @count items.', [
$this->messenger->addStatus($this->formatPlural($count, '%action was applied to @count item.', '%action was applied to @count items.', [
'%action' => $action->label(),
]));
}
@@ -426,13 +440,6 @@ class BulkForm extends FieldPluginBase implements CacheableDependencyInterface {
return FALSE;
}
/**
* Wraps drupal_set_message().
*/
protected function drupalSetMessage($message = NULL, $type = 'status', $repeat = FALSE) {
drupal_set_message($message, $type, $repeat);
}
/**
* Calculates a bulk form key.
*
@@ -408,10 +408,10 @@ class EntityField extends FieldPluginBase implements CacheableDependencyInterfac
];
$options['multi_type'] = [
'default' => 'separator'
'default' => 'separator',
];
$options['separator'] = [
'default' => ', '
'default' => ', ',
];
$options['field_api_classes'] = [
@@ -158,6 +158,7 @@ class EntityOperations extends FieldPluginBase {
protected function getLanguageManager() {
return $this->languageManager;
}
/**
* {@inheritdoc}
*/
@@ -4,7 +4,6 @@ namespace Drupal\views\Plugin\views\field;
use Drupal\Component\Utility\Html;
use Drupal\Component\Render\MarkupInterface;
use Drupal\Component\Utility\Unicode;
use Drupal\Component\Utility\UrlHelper;
use Drupal\Component\Utility\Xss;
use Drupal\Core\Form\FormStateInterface;
@@ -186,7 +185,13 @@ abstract class FieldPluginBase extends HandlerBase implements FieldHandlerInterf
}
if (empty($table_alias)) {
debug(t('Handler @handler tried to add additional_field @identifier but @table could not be added!', ['@handler' => $this->definition['id'], '@identifier' => $identifier, '@table' => $info['table']]));
trigger_error(sprintf(
"Handler % tried to add additional_field %s but % could not be added!",
$this->definition['id'],
$identifier,
$info['table']
), E_USER_WARNING);
$this->aliases[$identifier] = 'broken';
continue;
}
@@ -312,7 +317,7 @@ abstract class FieldPluginBase extends HandlerBase implements FieldHandlerInterf
// @todo Add possible html5 elements.
$elements = [
'' => $this->t('- Use default -'),
'0' => $this->t('- None -')
'0' => $this->t('- None -'),
];
$elements += \Drupal::config('views.settings')->get('field_rewrite_elements');
}
@@ -1288,7 +1293,7 @@ abstract class FieldPluginBase extends HandlerBase implements FieldHandlerInterf
$base_path = base_path();
// Checks whether the path starts with the base_path.
if (strpos($more_link_path, $base_path) === 0) {
$more_link_path = Unicode::substr($more_link_path, Unicode::strlen($base_path));
$more_link_path = mb_substr($more_link_path, mb_strlen($base_path));
}
// @todo Views should expect and store a leading /. See
@@ -1388,7 +1393,7 @@ abstract class FieldPluginBase extends HandlerBase implements FieldHandlerInterf
];
$alter += [
'path' => NULL
'path' => NULL,
];
$path = $alter['path'];
@@ -1792,8 +1797,8 @@ abstract class FieldPluginBase extends HandlerBase implements FieldHandlerInterf
* The trimmed string.
*/
public static function trimText($alter, $value) {
if (Unicode::strlen($value) > $alter['max_length']) {
$value = Unicode::substr($value, 0, $alter['max_length']);
if (mb_strlen($value) > $alter['max_length']) {
$value = mb_substr($value, 0, $alter['max_length']);
if (!empty($alter['word_boundary'])) {
$regex = "(.*)\b.+";
if (function_exists('mb_ereg')) {
@@ -18,7 +18,9 @@ use Drupal\views\ResultRow;
class MachineName extends FieldPluginBase {
/**
* @var array Stores the available options.
* Stores the available options.
*
* @var array
*/
protected $valueOptions;
@@ -78,8 +78,8 @@ abstract class PrerenderList extends FieldPluginBase implements MultiItemsFieldH
'#template' => '{{ items|safe_join(separator) }}',
'#context' => [
'items' => $items,
'separator' => $this->sanitizeValue($this->options['separator'], 'xss_admin')
]
'separator' => $this->sanitizeValue($this->options['separator'], 'xss_admin'),
],
];
}
else {
@@ -48,7 +48,6 @@ class BooleanOperator extends FilterPluginBase {
// Whether to accept NULL as a false value or not
public $accept_null = FALSE;
/**
* {@inheritdoc}
*/
@@ -656,7 +656,6 @@ abstract class FilterPluginBase extends HandlerBase implements CacheableDependen
return FALSE;
}
/**
* Validate the build group options form.
*/
@@ -835,7 +834,6 @@ abstract class FilterPluginBase extends HandlerBase implements CacheableDependen
}
}
/**
* Render our chunk of the exposed filter form when selecting
*
@@ -1105,7 +1103,7 @@ abstract class FilterPluginBase extends HandlerBase implements CacheableDependen
'#required' => TRUE,
'#attributes' => [
'class' => ['default-radios'],
]
],
];
// From all groups, let chose which is the default.
$form['group_info']['default_group_multiple'] = [
@@ -1114,7 +1112,7 @@ abstract class FilterPluginBase extends HandlerBase implements CacheableDependen
'#default_value' => $this->options['group_info']['default_group_multiple'],
'#attributes' => [
'class' => ['default-checkboxes'],
]
],
];
$form['group_info']['add_group'] = [
@@ -1165,7 +1163,6 @@ abstract class FilterPluginBase extends HandlerBase implements CacheableDependen
$form_state->get('force_build_group_options', TRUE);
}
/**
* Make some translations to a form item to make it more suitable to
* exposing.
@@ -1207,7 +1204,6 @@ abstract class FilterPluginBase extends HandlerBase implements CacheableDependen
}
}
/**
* Sanitizes the HTML select element's options.
*
@@ -20,6 +20,7 @@ class GroupByNumeric extends NumericFilter {
$this->{$info[$this->operator]['method']}($field);
}
}
protected function opBetween($field) {
$placeholder_min = $this->placeholder();
$placeholder_max = $this->placeholder();
@@ -369,7 +369,7 @@ class InOperator extends FilterPluginBase {
if ($values !== '') {
$values .= ', ';
}
if (Unicode::strlen($values) > 8) {
if (mb_strlen($values) > 8) {
$values = Unicode::truncate($values, 8, FALSE, TRUE);
break;
}
@@ -103,6 +103,7 @@ class ManyToOne extends InOperator {
}
protected $valueFormType = 'select';
protected function valueForm(&$form, FormStateInterface $form_state) {
parent::valueForm($form, $form_state);
@@ -190,6 +190,7 @@ class NumericFilter extends FilterPluginBase {
return $options;
}
/**
* Provide a simple textfield for equality
*/
@@ -299,7 +300,7 @@ class NumericFilter extends FilterPluginBase {
// Ensure there is something in the 'value'.
$form['value'] = [
'#type' => 'value',
'#value' => NULL
'#value' => NULL,
];
}
}
@@ -257,7 +257,7 @@ class StringFilter extends FilterPluginBase {
// Ensure there is something in the 'value'.
$form['value'] = [
'#type' => 'value',
'#value' => NULL
'#value' => NULL,
];
}
}
@@ -226,7 +226,7 @@ class JoinPluginBase extends PluginBase implements JoinPluginInterface {
// Merge in some default values.
$configuration += [
'type' => 'LEFT',
'extra_operator' => 'AND'
'extra_operator' => 'AND',
];
$this->configuration = $configuration;
@@ -281,6 +281,7 @@ class JoinPluginBase extends PluginBase implements JoinPluginInterface {
$select_query->addJoin($this->type, $right_table, $table['alias'], $condition, $arguments);
}
/**
* Adds the extras to the join condition.
*
@@ -233,7 +233,6 @@ abstract class SqlBase extends PagerPluginBase implements CacheableDependencyInt
$this->view->query->setOffset($offset);
}
/**
* Set the current page.
*
@@ -8,6 +8,7 @@ use Drupal\Core\Database\Database;
use Drupal\Core\Database\Query\Condition;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Messenger\MessengerInterface;
use Drupal\views\Plugin\views\display\DisplayPluginBase;
use Drupal\Core\Database\DatabaseExceptionWrapper;
use Drupal\views\Plugin\views\join\JoinPluginBase;
@@ -130,6 +131,13 @@ class Sql extends QueryPluginBase {
*/
protected $dateSql;
/**
* The messenger.
*
* @var \Drupal\Core\Messenger\MessengerInterface
*/
protected $messenger;
/**
* Constructs a Sql object.
*
@@ -143,21 +151,28 @@ class Sql extends QueryPluginBase {
* The entity type manager.
* @param \Drupal\views\Plugin\views\query\DateSqlInterface $date_sql
* The database-specific date handler.
* @param \Drupal\Core\Messenger\MessengerInterface $messenger
* The messenger.
*/
public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityTypeManagerInterface $entity_type_manager, DateSqlInterface $date_sql) {
public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityTypeManagerInterface $entity_type_manager, DateSqlInterface $date_sql, MessengerInterface $messenger) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->entityTypeManager = $entity_type_manager;
$this->dateSql = $date_sql;
$this->messenger = $messenger;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static(
$configuration,
$plugin_id,
$plugin_definition,
$container->get('entity_type.manager'),
$container->get('views.date_sql')
$container->get('views.date_sql'),
$container->get('messenger')
);
}
@@ -173,7 +188,7 @@ class Sql extends QueryPluginBase {
'link' => NULL,
'table' => $base_table,
'alias' => $base_table,
'base' => $base_table
'base' => $base_table,
];
// init the table queue with our primary table.
@@ -1030,7 +1045,7 @@ class Sql extends QueryPluginBase {
$this->orderby[] = [
'field' => $as,
'direction' => strtoupper($order)
'direction' => strtoupper($order),
];
}
@@ -1498,7 +1513,7 @@ class Sql extends QueryPluginBase {
if (!empty($this->limit) || !empty($this->offset)) {
// We can't have an offset without a limit, so provide a very large limit instead.
$limit = intval(!empty($this->limit) ? $this->limit : 999999);
$limit = intval(!empty($this->limit) ? $this->limit : 999999);
$offset = intval(!empty($this->offset) ? $this->offset : 0);
$query->range($offset, $limit);
}
@@ -1522,7 +1537,7 @@ class Sql extends QueryPluginBase {
catch (DatabaseExceptionWrapper $e) {
$view->result = [];
if (!empty($view->live_preview)) {
drupal_set_message($e->getMessage(), 'error');
$this->messenger->addError($e->getMessage());
}
else {
throw new DatabaseExceptionWrapper("Exception in {$view->storage->label()}[{$view->storage->id()}]: {$e->getMessage()}");
@@ -1778,7 +1793,7 @@ class Sql extends QueryPluginBase {
'filter' => 'groupby_numeric',
'sort' => 'groupby_numeric',
],
]
],
];
}
@@ -53,7 +53,7 @@ class EntityReverse extends RelationshipPluginBase {
'left_field' => $left_field,
'table' => $this->definition['field table'],
'field' => $this->definition['field field'],
'adjusted' => TRUE
'adjusted' => TRUE,
];
if (!empty($this->options['required'])) {
$first['type'] = 'INNER';
@@ -80,7 +80,7 @@ class EntityReverse extends RelationshipPluginBase {
'left_field' => 'entity_id',
'table' => $this->definition['base'],
'field' => $this->definition['base field'],
'adjusted' => TRUE
'adjusted' => TRUE,
];
if (!empty($this->options['required'])) {
@@ -56,8 +56,8 @@ class Opml extends StylePluginBase {
*/
public function render() {
if (empty($this->view->rowPlugin)) {
debug('Drupal\views\Plugin\views\style\Opml: Missing row plugin');
return;
trigger_error('Drupal\views\Plugin\views\style\Opml: Missing row plugin', E_WARNING);
return [];
}
$rows = [];
@@ -98,7 +98,7 @@ class Rss extends StylePluginBase {
public function render() {
if (empty($this->view->rowPlugin)) {
debug('Drupal\views\Plugin\views\style\Rss: Missing row plugin');
trigger_error('Drupal\views\Plugin\views\style\Rss: Missing row plugin', E_WARNING);
return [];
}
$rows = [];
@@ -457,8 +457,8 @@ abstract class StylePluginBase extends PluginBase {
*/
public function render() {
if ($this->usesRowPlugin() && empty($this->view->rowPlugin)) {
debug('Drupal\views\Plugin\views\style\StylePluginBase: Missing row plugin');
return;
trigger_error('Drupal\views\Plugin\views\style\StylePluginBase: Missing row plugin', E_WARNING);
return [];
}
// Group the rows according to the grouping instructions, if specified.
@@ -177,7 +177,7 @@ abstract class WizardPluginBase extends PluginBase implements WizardInterface {
'plugin_id' => 'boolean',
'entity_type' => $this->entityTypeId,
'entity_field' => $field_name,
]
],
] + $this->filters;
}
@@ -45,7 +45,7 @@ class FieldApiDataTest extends FieldTestBase {
'field_name' => $field_names[0],
'entity_type' => 'node',
'bundle' => 'page',
'label' => 'GiraffeA" label'
'label' => 'GiraffeA" label',
];
FieldConfig::create($field)->save();
@@ -55,7 +55,7 @@ class FieldApiDataTest extends FieldTestBase {
'field_name' => $field_names[0],
'entity_type' => 'node',
'bundle' => 'article',
'label' => 'GiraffeB" label'
'label' => 'GiraffeB" label',
])->save();
// Now create some example nodes/users for the view result.
@@ -230,7 +230,7 @@ class FieldApiDataTest extends FieldTestBase {
'field_name' => $this->fieldStorages[0]->getName(),
'entity_type' => 'node',
'bundle' => 'news',
'label' => 'GiraffeB" label'
'label' => 'GiraffeB" label',
])->save();
$this->container->get('views.views_data')->clear();
$data = $this->getViewsData();
@@ -1,41 +0,0 @@
<?php
namespace Drupal\views\Tests\Update;
use Drupal\system\Tests\Update\UpdatePathTestBase;
use Drupal\views\Entity\View;
/**
* Tests that the additional settings are added to the entity link field.
*
* @see views_post_update_entity_link_url()
*
* @group Update
*/
class EntityLinkOutputUrlUpdateTest extends UpdatePathTestBase {
/**
* {@inheritdoc}
*/
protected function setDatabaseDumpFiles() {
$this->databaseDumpFiles = [
__DIR__ . '/../../../../system/tests/fixtures/update/drupal-8.bare.standard.php.gz',
__DIR__ . '/../../../tests/fixtures/update/entity-link-output-url.php',
];
}
/**
* Tests that the additional settings are added to the config.
*/
public function testViewsPostUpdateEntityLinkUrl() {
$this->runUpdates();
// Load and initialize our test view.
$view = View::load('node_link_update_test');
$data = $view->toArray();
// Check that the field contains the new values.
$this->assertIdentical(FALSE, $data['display']['default']['display_options']['fields']['view_node']['output_url_as_text']);
$this->assertIdentical(FALSE, $data['display']['default']['display_options']['fields']['view_node']['absolute']);
}
}
@@ -1,54 +0,0 @@
<?php
namespace Drupal\views\Tests\Update;
use Drupal\system\Tests\Update\UpdatePathTestBase;
use Drupal\views\Views;
/**
* Tests the upgrade path for views multi-value base field data.
*
* @see views_update_8500()
*
* @group Update
*/
class EntityViewsMultiValueBaseFieldDataUpdateTest extends UpdatePathTestBase {
/**
* {@inheritdoc}
*/
protected function setDatabaseDumpFiles() {
$this->databaseDumpFiles = [
__DIR__ . '/../../../../system/tests/fixtures/update/drupal-8.bare.standard.php.gz',
__DIR__ . '/../../../../system/tests/fixtures/update/drupal-8.views-entity-views-data-2846614.php',
];
}
/**
* Tests multi-value base field views data is updated correctly.
*/
public function testUpdateMultiValueBaseFields() {
$this->runUpdates();
$view = Views::getView('test_user_multi_value');
$display = $view->storage->get('display');
// Check each handler type present in the configuration to make sure the
// field got updated correctly.
foreach (['fields', 'filters', 'arguments'] as $type) {
$handler_config = $display['default']['display_options'][$type]['roles'];
// The ID should remain unchanged. Otherwise the update handler could
// overwrite a separate handler config.
$this->assertEqual('roles', $handler_config['id']);
// The field should be updated from 'roles' to the correct column name.
$this->assertEqual('roles_target_id', $handler_config['field']);
// Check the table is still correct.
$this->assertEqual('user__roles', $handler_config['table']);
// The plugin ID should be updated as well.
$this->assertEqual($type === 'arguments' ? 'user__roles_rid' : 'user_roles', $handler_config['plugin_id']);
}
}
}
@@ -1,74 +0,0 @@
<?php
namespace Drupal\views\Tests;
use Drupal\Component\Serialization\Json;
use Drupal\Core\EventSubscriber\MainContentViewSubscriber;
/**
* Tests the ajax view functionality.
*
* @group views
*/
class ViewAjaxTest extends ViewTestBase {
/**
* Views used by this test.
*
* @var array
*/
public static $testViews = ['test_ajax_view', 'test_view'];
protected function setUp($import_test_views = TRUE) {
parent::setUp($import_test_views);
$this->enableViewsTestModule();
}
/**
* Tests an ajax view.
*/
public function testAjaxView() {
$this->drupalGet('test_ajax_view');
$drupal_settings = $this->getDrupalSettings();
$this->assertTrue(isset($drupal_settings['views']['ajax_path']), 'The Ajax callback path is set in drupalSettings.');
$this->assertEqual(count($drupal_settings['views']['ajaxViews']), 1);
$view_entry = array_keys($drupal_settings['views']['ajaxViews'])[0];
$this->assertEqual($drupal_settings['views']['ajaxViews'][$view_entry]['view_name'], 'test_ajax_view', 'The view\'s ajaxViews array entry has the correct \'view_name\' key.');
$this->assertEqual($drupal_settings['views']['ajaxViews'][$view_entry]['view_display_id'], 'page_1', 'The view\'s ajaxViews array entry has the correct \'view_display_id\' key.');
$data = [];
$data['view_name'] = 'test_ajax_view';
$data['view_display_id'] = 'test_ajax_view';
$post = [
'view_name' => 'test_ajax_view',
'view_display_id' => 'page_1',
];
$post += $this->getAjaxPageStatePostData();
$response = $this->drupalPost('views/ajax', '', $post, ['query' => [MainContentViewSubscriber::WRAPPER_FORMAT => 'drupal_ajax']]);
$data = Json::decode($response);
$this->assertTrue(isset($data[0]['settings']['views']['ajaxViews']));
// Ensure that the view insert command is part of the result.
$this->assertEqual($data[1]['command'], 'insert');
$this->assertTrue(strpos($data[1]['selector'], '.js-view-dom-id-') === 0);
$this->setRawContent($data[1]['data']);
$result = $this->xpath('//div[contains(@class, "views-row")]');
$this->assertEqual(count($result), 2, 'Ensure that two items are rendered in the HTML.');
}
/**
* Ensures that non-ajax view cannot be accessed via an ajax HTTP request.
*/
public function testNonAjaxViewViaAjax() {
$this->drupalPost('views/ajax', '', ['view_name' => 'test_ajax_view', 'view_display_id' => 'default'], ['query' => [MainContentViewSubscriber::WRAPPER_FORMAT => 'drupal_ajax']]);
$this->assertResponse(200);
$this->drupalPost('views/ajax', '', ['view_name' => 'test_view', 'view_display_id' => 'default'], ['query' => [MainContentViewSubscriber::WRAPPER_FORMAT => 'drupal_ajax']]);
$this->assertResponse(403);
}
}
@@ -108,7 +108,7 @@ class ViewTestData {
],
'primary key' => ['id'],
'unique keys' => [
'name' => ['name']
'name' => ['name'],
],
'indexes' => [
'ages' => ['age'],
+6 -3
View File
@@ -1096,7 +1096,8 @@ class ViewExecutable {
$argument->is_default = TRUE;
}
// Set the argument, which will also validate that the argument can be set.
// Set the argument, which ensures that the argument is valid and
// possibly transforms the value.
if (!$argument->setArgument($arg)) {
$status = $argument->validateFail($arg);
break;
@@ -1110,9 +1111,11 @@ class ViewExecutable {
$argument->query($this->display_handler->useGroupBy());
}
// Add this argument's substitution
// Add this argument's substitution.
$substitutions["{{ arguments.$id }}"] = $arg_title;
$substitutions["{{ raw_arguments.$id }}"] = strip_tags(Html::decodeEntities($arg));
// Since argument validator plugins can potentially transform the value,
// use whatever value the argument handler now has, not the raw value.
$substitutions["{{ raw_arguments.$id }}"] = strip_tags(Html::decodeEntities($argument->getValue()));
// Test to see if we should use this argument's title
if (!empty($argument->options['title_enable']) && !empty($argument->options['title'])) {
+2 -4
View File
@@ -133,10 +133,8 @@ class ViewsData {
*
* @param string|null $key
* The key of the cache entry to retrieve. Defaults to NULL, this will
* return all table data.
*
* @deprecated NULL $key deprecated in Drupal 8.2.x and will be removed in
* 9.0.0. Use getAll() instead.
* return all table data. NULL $key deprecated in Drupal 8.2.x and will be
* removed in 9.0.0. Use getAll() instead.
*
* @see https://www.drupal.org/node/2723553
*
+6 -7
View File
@@ -2,8 +2,7 @@
namespace Drupal\views;
use Drupal\Component\Utility\Unicode;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Component\Render\FormattableMarkup;
/**
* Defines a helper class for stuff related to views data.
@@ -120,7 +119,7 @@ class ViewsDataHelper {
}
else {
if ($string != 'base') {
$strings[$field][$key][$string] = SafeMarkup::format("Error: missing @component", ['@component' => $string]);
$strings[$field][$key][$string] = new FormattableMarkup("Error: missing @component", ['@component' => $string]);
}
}
}
@@ -174,14 +173,14 @@ class ViewsDataHelper {
* decided.
*/
protected static function fetchedFieldSort($a, $b) {
$a_group = Unicode::strtolower($a['group']);
$b_group = Unicode::strtolower($b['group']);
$a_group = mb_strtolower($a['group']);
$b_group = mb_strtolower($b['group']);
if ($a_group != $b_group) {
return $a_group < $b_group ? -1 : 1;
}
$a_title = Unicode::strtolower($a['title']);
$b_title = Unicode::strtolower($b['title']);
$a_title = mb_strtolower($a['title']);
$b_title = mb_strtolower($b['title']);
if ($a_title != $b_title) {
return $a_title < $b_title ? -1 : 1;
}