Unverified Commit 47c2dda6 authored by larowlan's avatar larowlan

Issue #2927746 by alexpott, catch, slasher13, mpdonadio, martin107, RoSk0,...

Issue #2927746 by alexpott, catch, slasher13, mpdonadio, martin107, RoSk0, jibran, larowlan, pounard, Mile23, Jo Fitzgerald, deviantintegral, pritish.kumar: Update Symfony components to 3.4.*
parent 6a3ba025
This diff is collapsed.
...@@ -4,20 +4,20 @@ ...@@ -4,20 +4,20 @@
"type": "drupal-core", "type": "drupal-core",
"license": "GPL-2.0+", "license": "GPL-2.0+",
"require": { "require": {
"php": ">=5.5.9", "php": "^5.5.9|>=7.0.8",
"symfony/class-loader": "~3.2.8", "symfony/class-loader": "~3.4.0",
"symfony/console": "~3.2.8", "symfony/console": "~3.4.0",
"symfony/dependency-injection": "~3.2.8", "symfony/dependency-injection": "~3.4.0",
"symfony/event-dispatcher": "~3.2.8", "symfony/event-dispatcher": "~3.4.0",
"symfony/http-foundation": "~3.2.8", "symfony/http-foundation": "~3.4.0",
"symfony/http-kernel": "~3.2.8", "symfony/http-kernel": "~3.4.0",
"symfony/routing": "~3.2.8", "symfony/routing": "~3.4.0",
"symfony/serializer": "~3.2.8", "symfony/serializer": "~3.4.0",
"symfony/translation": "~3.2.8", "symfony/translation": "~3.4.0",
"symfony/validator": "~3.2.8", "symfony/validator": "~3.4.0",
"symfony/process": "~3.2.8", "symfony/process": "~3.4.0",
"symfony/polyfill-iconv": "^1.0", "symfony/polyfill-iconv": "^1.0",
"symfony/yaml": "~3.2.8", "symfony/yaml": "~3.4.0",
"twig/twig": "^1.35.0", "twig/twig": "^1.35.0",
"doctrine/common": "^2.5", "doctrine/common": "^2.5",
"doctrine/annotations": "^1.2", "doctrine/annotations": "^1.2",
...@@ -46,8 +46,9 @@ ...@@ -46,8 +46,9 @@
"mikey179/vfsStream": "^1.2", "mikey179/vfsStream": "^1.2",
"phpunit/phpunit": "^4.8.35 || ^6.1", "phpunit/phpunit": "^4.8.35 || ^6.1",
"phpspec/prophecy": "^1.4", "phpspec/prophecy": "^1.4",
"symfony/css-selector": "~3.2.8", "symfony/css-selector": "^3.4.0",
"symfony/phpunit-bridge": "^3.4.3" "symfony/phpunit-bridge": "^3.4.3",
"symfony/debug": "^3.4.0"
}, },
"replace": { "replace": {
"drupal/action": "self.version", "drupal/action": "self.version",
......
...@@ -65,7 +65,7 @@ public function getArray() { ...@@ -65,7 +65,7 @@ public function getArray() {
$definition['aliases'] = $this->getAliases(); $definition['aliases'] = $this->getAliases();
$definition['parameters'] = $this->getParameters(); $definition['parameters'] = $this->getParameters();
$definition['services'] = $this->getServiceDefinitions(); $definition['services'] = $this->getServiceDefinitions();
$definition['frozen'] = $this->container->isFrozen(); $definition['frozen'] = $this->container->isCompiled();
$definition['machine_format'] = $this->supportsMachineFormat(); $definition['machine_format'] = $this->supportsMachineFormat();
return $definition; return $definition;
} }
...@@ -103,8 +103,8 @@ protected function getParameters() { ...@@ -103,8 +103,8 @@ protected function getParameters() {
} }
$parameters = $this->container->getParameterBag()->all(); $parameters = $this->container->getParameterBag()->all();
$is_frozen = $this->container->isFrozen(); $is_compiled = $this->container->isCompiled();
return $this->prepareParameters($parameters, $is_frozen); return $this->prepareParameters($parameters, $is_compiled);
} }
/** /**
...@@ -309,10 +309,10 @@ protected function dumpCollection($collection, &$resolve = FALSE) { ...@@ -309,10 +309,10 @@ protected function dumpCollection($collection, &$resolve = FALSE) {
} }
} }
else { else {
if (is_object($value)) { $code[$key] = $this->dumpValue($value);
if (is_object($code[$key])) {
$resolve = TRUE; $resolve = TRUE;
} }
$code[$key] = $this->dumpValue($value);
} }
} }
...@@ -403,6 +403,9 @@ protected function dumpValue($value) { ...@@ -403,6 +403,9 @@ protected function dumpValue($value) {
elseif ($value instanceof Parameter) { elseif ($value instanceof Parameter) {
return $this->getParameterCall((string) $value); return $this->getParameterCall((string) $value);
} }
elseif (is_string($value) && preg_match('/^\%(.*)\%$/', $value, $matches)) {
return $this->getParameterCall($matches[1]);
}
elseif ($value instanceof Expression) { elseif ($value instanceof Expression) {
throw new RuntimeException('Unable to use expressions as the Symfony ExpressionLanguage component is not installed.'); throw new RuntimeException('Unable to use expressions as the Symfony ExpressionLanguage component is not installed.');
} }
......
...@@ -104,8 +104,11 @@ public function dispatch($event_name, Event $event = NULL) { ...@@ -104,8 +104,11 @@ public function dispatch($event_name, Event $event = NULL) {
if (!isset($definition['callable'])) { if (!isset($definition['callable'])) {
$definition['callable'] = [$this->container->get($definition['service'][0]), $definition['service'][1]]; $definition['callable'] = [$this->container->get($definition['service'][0]), $definition['service'][1]];
} }
if (is_array($definition['callable']) && isset($definition['callable'][0]) && $definition['callable'][0] instanceof \Closure) {
$definition['callable'][0] = $definition['callable'][0]();
}
$definition['callable']($event, $event_name, $this); call_user_func($definition['callable'], $event, $event_name, $this);
if ($event->isPropagationStopped()) { if ($event->isPropagationStopped()) {
return $event; return $event;
} }
...@@ -144,6 +147,9 @@ public function getListeners($event_name = NULL) { ...@@ -144,6 +147,9 @@ public function getListeners($event_name = NULL) {
if (!isset($definition['callable'])) { if (!isset($definition['callable'])) {
$definition['callable'] = [$this->container->get($definition['service'][0]), $definition['service'][1]]; $definition['callable'] = [$this->container->get($definition['service'][0]), $definition['service'][1]];
} }
if (is_array($definition['callable']) && isset($definition['callable'][0]) && $definition['callable'][0] instanceof \Closure) {
$definition['callable'][0] = $definition['callable'][0]();
}
$result[] = $definition['callable']; $result[] = $definition['callable'];
} }
...@@ -156,27 +162,29 @@ public function getListeners($event_name = NULL) { ...@@ -156,27 +162,29 @@ public function getListeners($event_name = NULL) {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function getListenerPriority($eventName, $listener) { public function getListenerPriority($event_name, $listener) {
// Parts copied from \Symfony\Component\EventDispatcher, that's why you see if (!isset($this->listeners[$event_name])) {
// a yoda condition here.
if (!isset($this->listeners[$eventName])) {
return; return;
} }
foreach ($this->listeners[$eventName] as $priority => $listeners) { if (is_array($listener) && isset($listener[0]) && $listener[0] instanceof \Closure) {
if (FALSE !== ($key = array_search(['callable' => $listener], $listeners, TRUE))) { $listener[0] = $listener[0]();
return $priority;
}
} }
// Resolve service definitions if the listener has not been found so far. // Resolve service definitions if the listener has not been found so far.
foreach ($this->listeners[$eventName] as $priority => &$definitions) { foreach ($this->listeners[$event_name] as $priority => &$definitions) {
foreach ($definitions as $key => &$definition) { foreach ($definitions as $key => &$definition) {
if (!isset($definition['callable'])) { if (!isset($definition['callable'])) {
// Once the callable is retrieved we keep it for subsequent method // Once the callable is retrieved we keep it for subsequent method
// invocations on this class. // invocations on this class.
$definition['callable'] = [$this->container->get($definition['service'][0]), $definition['service'][1]]; $definition['callable'] = [
if ($definition['callable'] === $listener) { $this->container->get($definition['service'][0]),
return $priority; $definition['service'][1],
} ];
}
if (is_array($definition['callable']) && isset($definition['callable'][0]) && $definition['callable'][0] instanceof \Closure) {
$definition['callable'][0] = $definition['callable'][0]();
}
if ($definition['callable'] === $listener) {
return $priority;
} }
} }
} }
...@@ -186,7 +194,17 @@ public function getListenerPriority($eventName, $listener) { ...@@ -186,7 +194,17 @@ public function getListenerPriority($eventName, $listener) {
* {@inheritdoc} * {@inheritdoc}
*/ */
public function hasListeners($event_name = NULL) { public function hasListeners($event_name = NULL) {
return (bool) count($this->getListeners($event_name)); if ($event_name !== NULL) {
return !empty($this->listeners[$event_name]);
}
foreach ($this->listeners as $event_listeners) {
if ($event_listeners) {
return TRUE;
}
}
return FALSE;
} }
/** /**
...@@ -214,10 +232,23 @@ public function removeListener($event_name, $listener) { ...@@ -214,10 +232,23 @@ public function removeListener($event_name, $listener) {
$definition['callable'] = [$this->container->get($definition['service'][0]), $definition['service'][1]]; $definition['callable'] = [$this->container->get($definition['service'][0]), $definition['service'][1]];
} }
if (is_array($definition['callable']) && isset($definition['callable'][0]) && $definition['callable'][0] instanceof \Closure && !$listener instanceof \Closure) {
$definition['callable'][0] = $definition['callable'][0]();
}
if (is_array($definition['callable']) && isset($definition['callable'][0]) && !$definition['callable'][0] instanceof \Closure && is_array($listener) && isset($listener[0]) && $listener[0] instanceof \Closure) {
$listener[0] = $listener[0]();
}
if ($definition['callable'] === $listener) { if ($definition['callable'] === $listener) {
unset($this->listeners[$event_name][$priority][$key]); unset($definitions[$key]);
} }
} }
if ($definitions) {
$this->listeners[$event_name][$priority] = $definitions;
}
else {
unset($this->listeners[$event_name][$priority]);
}
} }
} }
......
...@@ -34,7 +34,7 @@ public static function decode($raw) { ...@@ -34,7 +34,7 @@ public static function decode($raw) {
$yaml = new Parser(); $yaml = new Parser();
// Make sure we have a single trailing newline. A very simple config like // Make sure we have a single trailing newline. A very simple config like
// 'foo: bar' with no newline will fail to parse otherwise. // 'foo: bar' with no newline will fail to parse otherwise.
return $yaml->parse($raw, SymfonyYaml::PARSE_EXCEPTION_ON_INVALID_TYPE); return $yaml->parse($raw, SymfonyYaml::PARSE_EXCEPTION_ON_INVALID_TYPE | SymfonyYaml::PARSE_KEYS_AS_STRINGS);
} }
catch (\Exception $e) { catch (\Exception $e) {
throw new InvalidDataTypeException($e->getMessage(), $e->getCode(), $e); throw new InvalidDataTypeException($e->getMessage(), $e->getCode(), $e);
......
...@@ -46,9 +46,12 @@ private function getProxyInstantiator() ...@@ -46,9 +46,12 @@ private function getProxyInstantiator()
} }
/** /**
* {@inheritdoc} * A 1to1 copy of parent::shareService.
*
* @todo https://www.drupal.org/project/drupal/issues/2937010 Since Symfony
* 3.4 this is not a 1to1 copy.
*/ */
protected function shareService(Definition $definition, $service, $id) protected function shareService(Definition $definition, $service, $id, array &$inlineServices)
{ {
if ($definition->isShared()) { if ($definition->isShared()) {
$this->services[$lowerId = strtolower($id)] = $service; $this->services[$lowerId = strtolower($id)] = $service;
...@@ -85,7 +88,20 @@ public function register($id, $class = null) { ...@@ -85,7 +88,20 @@ public function register($id, $class = null) {
if (strtolower($id) !== $id) { if (strtolower($id) !== $id) {
throw new \InvalidArgumentException("Service ID names must be lowercase: $id"); throw new \InvalidArgumentException("Service ID names must be lowercase: $id");
} }
return parent::register($id, $class); $definition = parent::register($id, $class);
// As of Symfony 3.4 all services are private by default.
$definition->setPublic(TRUE);
return $definition;
}
/**
* {@inheritdoc}
*/
public function setAlias($alias, $id) {
$alias = parent::setAlias($alias, $id);
// As of Symfony 3.4 all aliases are private by default.
$alias->setPublic(TRUE);
return $alias;
} }
/** /**
...@@ -100,8 +116,11 @@ public function setParameter($name, $value) { ...@@ -100,8 +116,11 @@ public function setParameter($name, $value) {
/** /**
* A 1to1 copy of parent::callMethod. * A 1to1 copy of parent::callMethod.
*
* @todo https://www.drupal.org/project/drupal/issues/2937010 Since Symfony
* 3.4 this is not a 1to1 copy.
*/ */
protected function callMethod($service, $call) { protected function callMethod($service, $call, array &$inlineServices = array()) {
$services = self::getServiceConditionals($call[1]); $services = self::getServiceConditionals($call[1]);
foreach ($services as $s) { foreach ($services as $s) {
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
use Symfony\Component\DependencyInjection\Alias; use Symfony\Component\DependencyInjection\Alias;
use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\DefinitionDecorator; use Symfony\Component\DependencyInjection\ChildDefinition;
use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException; use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
...@@ -155,9 +155,11 @@ private function parseDefinition($id, $service, $file) ...@@ -155,9 +155,11 @@ private function parseDefinition($id, $service, $file)
} }
if (isset($service['parent'])) { if (isset($service['parent'])) {
$definition = new DefinitionDecorator($service['parent']); $definition = new ChildDefinition($service['parent']);
} else { } else {
$definition = new Definition(); $definition = new Definition();
// As of Symfony 3.4 all services are private by default.
$definition->setPublic(TRUE);
} }
if (isset($service['class'])) { if (isset($service['class'])) {
...@@ -329,7 +331,10 @@ protected function loadFile($file) ...@@ -329,7 +331,10 @@ protected function loadFile($file)
throw new InvalidArgumentException(sprintf('The service file "%s" is not valid.', $file)); throw new InvalidArgumentException(sprintf('The service file "%s" is not valid.', $file));
} }
return $this->validate(Yaml::decode(file_get_contents($file)), $file); // @todo Remove preg_replace() once
// https://github.com/symfony/symfony/pull/25787 is in Symfony 3.4.
$content = preg_replace('/:$\n^\s+{\s*}$/m', ': {}', file_get_contents($file));
return $this->validate(Yaml::decode($content), $file);
} }
/** /**
......
...@@ -76,10 +76,10 @@ public function onException(GetResponseForExceptionEvent $event) { ...@@ -76,10 +76,10 @@ public function onException(GetResponseForExceptionEvent $event) {
// the configured upload limit. // the configured upload limit.
if ($exception instanceof BrokenPostRequestException && $request->query->has(FormBuilderInterface::AJAX_FORM_REQUEST)) { if ($exception instanceof BrokenPostRequestException && $request->query->has(FormBuilderInterface::AJAX_FORM_REQUEST)) {
$this->drupalSetMessage($this->t('An unrecoverable error occurred. The uploaded file likely exceeded the maximum file size (@size) that this server supports.', ['@size' => $this->formatSize($exception->getSize())]), 'error'); $this->drupalSetMessage($this->t('An unrecoverable error occurred. The uploaded file likely exceeded the maximum file size (@size) that this server supports.', ['@size' => $this->formatSize($exception->getSize())]), 'error');
$response = new AjaxResponse(); $response = new AjaxResponse(NULL, 200);
$status_messages = ['#type' => 'status_messages']; $status_messages = ['#type' => 'status_messages'];
$response->addCommand(new PrependCommand(NULL, $status_messages)); $response->addCommand(new PrependCommand(NULL, $status_messages));
$response->headers->set('X-Status-Code', 200); $event->allowCustomResponseCode();
$event->setResponse($response); $event->setResponse($response);
return; return;
} }
...@@ -99,7 +99,8 @@ public function onException(GetResponseForExceptionEvent $event) { ...@@ -99,7 +99,8 @@ public function onException(GetResponseForExceptionEvent $event) {
// Since this response is being set in place of an exception, explicitly // Since this response is being set in place of an exception, explicitly
// mark this as a 200 status. // mark this as a 200 status.
$response->headers->set('X-Status-Code', 200); $response->setStatusCode(200);
$event->allowCustomResponseCode();
$event->setResponse($response); $event->setResponse($response);
} }
catch (\Exception $e) { catch (\Exception $e) {
......
...@@ -59,23 +59,23 @@ public static function setSettingsOnRequest(Request $request, Settings $settings ...@@ -59,23 +59,23 @@ public static function setSettingsOnRequest(Request $request, Settings $settings
// Initialize proxy settings. // Initialize proxy settings.
if ($settings->get('reverse_proxy', FALSE)) { if ($settings->get('reverse_proxy', FALSE)) {
$ip_header = $settings->get('reverse_proxy_header', 'X_FORWARDED_FOR'); $ip_header = $settings->get('reverse_proxy_header', 'X_FORWARDED_FOR');
$request::setTrustedHeaderName($request::HEADER_CLIENT_IP, $ip_header); $request::setTrustedHeaderName($request::HEADER_X_FORWARDED_FOR, $ip_header);
$proto_header = $settings->get('reverse_proxy_proto_header', 'X_FORWARDED_PROTO'); $proto_header = $settings->get('reverse_proxy_proto_header', 'X_FORWARDED_PROTO');
$request::setTrustedHeaderName($request::HEADER_CLIENT_PROTO, $proto_header); $request::setTrustedHeaderName($request::HEADER_X_FORWARDED_PROTO, $proto_header);
$host_header = $settings->get('reverse_proxy_host_header', 'X_FORWARDED_HOST'); $host_header = $settings->get('reverse_proxy_host_header', 'X_FORWARDED_HOST');
$request::setTrustedHeaderName($request::HEADER_CLIENT_HOST, $host_header); $request::setTrustedHeaderName($request::HEADER_X_FORWARDED_HOST, $host_header);
$port_header = $settings->get('reverse_proxy_port_header', 'X_FORWARDED_PORT'); $port_header = $settings->get('reverse_proxy_port_header', 'X_FORWARDED_PORT');
$request::setTrustedHeaderName($request::HEADER_CLIENT_PORT, $port_header); $request::setTrustedHeaderName($request::HEADER_X_FORWARDED_PORT, $port_header);
$forwarded_header = $settings->get('reverse_proxy_forwarded_header', 'FORWARDED'); $forwarded_header = $settings->get('reverse_proxy_forwarded_header', 'FORWARDED');
$request::setTrustedHeaderName($request::HEADER_FORWARDED, $forwarded_header); $request::setTrustedHeaderName($request::HEADER_FORWARDED, $forwarded_header);
$proxies = $settings->get('reverse_proxy_addresses', []); $proxies = $settings->get('reverse_proxy_addresses', []);
if (count($proxies) > 0) { if (count($proxies) > 0) {
$request::setTrustedProxies($proxies); $request::setTrustedProxies($proxies, Request::HEADER_X_FORWARDED_ALL | Request::HEADER_FORWARDED);
} }
} }
} }
......
...@@ -120,6 +120,9 @@ protected function prepareSettings() { ...@@ -120,6 +120,9 @@ protected function prepareSettings() {
// Add a listener to validate configuration schema on save. // Add a listener to validate configuration schema on save.
$yaml = new SymfonyYaml(); $yaml = new SymfonyYaml();
$content = file_get_contents($directory . '/services.yml'); $content = file_get_contents($directory . '/services.yml');
// @todo Remove preg_replace() once
// https://github.com/symfony/symfony/pull/25787 is in Symfony 3.4.
$content = preg_replace('/:$\n^\s+{\s*}$/m', ': {}', $content);
$services = $yaml->parse($content); $services = $yaml->parse($content);
$services['services']['simpletest.config_schema_checker'] = [ $services['services']['simpletest.config_schema_checker'] = [
'class' => ConfigSchemaChecker::class, 'class' => ConfigSchemaChecker::class,
...@@ -165,7 +168,11 @@ protected function setContainerParameter($name, $value) { ...@@ -165,7 +168,11 @@ protected function setContainerParameter($name, $value) {
$filename = $this->siteDirectory . '/services.yml'; $filename = $this->siteDirectory . '/services.yml';
chmod($filename, 0666); chmod($filename, 0666);
$services = Yaml::decode(file_get_contents($filename)); // @todo Remove preg_replace() once
// https://github.com/symfony/symfony/pull/25787 is in Symfony 3.4.
$content = file_get_contents($filename);
$content = preg_replace('/:$\n^\s+{\s*}$/m', ': {}', $content);
$services = Yaml::decode($content);
$services['parameters'][$name] = $value; $services['parameters'][$name] = $value;
file_put_contents($filename, Yaml::encode($services)); file_put_contents($filename, Yaml::encode($services));
......
...@@ -117,6 +117,8 @@ public function testCommentPreviewDuplicateSubmission() { ...@@ -117,6 +117,8 @@ public function testCommentPreviewDuplicateSubmission() {
// Go back and re-submit the form. // Go back and re-submit the form.
$this->getSession()->getDriver()->back(); $this->getSession()->getDriver()->back();
$submit_button = $this->assertSession()->buttonExists('Save');
$submit_button->click();
$this->assertText('Your comment has been posted.'); $this->assertText('Your comment has been posted.');
$elements = $this->xpath('//section[contains(@class, "comment-wrapper")]/article'); $elements = $this->xpath('//section[contains(@class, "comment-wrapper")]/article');
$this->assertEqual(2, count($elements)); $this->assertEqual(2, count($elements));
......
...@@ -172,12 +172,24 @@ public function testImport() { ...@@ -172,12 +172,24 @@ public function testImport() {
'import' => $import, 'import' => $import,
]; ];
$this->drupalPostForm('admin/config/development/configuration/single/import', $edit, t('Import')); $this->drupalPostForm('admin/config/development/configuration/single/import', $edit, t('Import'));
$this->assertRaw(t('Are you sure you want to update the %name @type?', ['%name' => 'second', '@type' => 'test configuration'])); if (extension_loaded('yaml')) {
$this->drupalPostForm(NULL, [], t('Confirm')); // If the yaml extension is loaded it will work but not create the PHP
$entity = $storage->load('second'); // object.
$this->assertRaw(t('The configuration was imported successfully.')); $this->assertRaw(t('Are you sure you want to update the %name @type?', [
$this->assertTrue(is_string($entity->label()), 'Entity label is a string'); '%name' => 'second',
$this->assertTrue(strpos($entity->label(), 'ObjectSerialization') > 0, 'Label contains serialized object'); '@type' => 'test configuration'
]));
$this->drupalPostForm(NULL, [], t('Confirm'));
$entity = $storage->load('second');
$this->assertRaw(t('The configuration was imported successfully.'));
$this->assertTrue(is_string($entity->label()), 'Entity label is a string');
$this->assertTrue(strpos($entity->label(), 'ObjectSerialization') > 0, 'Label contains serialized object');
}
else {
// If the Symfony parser is used there will be an error.
$this->assertSession()->responseContains('The import failed with the following message:');
$this->assertSession()->responseContains('Object support when parsing a YAML file has been disabled');
}
} }
/** /**
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
use Drupal\rest\LinkManager\LinkManager; use Drupal\rest\LinkManager\LinkManager;
use Drupal\rest\LinkManager\RelationLinkManager; use Drupal\rest\LinkManager\RelationLinkManager;
use Drupal\rest\LinkManager\TypeLinkManager; use Drupal\rest\LinkManager\TypeLinkManager;
use Symfony\Component\DependencyInjection\DefinitionDecorator; use Symfony\Component\DependencyInjection\ChildDefinition;
use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\DependencyInjection\Reference;
/** /**
...@@ -28,21 +28,21 @@ public function register(ContainerBuilder $container) { ...@@ -28,21 +28,21 @@ public function register(ContainerBuilder $container) {
// @deprecated in Drupal 8.3.x and will be removed before Drupal 9.0.0. // @deprecated in Drupal 8.3.x and will be removed before Drupal 9.0.0.
// Use hal.link_manager instead. // Use hal.link_manager instead.
// @see https://www.drupal.org/node/2830467 // @see https://www.drupal.org/node/2830467
$service_definition = new DefinitionDecorator(new Reference('hal.link_manager')); $service_definition = new ChildDefinition(new Reference('hal.link_manager'));
$service_definition->setClass(LinkManager::class); $service_definition->setClass(LinkManager::class);
$container->setDefinition('rest.link_manager', $service_definition); $container->setDefinition('rest.link_manager', $service_definition);
// @deprecated in Drupal 8.3.x and will be removed before Drupal 9.0.0. // @deprecated in Drupal 8.3.x and will be removed before Drupal 9.0.0.
// Use hal.link_manager.type instead. // Use hal.link_manager.type instead.
// @see https://www.drupal.org/node/2830467 // @see https://www.drupal.org/node/2830467
$service_definition = new DefinitionDecorator(new Reference('hal.link_manager.type')); $service_definition = new ChildDefinition(new Reference('hal.link_manager.type'));
$service_definition->setClass(TypeLinkManager::class); $service_definition->setClass(TypeLinkManager::class);
$container->setDefinition('rest.link_manager.type', $service_definition); $container->setDefinition('rest.link_manager.type', $service_definition);
// @deprecated in Drupal 8.3.x and will be removed before Drupal 9.0.0. // @deprecated in Drupal 8.3.x and will be removed before Drupal 9.0.0.
// Use hal.link_manager.relation instead. // Use hal.link_manager.relation instead.
// @see https://www.drupal.org/node/2830467 // @see https://www.drupal.org/node/2830467
$service_definition = new DefinitionDecorator(new Reference('hal.link_manager.relation')); $service_definition = new ChildDefinition(new Reference('hal.link_manager.relation'));
$service_definition->setClass(RelationLinkManager::class); $service_definition->setClass(RelationLinkManager::class);
$container->setDefinition('rest.link_manager.relation', $service_definition); $container->setDefinition('rest.link_manager.relation', $service_definition);
} }
......
...@@ -67,9 +67,15 @@ public function testArrayArgumentsSQLInjection() { ...@@ -67,9 +67,15 @@ public function testArrayArgumentsSQLInjection() {
public function testConditionOperatorArgumentsSQLInjection() { public function testConditionOperatorArgumentsSQLInjection() {
$injection = "IS NOT NULL) ;INSERT INTO {test} (name) VALUES ('test12345678'); -- "; $injection = "IS NOT NULL) ;INSERT INTO {test} (name) VALUES ('test12345678'); -- ";
// Convert errors to exceptions for testing purposes below. $previous_error_handler = set_error_handler(function ($severity, $message, $filename, $lineno, $context) use (&$previous_error_handler) {
set_error_handler(function ($severity, $message, $filename, $lineno) { // Normalize the filename to use UNIX directory separators.
throw new \ErrorException($message, 0, $severity, $filename, $lineno); if (preg_match('@core/lib/Drupal/Core/Database/Query/Condition.php$@', str_replace(DIRECTORY_SEPARATOR, '/', $filename))) {
// Convert errors to exceptions for testing purposes below.
throw new \ErrorException($message, 0, $severity, $filename, $lineno);
}
if ($previous_error_handler) {
return $previous_error_handler($severity, $message, $filename, $lineno, $context);
}
}); });
try { try {
$result = db_select('test', 't') $result = db_select('test', 't')
......
...@@ -68,7 +68,7 @@ protected function setUp() { ...@@ -68,7 +68,7 @@ protected function setUp() {
$this->containerBuilder->getAliases()->willReturn([]); $this->containerBuilder->getAliases()->willReturn([]);
$this->containerBuilder->getParameterBag()->willReturn(new ParameterBag()); $this->containerBuilder->getParameterBag()->willReturn(new ParameterBag());
$this->containerBuilder->getDefinitions()->willReturn(NULL); $this->containerBuilder->getDefinitions()->willReturn(NULL);
$this->containerBuilder->isFrozen()->willReturn(TRUE); $this->containerBuilder->isCompiled()->willReturn(TRUE);
$definition = []; $definition = [];
$definition['aliases'] = []; $definition['aliases'] = [];
...@@ -147,7 +147,7 @@ public function testGetParameters($parameters, $definition_parameters, $is_froze ...@@ -147,7 +147,7 @@ public function testGetParameters($parameters, $definition_parameters, $is_froze
$parameter_bag = new ParameterBag($parameters); $parameter_bag = new ParameterBag($parameters);
$this->containerBuilder->getParameterBag()->willReturn($parameter_bag); $this->containerBuilder->getParameterBag()->willReturn($parameter_bag);
$this->containerBuilder->isFrozen()->willReturn($is_frozen); $this->containerBuilder->isCompiled()->willReturn($is_frozen);
if (isset($parameters['reference'])) { if (isset($parameters['reference'])) {
$definition = new Definition('\stdClass'); $definition = new Definition('\stdClass');
......
...@@ -193,4 +193,59 @@ public function testGetListenerPriorityWithServices() ...@@ -193,4 +193,59 @@ public function testGetListenerPriorityWithServices()
$this->assertSame(5, $actualPriority); $this->assertSame(5, $actualPriority);
} }
/**
* @expectedDeprecation The Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher class is deprecated since Symfony 3.3 and will be removed in 4.0. Use EventDispatcher with closure factories instead.
* @group legacy
*/
public function testAddAListenerService() {
parent::testAddAListenerService();
}
/**
* @expectedDeprecation The Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher class is deprecated since Symfony 3.3 and will be removed in 4.0. Use EventDispatcher with closure factories instead.
* @group legacy
*/
public function testPreventDuplicateListenerService() {
parent::testPreventDuplicateListenerService();