diff --git a/core/modules/node/config/install/views.view.content.yml b/core/modules/node/config/install/views.view.content.yml index f01eb21c530f734c8731efbd6f00319f69878e6b..3ea06e7b166fcea2c5ee65fbf95be588fa8ac4d1 100644 --- a/core/modules/node/config/install/views.view.content.yml +++ b/core/modules/node/config/install/views.view.content.yml @@ -321,7 +321,6 @@ display: hide_alter_empty: true link_to_node: false comments: false - optional: true plugin_id: history_user_timestamp provider: history filters: @@ -473,7 +472,6 @@ display: identifier: langcode remember_roles: authenticated: authenticated - optional: true plugin_id: language provider: language sorts: { } diff --git a/core/modules/node/config/install/views.view.content_recent.yml b/core/modules/node/config/install/views.view.content_recent.yml index 07afd74e5562e5c0787912693620b9da84e2cb2b..8e231b2ca968926675cc919ca7d7fb917bc3c5be 100644 --- a/core/modules/node/config/install/views.view.content_recent.yml +++ b/core/modules/node/config/install/views.view.content_recent.yml @@ -206,7 +206,6 @@ display: hide_alter_empty: true link_to_node: false comments: false - optional: true plugin_id: history_user_timestamp provider: history name: diff --git a/core/modules/views/config/schema/views.data_types.schema.yml b/core/modules/views/config/schema/views.data_types.schema.yml index a280d7309ff8621d5a3d98e93b364dc93c73d50a..3cef2658a0131cdbe976e331317cf03054ef8251 100644 --- a/core/modules/views/config/schema/views.data_types.schema.yml +++ b/core/modules/views/config/schema/views.data_types.schema.yml @@ -330,9 +330,6 @@ views_handler: provider: type: string label: 'Provider' - optional: - type: boolean - label: 'Optional' views_argument: type: views_handler diff --git a/core/modules/views/src/Entity/View.php b/core/modules/views/src/Entity/View.php index 00098b880ca164ff0abf7bfd95bc9ac31f1d6b76..93c446cc32b15442ea464be16f23c78cde38a590 100644 --- a/core/modules/views/src/Entity/View.php +++ b/core/modules/views/src/Entity/View.php @@ -268,7 +268,7 @@ public function calculateDependencies() { if (!empty($display['display_options'][$handler_type])) { foreach ($display['display_options'][$handler_type] as $handler) { // Add the provider as dependency. - if (isset($handler['provider']) && empty($handler['optional'])) { + if (isset($handler['provider'])) { $this->addDependency('module', $handler['provider']); } // Add the additional dependencies from the handler configuration. diff --git a/core/modules/views/src/Plugin/ViewsHandlerManager.php b/core/modules/views/src/Plugin/ViewsHandlerManager.php index c3651cff6022f991f86799da3d5eeb71ab706f58..7b7b76e5ee4d1e3532ee6df1e18ee3f01e41ed55 100644 --- a/core/modules/views/src/Plugin/ViewsHandlerManager.php +++ b/core/modules/views/src/Plugin/ViewsHandlerManager.php @@ -70,9 +70,6 @@ public function __construct($handler_type, \Traversable $namespaces, ViewsData $ * An associative array representing the handler to be retrieved: * - table: The name of the table containing the handler. * - field: The name of the field the handler represents. - * - optional: (optional) Whether or not this handler is optional. If a - * handler is missing and not optional, a debug message will be displayed. - * Defaults to FALSE. * @param string|null $override * (optional) Override the actual handler object with this plugin ID. Used for * aggregation when the handler is redirected to the aggregation handler. @@ -83,7 +80,6 @@ public function __construct($handler_type, \Traversable $namespaces, ViewsData $ public function getHandler($item, $override = NULL) { $table = $item['table']; $field = $item['field']; - $optional = !empty($item['optional']); // Get the plugin manager for this type. $data = $this->viewsData->get($table); @@ -119,12 +115,8 @@ public function getHandler($item, $override = NULL) { } } - if (!$optional) { - // debug(t("Missing handler: @table @field @type", array('@table' => $table, '@field' => $field, '@type' => $this->handlerType))); - } - // Finally, use the 'broken' handler. - return $this->createInstance('broken', array('optional' => $optional, 'original_configuration' => $item)); + return $this->createInstance('broken', array('original_configuration' => $item)); } /** diff --git a/core/modules/views/src/Plugin/views/BrokenHandlerTrait.php b/core/modules/views/src/Plugin/views/BrokenHandlerTrait.php index e1623f750f03f40479abe499bfe9dcb56723a3c8..2135813bbe49bf81c0d99630c63740ea9edf07b4 100644 --- a/core/modules/views/src/Plugin/views/BrokenHandlerTrait.php +++ b/core/modules/views/src/Plugin/views/BrokenHandlerTrait.php @@ -21,7 +21,7 @@ public function adminLabel($short = FALSE) { $args = array( '@module' => $this->definition['original_configuration']['provider'], ); - return $this->isOptional() ? t('Optional handler is missing (Module: @module) …', $args) : t('Broken/missing handler (Module: @module) …', $args); + return t('Broken/missing handler (Module: @module) …', $args); } /** @@ -56,12 +56,7 @@ public function query($group_by = FALSE) { * @see \Drupal\views\Plugin\views\PluginBase::defineOptions(). */ public function buildOptionsForm(&$form, &$form_state) { - if ($this->isOptional()) { - $description_top = t('The handler for this item is optional. The following details are available:'); - } - else { - $description_top = t('The handler for this item is broken or missing. The following details are available:'); - } + $description_top = t('The handler for this item is broken or missing. The following details are available:'); $items = array( t('Module: @module', array('@module' => $this->definition['original_configuration']['provider'])), diff --git a/core/modules/views/src/Plugin/views/HandlerBase.php b/core/modules/views/src/Plugin/views/HandlerBase.php index 979fa4b8126cced4f3dffc338de66abc01d47fec..e53cf7541968b37a256bbbc9c14773d5f861fba1 100644 --- a/core/modules/views/src/Plugin/views/HandlerBase.php +++ b/core/modules/views/src/Plugin/views/HandlerBase.php @@ -85,13 +85,6 @@ abstract class HandlerBase extends PluginBase { */ public $relationship = NULL; - /** - * Whether or not this handler is optional. - * - * @var bool - */ - protected $optional = FALSE; - /** * The module handler. * @@ -112,7 +105,6 @@ abstract class HandlerBase extends PluginBase { public function __construct(array $configuration, $plugin_id, $plugin_definition) { parent::__construct($configuration, $plugin_id, $plugin_definition); $this->is_handler = TRUE; - $this->optional = !empty($configuration['optional']); } /** @@ -178,15 +170,6 @@ protected function defineOptions() { return $options; } - /** - * Returns whether this handler is optional. - * - * @return bool - */ - public function isOptional() { - return $this->optional; - } - /** * Return a string representing this handler's name in the UI. */ diff --git a/core/modules/views/src/Tests/ModuleTest.php b/core/modules/views/src/Tests/ModuleTest.php index dd976e7b66b70ad4ac66978020b0fdfb1c8e4bd9..e719a9cd5ec3362b8d8e8673881e7e9ce2960c35 100644 --- a/core/modules/views/src/Tests/ModuleTest.php +++ b/core/modules/views/src/Tests/ModuleTest.php @@ -108,21 +108,11 @@ public function testViewsGetHandler() { $item = array( 'table' => 'table_invalid', 'field' => 'id', - 'optional' => FALSE, ); $this->container->get('plugin.manager.views.filter')->getHandler($item); $this->assertEqual(strpos($this->lastErrorMessage, format_string("Missing handler: @table @field @type", array('@table' => 'table_invalid', '@field' => 'id', '@type' => 'filter'))) !== FALSE, 'An invalid table name throws a debug message.'); unset($this->lastErrorMessage); - $item = array( - 'table' => 'table_invalid', - 'field' => 'id', - 'optional' => TRUE, - ); - $this->container->get('plugin.manager.views.filter')->getHandler($item); - $this->assertFalse($this->lastErrorMessage, "An optional handler does not throw a debug message."); - unset($this->lastErrorMessage); - restore_error_handler(); } diff --git a/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_view_optional.yml b/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_view_optional.yml deleted file mode 100644 index de319fe7d4fca09416a3af3a7527f20dcac802f6..0000000000000000000000000000000000000000 --- a/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_view_optional.yml +++ /dev/null @@ -1,97 +0,0 @@ -base_table: views_test_data -core: '8' -description: '' -status: '1' -display: - default: - display_options: - defaults: - fields: '0' - pager: '0' - pager_options: '0' - sorts: '0' - fields: - id_optional: - field: id_optional - id: id_optional - relationship: none - table: views_test_data - plugin_id: numeric - optional: 1 - provider: views - filters: - id_optional: - field: id_optional - id: id_optional - relationship: none - table: views_test_data - plugin_id: numeric - optional: 1 - provider: views - arguments: - id_optional: - field: id_optional - id: id_optional - relationship: none - table: views_test_data - plugin_id: numeric - optional: 1 - provider: views - sorts: - id_optional: - field: id_optional - id: id_optional - relationship: none - table: views_test_data - plugin_id: numeric - order: ASC - optional: 1 - provider: views - relationships: - id_optional: - field: id_optional - id: id_optional - relationship: none - table: views_test_data - plugin_id: numeric - optional: 1 - provider: views - header: - id_optional: - field: id_optional - id: id_optional - relationship: none - table: views_test_data - plugin_id: numeric - optional: 1 - provider: views - footer: - id_optional: - field: id_optional - id: id_optional - relationship: none - table: views_test_data - plugin_id: numeric - optional: 1 - provider: views - empty: - id_optional: - field: id_optional - id: id_optional - relationship: none - table: views_test_data - plugin_id: numeric - optional: 1 - provider: views - pager: - options: - offset: '0' - type: none - pager_options: { } - display_plugin: default - display_title: Master - id: default - position: 0 -label: 'Test view' -id: test_view_optional -tag: '' diff --git a/core/modules/views_ui/src/Tests/HandlerTest.php b/core/modules/views_ui/src/Tests/HandlerTest.php index 4eaac1e90e1d04e419341030ad4b850505dfdda4..d4a745899a47dc8fd48ce943a9e16ba4f35907af 100644 --- a/core/modules/views_ui/src/Tests/HandlerTest.php +++ b/core/modules/views_ui/src/Tests/HandlerTest.php @@ -23,7 +23,7 @@ class HandlerTest extends UITestBase { * * @var array */ - public static $testViews = array('test_view_empty', 'test_view_broken', 'test_view_optional'); + public static $testViews = array('test_view_empty', 'test_view_broken'); /** * Overrides \Drupal\views\Tests\ViewTestBase::schemaDefinition(). @@ -171,38 +171,4 @@ public function testBrokenHandlers() { } } - /** - * Tests optional handlers. - */ - public function testOptionalHandlers() { - $handler_types = ViewExecutable::getHandlerTypes(); - foreach ($handler_types as $type => $type_info) { - $this->drupalGet('admin/structure/views/view/test_view_optional/edit'); - - $href = "admin/structure/views/nojs/handler/test_view_optional/default/$type/id_optional"; - - $result = $this->xpath('//a[contains(@href, :href)]', array(':href' => $href)); - $this->assertEqual(count($result), 1, String::format('Handler (%type) edit link found.', array('%type' => $type))); - - $text = t('Optional handler is missing (Module: @module) …', array('@module' => 'views')); - - $this->assertIdentical((string) $result[0], $text, 'Ensure the optional handler link text was found.'); - - $this->drupalGet($href); - $result = $this->xpath('//h1'); - $this->assertTrue(strpos((string) $result[0], $text) !== FALSE, 'Ensure the optional handler title was found.'); - - $description_args = array( - '@module' => 'views', - '@table' => 'views_test_data', - '@field' => 'id_optional', - ); - - foreach ($description_args as $token => $value) { - $this->assertNoText($token, String::format('Raw @token token placeholder not found.', array('@token' => $token))); - $this->assertText($value, String::format('Replaced @token value found.', array('@token' => $token))); - } - } - } - }