summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Pott2015-07-28 01:11:48 (GMT)
committerAlex Pott2015-07-28 01:11:48 (GMT)
commit0613685619c4f3c747e84055340d5290dd49d34a (patch)
tree6d7579ef2521a473d962915c854a77f6bb975db6
parent0fc922d9e7754049c44a37066f7a6604039201fc (diff)
Issue #2529514 by dawehner, Fabianx, Wim Leers: Replace system.filter::protocols with container parameters
-rw-r--r--core/core.services.yml18
-rw-r--r--core/lib/Drupal/Core/DrupalKernel.php4
-rw-r--r--core/lib/Drupal/Core/Routing/UrlGenerator.php9
-rw-r--r--core/lib/Drupal/Core/Utility/UnroutedUrlAssembler.php9
-rw-r--r--core/modules/filter/filter.module2
-rw-r--r--core/modules/filter/src/Tests/FilterUnitTest.php2
-rw-r--r--core/modules/migrate_drupal/migration_templates/d6_system_filter.yml13
-rw-r--r--core/modules/migrate_drupal/src/Tests/d6/MigrateDrupal6Test.php1
-rw-r--r--core/modules/migrate_drupal/src/Tests/d6/MigrateSystemFilterTest.php34
-rw-r--r--core/modules/system/config/install/system.filter.yml14
-rw-r--r--core/modules/system/config/schema/system.schema.yml11
-rw-r--r--core/modules/views/tests/src/Unit/Plugin/field/FieldPluginBaseTest.php10
-rw-r--r--core/tests/Drupal/Tests/Core/Routing/UrlGeneratorTest.php4
-rw-r--r--core/tests/Drupal/Tests/Core/Utility/UnroutedUrlAssemblerTest.php3
-rw-r--r--sites/default/default.services.yml15
15 files changed, 46 insertions, 103 deletions
diff --git a/core/core.services.yml b/core/core.services.yml
index 470db00..47ee363 100644
--- a/core/core.services.yml
+++ b/core/core.services.yml
@@ -7,6 +7,20 @@ parameters:
default: keyvalue.database
factory.keyvalue.expirable:
default: keyvalue.expirable.database
+ filter_protocols:
+ - http
+ - https
+ - ftp
+ - news
+ - nntp
+ - tel
+ - telnet
+ - mailto
+ - irc
+ - ssh
+ - sftp
+ - webcal
+ - rtsp
services:
# Simple cache contexts, directly derived from the request context.
cache_context.ip:
@@ -712,7 +726,7 @@ services:
- { name: event_subscriber }
url_generator.non_bubbling:
class: Drupal\Core\Routing\UrlGenerator
- arguments: ['@router.route_provider', '@path_processor_manager', '@route_processor_manager', '@config.factory', '@request_stack']
+ arguments: ['@router.route_provider', '@path_processor_manager', '@route_processor_manager', '@request_stack', '%filter_protocols%']
public: false
calls:
- [setContext, ['@?router.request_context']]
@@ -726,7 +740,7 @@ services:
arguments: ['@request_stack', '@url_generator']
unrouted_url_assembler:
class: Drupal\Core\Utility\UnroutedUrlAssembler
- arguments: ['@request_stack', '@config.factory', '@path_processor_manager']
+ arguments: ['@request_stack', '@path_processor_manager', '%filter_protocols%']
link_generator:
class: Drupal\Core\Utility\LinkGenerator
arguments: ['@url_generator', '@module_handler', '@renderer']
diff --git a/core/lib/Drupal/Core/DrupalKernel.php b/core/lib/Drupal/Core/DrupalKernel.php
index fd27416..61c5863 100644
--- a/core/lib/Drupal/Core/DrupalKernel.php
+++ b/core/lib/Drupal/Core/DrupalKernel.php
@@ -466,8 +466,8 @@ class DrupalKernel implements DrupalKernelInterface, TerminableInterface {
$this->container->get('request_stack')->push($request);
// Set the allowed protocols once we have the config available.
- $allowed_protocols = $this->container->get('config.factory')->get('system.filter')->get('protocols');
- if (!isset($allowed_protocols)) {
+ $allowed_protocols = $this->container->getParameter('filter_protocols');
+ if (!$allowed_protocols) {
// \Drupal\Component\Utility\UrlHelper::filterBadProtocol() is called by
// the installer and update.php, in which case the configuration may not
// exist (yet). Provide a minimal default set of allowed protocols for
diff --git a/core/lib/Drupal/Core/Routing/UrlGenerator.php b/core/lib/Drupal/Core/Routing/UrlGenerator.php
index 5103bf2..6bc12b0 100644
--- a/core/lib/Drupal/Core/Routing/UrlGenerator.php
+++ b/core/lib/Drupal/Core/Routing/UrlGenerator.php
@@ -72,19 +72,18 @@ class UrlGenerator implements UrlGeneratorInterface {
* The path processor to convert the system path to one suitable for urls.
* @param \Drupal\Core\RouteProcessor\OutboundRouteProcessorInterface $route_processor
* The route processor.
- * @param \Drupal\Core\Config\ConfigFactoryInterface $config
- * The config factory.
* @param \Symfony\Component\HttpFoundation\RequestStack $request_stack
* A request stack object.
+ * @param string[] $filter_protocols
+ * (optional) An array of protocols allowed for URL generation.
*/
- public function __construct(RouteProviderInterface $provider, OutboundPathProcessorInterface $path_processor, OutboundRouteProcessorInterface $route_processor, ConfigFactoryInterface $config, RequestStack $request_stack) {
+ public function __construct(RouteProviderInterface $provider, OutboundPathProcessorInterface $path_processor, OutboundRouteProcessorInterface $route_processor, RequestStack $request_stack, array $filter_protocols = ['http', 'https']) {
$this->provider = $provider;
$this->context = new RequestContext();
$this->pathProcessor = $path_processor;
$this->routeProcessor = $route_processor;
- $allowed_protocols = $config->get('system.filter')->get('protocols') ?: array('http', 'https');
- UrlHelper::setAllowedProtocols($allowed_protocols);
+ UrlHelper::setAllowedProtocols($filter_protocols);
$this->requestStack = $request_stack;
}
diff --git a/core/lib/Drupal/Core/Utility/UnroutedUrlAssembler.php b/core/lib/Drupal/Core/Utility/UnroutedUrlAssembler.php
index e03d4c4..1e807b3 100644
--- a/core/lib/Drupal/Core/Utility/UnroutedUrlAssembler.php
+++ b/core/lib/Drupal/Core/Utility/UnroutedUrlAssembler.php
@@ -40,14 +40,13 @@ class UnroutedUrlAssembler implements UnroutedUrlAssemblerInterface {
*
* @param \Symfony\Component\HttpFoundation\RequestStack $request_stack
* A request stack object.
- * @param \Drupal\Core\Config\ConfigFactoryInterface $config
- * The config factory.
* @param \Drupal\Core\PathProcessor\OutboundPathProcessorInterface $path_processor
* The output path processor.
+ * @param string[] $filter_protocols
+ * (optional) An array of protocols allowed for URL generation.
*/
- public function __construct(RequestStack $request_stack, ConfigFactoryInterface $config, OutboundPathProcessorInterface $path_processor) {
- $allowed_protocols = $config->get('system.filter')->get('protocols') ?: ['http', 'https'];
- UrlHelper::setAllowedProtocols($allowed_protocols);
+ public function __construct(RequestStack $request_stack, OutboundPathProcessorInterface $path_processor, array $filter_protocols = ['http', 'https']) {
+ UrlHelper::setAllowedProtocols($filter_protocols);
$this->requestStack = $request_stack;
$this->pathProcessor = $path_processor;
}
diff --git a/core/modules/filter/filter.module b/core/modules/filter/filter.module
index 67dbd6c..2287d7a 100644
--- a/core/modules/filter/filter.module
+++ b/core/modules/filter/filter.module
@@ -501,7 +501,7 @@ function _filter_url($text, $filter) {
// we cannot cleanly differ between protocols here without hard-coding MAILTO,
// so '//' is optional for all protocols.
// @see \Drupal\Component\Utility\UrlHelper::filterBadProtocol()
- $protocols = \Drupal::config('system.filter')->get('protocols');
+ $protocols = \Drupal::getContainer()->getParameter('filter_protocols') ?: ['http', 'https'];
$protocols = implode(':(?://)?|', $protocols) . ':(?://)?';
$valid_url_path_characters = "[\p{L}\p{M}\p{N}!\*\';:=\+,\.\$\/%#\[\]\-_~@&]";
diff --git a/core/modules/filter/src/Tests/FilterUnitTest.php b/core/modules/filter/src/Tests/FilterUnitTest.php
index b606a4b..fe7664c 100644
--- a/core/modules/filter/src/Tests/FilterUnitTest.php
+++ b/core/modules/filter/src/Tests/FilterUnitTest.php
@@ -594,7 +594,7 @@ me@me.tv
),
// Absolute URL protocols.
// The list to test is found in the beginning of _filter_url() at
- // $protocols = $this->config('system.filter')->get('protocols').
+ // $protocols = \Drupal::getContainer()->getParameter('filter_protocols').
'
https://example.com,
ftp://ftp.example.com,
diff --git a/core/modules/migrate_drupal/migration_templates/d6_system_filter.yml b/core/modules/migrate_drupal/migration_templates/d6_system_filter.yml
deleted file mode 100644
index 739268d..0000000
--- a/core/modules/migrate_drupal/migration_templates/d6_system_filter.yml
+++ /dev/null
@@ -1,13 +0,0 @@
-id: d6_system_filter
-label: Drupal 6 filter configuration
-migration_tags:
- - Drupal 6
-source:
- plugin: variable
- variables:
- - filter_allowed_protocols
-process:
- protocols: filter_allowed_protocols
-destination:
- plugin: config
- config_name: system.filter
diff --git a/core/modules/migrate_drupal/src/Tests/d6/MigrateDrupal6Test.php b/core/modules/migrate_drupal/src/Tests/d6/MigrateDrupal6Test.php
index bf4435f..ac5a836 100644
--- a/core/modules/migrate_drupal/src/Tests/d6/MigrateDrupal6Test.php
+++ b/core/modules/migrate_drupal/src/Tests/d6/MigrateDrupal6Test.php
@@ -121,7 +121,6 @@ class MigrateDrupal6Test extends MigrateFullDrupalTestBase {
'd6_syslog_settings',
'd6_system_cron',
'd6_system_file',
- 'd6_system_filter',
'd6_system_image',
'd6_system_image_gd',
'd6_system_logging',
diff --git a/core/modules/migrate_drupal/src/Tests/d6/MigrateSystemFilterTest.php b/core/modules/migrate_drupal/src/Tests/d6/MigrateSystemFilterTest.php
deleted file mode 100644
index 251b41b..0000000
--- a/core/modules/migrate_drupal/src/Tests/d6/MigrateSystemFilterTest.php
+++ /dev/null
@@ -1,34 +0,0 @@
-<?php
-
-/**
- * @file
- * Contains \Drupal\migrate_drupal\Tests\d6\MigrateSystemFilterTest.
- */
-
-namespace Drupal\migrate_drupal\Tests\d6;
-
-/**
- * Upgrade filter variables to system.*.yml.
- *
- * @group migrate_drupal
- */
-class MigrateSystemFilterTest extends MigrateDrupal6TestBase {
-
- /**
- * {@inheritdoc}
- */
- protected function setUp() {
- parent::setUp();
- $this->loadDumps(['Variable.php']);
- $this->executeMigration('d6_system_filter');
- }
-
- /**
- * Tests migration of system (filter) variables to system.filter.yml.
- */
- public function testSystemFilter() {
- $config = $this->config('system.filter');
- $this->assertIdentical(array('http', 'https', 'ftp', 'news', 'nntp', 'tel', 'telnet', 'mailto', 'irc', 'ssh', 'sftp', 'webcal', 'rtsp'), $config->get('protocols'));
- }
-
-}
diff --git a/core/modules/system/config/install/system.filter.yml b/core/modules/system/config/install/system.filter.yml
deleted file mode 100644
index 12ce55a..0000000
--- a/core/modules/system/config/install/system.filter.yml
+++ /dev/null
@@ -1,14 +0,0 @@
-protocols:
- - http
- - https
- - ftp
- - news
- - nntp
- - tel
- - telnet
- - mailto
- - irc
- - ssh
- - sftp
- - webcal
- - rtsp
diff --git a/core/modules/system/config/schema/system.schema.yml b/core/modules/system/config/schema/system.schema.yml
index 7cde50d..12b0e6c 100644
--- a/core/modules/system/config/schema/system.schema.yml
+++ b/core/modules/system/config/schema/system.schema.yml
@@ -126,17 +126,6 @@ system.diff:
type: integer
label: 'Number of trailing lines in a diff'
-system.filter:
- type: config_object
- label: 'Filter settings'
- mapping:
- protocols:
- type: sequence
- label: 'Allowed protocols'
- sequence:
- type: string
- label: 'Protocol'
-
system.logging:
type: config_object
label: 'Logging settings'
diff --git a/core/modules/views/tests/src/Unit/Plugin/field/FieldPluginBaseTest.php b/core/modules/views/tests/src/Unit/Plugin/field/FieldPluginBaseTest.php
index ec3b0d0..7b87f22 100644
--- a/core/modules/views/tests/src/Unit/Plugin/field/FieldPluginBaseTest.php
+++ b/core/modules/views/tests/src/Unit/Plugin/field/FieldPluginBaseTest.php
@@ -168,16 +168,8 @@ class FieldPluginBaseTest extends UnitTestCase {
* Sets up the unrouted url assembler and the link generator.
*/
protected function setUpUrlIntegrationServices() {
- $config = $this->getMockBuilder('Drupal\Core\Config\ImmutableConfig')
- ->disableOriginalConstructor()
- ->getMock();
- $config_factory = $this->getMock('\Drupal\Core\Config\ConfigFactoryInterface');
- $config_factory->expects($this->any())
- ->method('get')
- ->willReturn($config);
-
$this->pathProcessor = $this->getMock('Drupal\Core\PathProcessor\OutboundPathProcessorInterface');
- $this->unroutedUrlAssembler = new UnroutedUrlAssembler($this->requestStack, $config_factory, $this->pathProcessor);
+ $this->unroutedUrlAssembler = new UnroutedUrlAssembler($this->requestStack, $this->pathProcessor);
\Drupal::getContainer()->set('unrouted_url_assembler', $this->unroutedUrlAssembler);
diff --git a/core/tests/Drupal/Tests/Core/Routing/UrlGeneratorTest.php b/core/tests/Drupal/Tests/Core/Routing/UrlGeneratorTest.php
index a0f6213..2e04b87 100644
--- a/core/tests/Drupal/Tests/Core/Routing/UrlGeneratorTest.php
+++ b/core/tests/Drupal/Tests/Core/Routing/UrlGeneratorTest.php
@@ -147,9 +147,7 @@ class UrlGeneratorTest extends UnitTestCase {
->disableOriginalConstructor()
->getMock();
- $config_factory_stub = $this->getConfigFactoryStub(array('system.filter' => array('protocols' => array('http', 'https'))));
-
- $generator = new UrlGenerator($provider, $processor_manager, $this->routeProcessorManager, $config_factory_stub, $this->requestStack);
+ $generator = new UrlGenerator($provider, $processor_manager, $this->routeProcessorManager, $this->requestStack, ['http', 'https']);
$generator->setContext($context);
$this->generator = $generator;
}
diff --git a/core/tests/Drupal/Tests/Core/Utility/UnroutedUrlAssemblerTest.php b/core/tests/Drupal/Tests/Core/Utility/UnroutedUrlAssemblerTest.php
index 98abf48..e13b85b 100644
--- a/core/tests/Drupal/Tests/Core/Utility/UnroutedUrlAssemblerTest.php
+++ b/core/tests/Drupal/Tests/Core/Utility/UnroutedUrlAssemblerTest.php
@@ -55,9 +55,8 @@ class UnroutedUrlAssemblerTest extends UnitTestCase {
parent::setUp();
$this->requestStack = new RequestStack();
- $this->configFactory = $this->getConfigFactoryStub(['system.filter' => []]);
$this->pathProcessor = $this->getMock('Drupal\Core\PathProcessor\OutboundPathProcessorInterface');
- $this->unroutedUrlAssembler = new UnroutedUrlAssembler($this->requestStack, $this->configFactory, $this->pathProcessor);
+ $this->unroutedUrlAssembler = new UnroutedUrlAssembler($this->requestStack, $this->pathProcessor);
}
/**
diff --git a/sites/default/default.services.yml b/sites/default/default.services.yml
index e20002d..ecaa7b2 100644
--- a/sites/default/default.services.yml
+++ b/sites/default/default.services.yml
@@ -96,3 +96,18 @@ parameters:
# Default key/value expirable storage service to use.
# @default keyvalue.database.expirable
# default: keyvalue.database.expirable
+ # Allowed protocols for URL generation.
+ filter_protocols:
+ - http
+ - https
+ - ftp
+ - news
+ - nntp
+ - tel
+ - telnet
+ - mailto
+ - irc
+ - ssh
+ - sftp
+ - webcal
+ - rtsp