Issue #3197482 by longwave, Spokje, Taran2L, murilohp, catch, Gábor Hojtsy, daffie: Update Drupal 10 to depend on Symfony 5.4 (as a stepping stone to Symfony 6, for deprecation checking support)
parent
cf6f4befc8
commit
7b324dd8f1
|
@ -24,16 +24,16 @@
|
|||
"mikey179/vfsstream": "^1.6.8",
|
||||
"phpunit/phpunit": "^9.5",
|
||||
"phpspec/prophecy-phpunit": "^2",
|
||||
"symfony/css-selector": "^4.4",
|
||||
"symfony/css-selector": "^5.4",
|
||||
"symfony/phpunit-bridge": "^5.4",
|
||||
"symfony/var-dumper": "^5.4",
|
||||
"symfony/error-handler": "^4.4",
|
||||
"symfony/error-handler": "^5.4",
|
||||
"justinrainbow/json-schema": "^5.2",
|
||||
"symfony/filesystem": "^4.4",
|
||||
"symfony/finder": "^4.4",
|
||||
"symfony/lock": "^4.4",
|
||||
"symfony/browser-kit": "^4.4",
|
||||
"symfony/dom-crawler": "^4.4 !=4.4.5",
|
||||
"symfony/filesystem": "^5.4",
|
||||
"symfony/finder": "^5.4",
|
||||
"symfony/lock": "^5.4",
|
||||
"symfony/browser-kit": "^5.4",
|
||||
"symfony/dom-crawler": "^5.4",
|
||||
"easyrdf/easyrdf": "^0.9 || ^1.0"
|
||||
},
|
||||
"replace": {
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -26,39 +26,40 @@
|
|||
"pear/pear_exception": "v1.0.2",
|
||||
"psr/cache": "1.0.1",
|
||||
"psr/container": "1.1.1",
|
||||
"psr/event-dispatcher": "1.0.0",
|
||||
"psr/http-client": "1.0.1",
|
||||
"psr/http-factory": "1.0.1",
|
||||
"psr/http-message": "1.0.1",
|
||||
"psr/log": "1.1.4",
|
||||
"ralouphie/getallheaders": "3.0.3",
|
||||
"stack/builder": "v1.0.6",
|
||||
"symfony/console": "v4.4.34",
|
||||
"symfony/debug": "v4.4.31",
|
||||
"symfony/dependency-injection": "v4.4.34",
|
||||
"symfony/console": "v5.4.2",
|
||||
"symfony/dependency-injection": "v5.4.2",
|
||||
"symfony/deprecation-contracts": "v2.5.0",
|
||||
"symfony/error-handler": "v4.4.34",
|
||||
"symfony/event-dispatcher": "v4.4.34",
|
||||
"symfony/event-dispatcher-contracts": "v1.1.11",
|
||||
"symfony/http-client-contracts": "v2.5.0",
|
||||
"symfony/http-foundation": "v4.4.34",
|
||||
"symfony/http-kernel": "v4.4.35",
|
||||
"symfony/mime": "v5.4.0",
|
||||
"symfony/polyfill-ctype": "v1.23.0",
|
||||
"symfony/polyfill-iconv": "v1.23.0",
|
||||
"symfony/polyfill-intl-idn": "v1.23.0",
|
||||
"symfony/polyfill-intl-normalizer": "v1.23.0",
|
||||
"symfony/polyfill-mbstring": "v1.23.1",
|
||||
"symfony/polyfill-php80": "v1.23.1",
|
||||
"symfony/process": "v4.4.35",
|
||||
"symfony/error-handler": "v5.4.2",
|
||||
"symfony/event-dispatcher": "v5.4.0",
|
||||
"symfony/event-dispatcher-contracts": "v3.0.0",
|
||||
"symfony/http-foundation": "v5.4.2",
|
||||
"symfony/http-kernel": "v5.4.2",
|
||||
"symfony/mime": "v5.4.2",
|
||||
"symfony/polyfill-ctype": "v1.24.0",
|
||||
"symfony/polyfill-iconv": "v1.24.0",
|
||||
"symfony/polyfill-intl-grapheme": "v1.24.0",
|
||||
"symfony/polyfill-intl-idn": "v1.24.0",
|
||||
"symfony/polyfill-intl-normalizer": "v1.24.0",
|
||||
"symfony/polyfill-mbstring": "v1.24.0",
|
||||
"symfony/polyfill-php80": "v1.24.0",
|
||||
"symfony/polyfill-php81": "v1.24.0",
|
||||
"symfony/process": "v5.4.2",
|
||||
"symfony/psr-http-message-bridge": "v2.1.2",
|
||||
"symfony/routing": "v4.4.34",
|
||||
"symfony/serializer": "v4.4.35",
|
||||
"symfony/routing": "v5.4.0",
|
||||
"symfony/serializer": "v5.4.2",
|
||||
"symfony/service-contracts": "v2.5.0",
|
||||
"symfony/translation": "v4.4.34",
|
||||
"symfony/translation-contracts": "v2.5.0",
|
||||
"symfony/validator": "v4.4.35",
|
||||
"symfony/var-dumper": "v5.4.0",
|
||||
"symfony/yaml": "v4.4.34",
|
||||
"symfony/string": "v6.0.2",
|
||||
"symfony/translation-contracts": "v3.0.0",
|
||||
"symfony/validator": "v5.4.2",
|
||||
"symfony/var-dumper": "v5.4.2",
|
||||
"symfony/yaml": "v5.4.2",
|
||||
"twig/twig": "v3.3.7",
|
||||
"typo3/phar-stream-wrapper": "v3.1.7"
|
||||
}
|
||||
|
|
|
@ -18,13 +18,13 @@
|
|||
"mikey179/vfsstream": "^1.6.8",
|
||||
"phpspec/prophecy-phpunit": "^2",
|
||||
"phpunit/phpunit": "^9.5",
|
||||
"symfony/browser-kit": "^4.4",
|
||||
"symfony/css-selector": "^4.4",
|
||||
"symfony/dom-crawler": "^4.4 !=4.4.5",
|
||||
"symfony/error-handler": "^4.4",
|
||||
"symfony/filesystem": "^4.4",
|
||||
"symfony/finder": "^4.4",
|
||||
"symfony/lock": "^4.4",
|
||||
"symfony/browser-kit": "^5.4",
|
||||
"symfony/css-selector": "^5.4",
|
||||
"symfony/dom-crawler": "^5.4",
|
||||
"symfony/error-handler": "^5.4",
|
||||
"symfony/filesystem": "^5.4",
|
||||
"symfony/finder": "^5.4",
|
||||
"symfony/lock": "^5.4",
|
||||
"symfony/phpunit-bridge": "^5.4",
|
||||
"symfony/var-dumper": "^5.4"
|
||||
}
|
||||
|
|
|
@ -58,12 +58,12 @@
|
|||
"seld/phar-utils": "1.1.2",
|
||||
"sirbrillig/phpcs-variable-analysis": "v2.11.2",
|
||||
"squizlabs/php_codesniffer": "3.6.1",
|
||||
"symfony/browser-kit": "v4.4.27",
|
||||
"symfony/css-selector": "v4.4.27",
|
||||
"symfony/dom-crawler": "v4.4.30",
|
||||
"symfony/filesystem": "v4.4.27",
|
||||
"symfony/finder": "v4.4.30",
|
||||
"symfony/lock": "v4.4.33",
|
||||
"symfony/browser-kit": "v5.4.2",
|
||||
"symfony/css-selector": "v5.4.2",
|
||||
"symfony/dom-crawler": "v5.4.2",
|
||||
"symfony/filesystem": "v5.4.0",
|
||||
"symfony/finder": "v5.4.2",
|
||||
"symfony/lock": "v5.4.2",
|
||||
"symfony/phpunit-bridge": "v5.4.0",
|
||||
"theseer/tokenizer": "1.2.1",
|
||||
"webmozart/assert": "1.10.0"
|
||||
|
|
|
@ -64,7 +64,6 @@ class Config {
|
|||
'symfony/browser-kit' => ['Tests'],
|
||||
'symfony/console' => ['Tests'],
|
||||
'symfony/css-selector' => ['Tests'],
|
||||
'symfony/debug' => ['Tests'],
|
||||
'symfony/dependency-injection' => ['Tests'],
|
||||
'symfony/dom-crawler' => ['Tests'],
|
||||
'symfony/filesystem' => ['Tests'],
|
||||
|
@ -77,7 +76,6 @@ class Config {
|
|||
'symfony/psr-http-message-bridge' => ['Tests'],
|
||||
'symfony/routing' => ['Tests'],
|
||||
'symfony/serializer' => ['Tests'],
|
||||
'symfony/translation' => ['Tests'],
|
||||
'symfony/var-dumper' => ['Tests'],
|
||||
'symfony/validator' => ['Tests', 'Resources'],
|
||||
'symfony/yaml' => ['Tests'],
|
||||
|
|
|
@ -18,20 +18,19 @@
|
|||
"ext-tokenizer": "*",
|
||||
"ext-xml": "*",
|
||||
"php": ">=8.0.2",
|
||||
"symfony/console": "^4.4",
|
||||
"symfony/dependency-injection": "^4.4",
|
||||
"symfony/event-dispatcher": "^4.4",
|
||||
"symfony/http-foundation": "^4.4.7",
|
||||
"symfony/http-kernel": "^4.4",
|
||||
"symfony/console": "^5.4",
|
||||
"symfony/dependency-injection": "^5.4",
|
||||
"symfony/event-dispatcher": "^5.4",
|
||||
"symfony/http-foundation": "^5.4",
|
||||
"symfony/http-kernel": "^5.4",
|
||||
"symfony/mime": "^5.4",
|
||||
"symfony/routing": "^4.4",
|
||||
"symfony/serializer": "^4.4",
|
||||
"symfony/translation": "^4.4",
|
||||
"symfony/validator": "^4.4",
|
||||
"symfony/process": "^4.4",
|
||||
"symfony/routing": "^5.4",
|
||||
"symfony/serializer": "^5.4",
|
||||
"symfony/validator": "^5.4",
|
||||
"symfony/process": "^5.4",
|
||||
"symfony/polyfill-iconv": "^1.0",
|
||||
"symfony/polyfill-php80": "^1.16",
|
||||
"symfony/yaml": "^4.4.19",
|
||||
"symfony/yaml": "^5.4",
|
||||
"typo3/phar-stream-wrapper": "^3.1.3",
|
||||
"twig/twig": "^3.0",
|
||||
"doctrine/annotations": "^1.12",
|
||||
|
|
|
@ -6,14 +6,11 @@
|
|||
*/
|
||||
|
||||
use Drupal\Component\Utility\Crypt;
|
||||
use Drupal\Core\Http\InputBag;
|
||||
use Drupal\Core\Logger\RfcLogLevel;
|
||||
use Drupal\Core\Test\TestDatabase;
|
||||
use Drupal\Core\Utility\Error;
|
||||
use Drupal\Core\StringTranslation\TranslatableMarkup;
|
||||
use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\InputBag as SymfonyInputBag;
|
||||
|
||||
/**
|
||||
* Minimum allowed version of PHP for Drupal to be bootstrapped.
|
||||
|
@ -126,30 +123,6 @@ define('REQUEST_TIME', (int) $_SERVER['REQUEST_TIME']);
|
|||
*/
|
||||
define('DRUPAL_ROOT', dirname(__DIR__, 2));
|
||||
|
||||
/**
|
||||
* Declare class aliases that will be added by the autoloader.
|
||||
*/
|
||||
// @todo https://www.drupal.org/project/drupal/issues/3197482 Remove this class
|
||||
// alias once Drupal is running Symfony 5.3 or higher.
|
||||
class_alias('Drupal\Core\Http\KernelEvent', 'Symfony\Component\HttpKernel\Event\KernelEvent', TRUE);
|
||||
|
||||
/**
|
||||
* Set up the Symfony Request factory for forward compatibility with Symfony 5.
|
||||
*
|
||||
* @todo Remove this when Symfony 4 is no longer supported.
|
||||
*/
|
||||
Request::setFactory(
|
||||
function ($query, $request, $attributes, $cookies, $files, $server, $content) {
|
||||
$request = new Request($query, $request, $attributes, $cookies, $files, $server, $content);
|
||||
foreach (['request', 'query', 'cookies'] as $bag) {
|
||||
if (!($bag instanceof SymfonyInputBag)) {
|
||||
$request->$bag = new InputBag($request->$bag->all());
|
||||
}
|
||||
}
|
||||
return $request;
|
||||
}
|
||||
);
|
||||
|
||||
/**
|
||||
* Returns and optionally sets the filename for a system resource.
|
||||
*
|
||||
|
|
|
@ -3,11 +3,8 @@
|
|||
namespace Drupal\Component\EventDispatcher;
|
||||
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Symfony\Component\EventDispatcher\Event;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
use Symfony\Contracts\EventDispatcher\Event as ContractsEvent;
|
||||
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface as ContractsEventDispatcherInterface;
|
||||
|
||||
/**
|
||||
* A performance optimized container aware event dispatcher.
|
||||
|
@ -88,39 +85,8 @@ class ContainerAwareEventDispatcher implements EventDispatcherInterface {
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function dispatch($event/*, string $event_name = NULL*/) {
|
||||
$event_name = 1 < \func_num_args() ? func_get_arg(1) : NULL;
|
||||
if (\is_object($event)) {
|
||||
$class_name = get_class($event);
|
||||
$event_name = $event_name ?? $class_name;
|
||||
|
||||
$deprecation_message = 'Symfony\Component\EventDispatcher\Event is deprecated in drupal:9.1.0 and will be replaced by Symfony\Contracts\EventDispatcher\Event in drupal:10.0.0. A new Drupal\Component\EventDispatcher\Event class is available to bridge the two versions of the class. See https://www.drupal.org/node/3159012';
|
||||
|
||||
// Trigger a deprecation error if the deprecated Event class is used
|
||||
// directly.
|
||||
if ($class_name === 'Symfony\Component\EventDispatcher\Event') {
|
||||
@trigger_error($deprecation_message, E_USER_DEPRECATED);
|
||||
}
|
||||
// Also try to trigger deprecation errors when classes are in the Drupal
|
||||
// namespace and inherit directly from the deprecated class. If a class is
|
||||
// in the Symfony namespace or a different one, we have to assume those
|
||||
// will be updated by the dependency itself. Exclude the Drupal Event
|
||||
// bridge class as a special case, otherwise it's pointless.
|
||||
elseif ($class_name !== 'Drupal\Component\EventDispatcher\Event' && strpos($class_name, 'Drupal') !== FALSE) {
|
||||
if (get_parent_class($event) === 'Symfony\Component\EventDispatcher\Event') {
|
||||
@trigger_error($deprecation_message, E_USER_DEPRECATED);
|
||||
}
|
||||
}
|
||||
}
|
||||
elseif (\is_string($event) && (NULL === $event_name || $event_name instanceof ContractsEvent || $event_name instanceof Event)) {
|
||||
@trigger_error('Calling the Symfony\Component\EventDispatcher\EventDispatcherInterface::dispatch() method with a string event name as the first argument is deprecated in drupal:9.1.0, an Event object will be required instead in drupal:10.0.0. See https://www.drupal.org/node/3154407', E_USER_DEPRECATED);
|
||||
$swap = $event;
|
||||
$event = $event_name ?? new Event();
|
||||
$event_name = $swap;
|
||||
}
|
||||
else {
|
||||
throw new \TypeError(sprintf('Argument 1 passed to "%s::dispatch()" must be an object, %s given.', ContractsEventDispatcherInterface::class, \gettype($event)));
|
||||
}
|
||||
public function dispatch(object $event, ?string $eventName = NULL): object {
|
||||
$event_name = $eventName ?? get_class($event);
|
||||
|
||||
if (isset($this->listeners[$event_name])) {
|
||||
// Sort listeners if necessary.
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace Drupal\Component\EventDispatcher;
|
||||
|
||||
use Symfony\Component\EventDispatcher\Event as SymfonyEvent;
|
||||
use Symfony\Contracts\EventDispatcher\Event as SymfonyEvent;
|
||||
|
||||
/**
|
||||
* Provides a forward-compatibility layer for the Symfony 5 event class.
|
||||
|
|
|
@ -60,7 +60,6 @@ class Composer {
|
|||
'symfony/browser-kit' => ['Tests'],
|
||||
'symfony/console' => ['Tests'],
|
||||
'symfony/css-selector' => ['Tests'],
|
||||
'symfony/debug' => ['Tests'],
|
||||
'symfony/dependency-injection' => ['Tests'],
|
||||
'symfony/dom-crawler' => ['Tests'],
|
||||
'symfony/filesystem' => ['Tests'],
|
||||
|
@ -74,7 +73,6 @@ class Composer {
|
|||
'symfony/psr-http-message-bridge' => ['Tests'],
|
||||
'symfony/routing' => ['Tests'],
|
||||
'symfony/serializer' => ['Tests'],
|
||||
'symfony/translation' => ['Tests'],
|
||||
'symfony/validator' => ['Tests', 'Resources'],
|
||||
'symfony/yaml' => ['Tests'],
|
||||
'theseer/tokenizer' => ['tests'],
|
||||
|
|
|
@ -20,7 +20,7 @@ class DeprecatedServicePass implements CompilerPassInterface {
|
|||
foreach ($container->getDefinitions() as $service_id => $definition) {
|
||||
if ($definition->isDeprecated()) {
|
||||
// @todo: remove when Drupal requires Symfony 5. See
|
||||
// https://www.drupal.org/project/drupal/issues/3197482
|
||||
// https://www.drupal.org/project/drupal/issues/3197729
|
||||
if (method_exists($definition, 'getDeprecation')) {
|
||||
$deprecated_services[$service_id] = $definition->getDeprecation($service_id)['message'];
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ class DeprecatedServicePass implements CompilerPassInterface {
|
|||
foreach ($container->getAliases() as $service_id => $definition) {
|
||||
if ($definition->isDeprecated()) {
|
||||
// @todo: remove when Drupal requires Symfony 5. See
|
||||
// https://www.drupal.org/project/drupal/issues/3197482
|
||||
// https://www.drupal.org/project/drupal/issues/3197729
|
||||
if (method_exists($definition, 'getDeprecation')) {
|
||||
$deprecated_services[$service_id] = $definition->getDeprecation($service_id)['message'];
|
||||
}
|
||||
|
|
|
@ -6,7 +6,6 @@ use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
|
|||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Exception\LogicException;
|
||||
use Symfony\Component\DependencyInjection\Reference;
|
||||
use Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesserInterface as LegacyMimeTypeGuesserInterface;
|
||||
use Symfony\Component\Mime\MimeTypeGuesserInterface;
|
||||
|
||||
/**
|
||||
|
@ -29,7 +28,6 @@ class MimeTypePass implements CompilerPassInterface {
|
|||
|
||||
$tag = 'mime_type_guesser';
|
||||
$interface = MimeTypeGuesserInterface::class;
|
||||
$deprecated_interface = LegacyMimeTypeGuesserInterface::class;
|
||||
|
||||
// Find all tagged handlers.
|
||||
$handlers = [];
|
||||
|
@ -37,10 +35,7 @@ class MimeTypePass implements CompilerPassInterface {
|
|||
// Validate the interface.
|
||||
$handler = $container->getDefinition($id);
|
||||
if (!is_subclass_of($handler->getClass(), $interface)) {
|
||||
// Special handling for $deprecated_interface.
|
||||
if (!is_subclass_of($handler->getClass(), $deprecated_interface)) {
|
||||
throw new LogicException("Service '$id' does not implement $interface.");
|
||||
}
|
||||
throw new LogicException("Service '$id' does not implement $interface.");
|
||||
}
|
||||
$handlers[$id] = $attributes[0]['priority'] ?? 0;
|
||||
$interfaces[$id] = $handler->getClass();
|
||||
|
@ -56,12 +51,7 @@ class MimeTypePass implements CompilerPassInterface {
|
|||
// definition.
|
||||
foreach ($handlers as $id => $priority) {
|
||||
$arguments = [new Reference($id), $priority];
|
||||
if (is_subclass_of($interfaces[$id], $interface)) {
|
||||
$consumer->addMethodCall('addMimeTypeGuesser', $arguments);
|
||||
}
|
||||
else {
|
||||
$consumer->addMethodCall('addGuesser', $arguments);
|
||||
}
|
||||
$consumer->addMethodCall('addMimeTypeGuesser', $arguments);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -108,23 +108,6 @@ class ContainerBuilder extends SymfonyContainerBuilder {
|
|||
return $alias;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setDefinition($id, Definition $definition): Definition {
|
||||
$definition = parent::setDefinition($id, $definition);
|
||||
// As of Symfony 3.4 all definitions are private by default.
|
||||
// \Symfony\Component\DependencyInjection\Compiler\ResolvePrivatesPassOnly
|
||||
// removes services marked as private from the container even if they are
|
||||
// also marked as public. Drupal requires services that are public to
|
||||
// remain in the container and not be removed.
|
||||
if ($definition->isPublic() && $definition->isPrivate()) {
|
||||
@trigger_error('Not marking service definitions as public is deprecated in drupal:9.2.0 and is required in drupal:10.0.0. Call $definition->setPublic(TRUE) before calling ::setDefinition(). See https://www.drupal.org/node/3194517', E_USER_DEPRECATED);
|
||||
$definition->setPrivate(FALSE);
|
||||
}
|
||||
return $definition;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
|
|
@ -17,7 +17,6 @@ use Drupal\Core\DependencyInjection\ServiceProviderInterface;
|
|||
use Drupal\Core\DependencyInjection\YamlFileLoader;
|
||||
use Drupal\Core\Extension\Extension;
|
||||
use Drupal\Core\Extension\ExtensionDiscovery;
|
||||
use Drupal\Core\File\MimeType\MimeTypeGuesser;
|
||||
use Drupal\Core\Http\TrustedHostsRequestFactory;
|
||||
use Drupal\Core\Installer\InstallerKernel;
|
||||
use Drupal\Core\Installer\InstallerRedirectTrait;
|
||||
|
@ -597,9 +596,6 @@ class DrupalKernel implements DrupalKernelInterface, TerminableInterface {
|
|||
// Set the allowed protocols.
|
||||
UrlHelper::setAllowedProtocols($this->container->getParameter('filter_protocols'));
|
||||
|
||||
// Override of Symfony's MIME type guesser singleton.
|
||||
MimeTypeGuesser::registerWithSymfonyGuesser($this->container);
|
||||
|
||||
$this->prepared = TRUE;
|
||||
}
|
||||
|
||||
|
|
|
@ -3,13 +3,12 @@
|
|||
namespace Drupal\Core\File\MimeType;
|
||||
|
||||
use Drupal\Core\Extension\ModuleHandlerInterface;
|
||||
use Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesserInterface as LegacyMimeTypeGuesserInterface;
|
||||
use Symfony\Component\Mime\MimeTypeGuesserInterface;
|
||||
|
||||
/**
|
||||
* Makes possible to guess the MIME type of a file using its extension.
|
||||
*/
|
||||
class ExtensionMimeTypeGuesser implements MimeTypeGuesserInterface, LegacyMimeTypeGuesserInterface {
|
||||
class ExtensionMimeTypeGuesser implements MimeTypeGuesserInterface {
|
||||
|
||||
/**
|
||||
* Default MIME extension mapping.
|
||||
|
|
|
@ -3,15 +3,12 @@
|
|||
namespace Drupal\Core\File\MimeType;
|
||||
|
||||
use Drupal\Core\StreamWrapper\StreamWrapperManagerInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesser as SymfonyMimeTypeGuesser;
|
||||
use Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesserInterface as LegacyMimeTypeGuesserInterface;
|
||||
use Symfony\Component\Mime\MimeTypeGuesserInterface as MimeTypeGuesserInterface;
|
||||
use Symfony\Component\Mime\MimeTypeGuesserInterface;
|
||||
|
||||
/**
|
||||
* Defines a MIME type guesser that also supports stream wrapper paths.
|
||||
*/
|
||||
class MimeTypeGuesser implements LegacyMimeTypeGuesserInterface, MimeTypeGuesserInterface {
|
||||
class MimeTypeGuesser implements MimeTypeGuesserInterface {
|
||||
|
||||
/**
|
||||
* An array of arrays of registered guessers keyed by priority.
|
||||
|
@ -104,29 +101,6 @@ class MimeTypeGuesser implements LegacyMimeTypeGuesserInterface, MimeTypeGuesser
|
|||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends a MIME type guesser to the guessers chain.
|
||||
*
|
||||
* @param \Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesserInterface $guesser
|
||||
* The guesser to be appended.
|
||||
* @param int $priority
|
||||
* The priority of the guesser being added.
|
||||
*
|
||||
* @return $this
|
||||
*
|
||||
* @deprecated in drupal:9.1.0 and is removed from drupal:10.0.0. Use
|
||||
* ::addMimeTypeGuesser() instead.
|
||||
*
|
||||
* @see https://www.drupal.org/node/3133341
|
||||
*/
|
||||
public function addGuesser(LegacyMimeTypeGuesserInterface $guesser, $priority = 0) {
|
||||
@trigger_error(__METHOD__ . ' is deprecated in drupal:9.1.0 and is removed from drupal:10.0.0. Use ::addMimeTypeGuesser() instead. See https://www.drupal.org/node/3133341', E_USER_DEPRECATED);
|
||||
$this->guessers[$priority][] = $guesser;
|
||||
// Mark sorted guessers for rebuild.
|
||||
$this->sortedGuessers = NULL;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
@ -150,20 +124,4 @@ class MimeTypeGuesser implements LegacyMimeTypeGuesserInterface, MimeTypeGuesser
|
|||
return $sorted;
|
||||
}
|
||||
|
||||
/**
|
||||
* A helper function to register with Symfony's singleton MIME type guesser.
|
||||
*
|
||||
* Symfony's default mimetype guessers have dependencies on PHP's fileinfo
|
||||
* extension or being able to run the system command file. Drupal's guesser
|
||||
* does not have these dependencies.
|
||||
*
|
||||
* @see \Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesser
|
||||
*/
|
||||
public static function registerWithSymfonyGuesser(ContainerInterface $container) {
|
||||
// Reset state, so we do not store more and more services during test runs.
|
||||
SymfonyMimeTypeGuesser::reset();
|
||||
$singleton = SymfonyMimeTypeGuesser::getInstance();
|
||||
$singleton->register($container->get('file.mime_type.guesser'));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,88 +0,0 @@
|
|||
<?php
|
||||
|
||||
// @codingStandardsIgnoreFile
|
||||
// cspell:disable
|
||||
|
||||
namespace Drupal\Core\Http;
|
||||
|
||||
use Drupal\Component\EventDispatcher\Event;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
||||
|
||||
/**
|
||||
* Symfony 6 bridge.
|
||||
*
|
||||
* This is a copy of Symfony\Component\HttpKernel\Event\KernelEvent
|
||||
* with two changes: adding an ::isMainRequest() method for forward
|
||||
* compatibility with Symfony 5.3+, and issuing a deprecation message from
|
||||
* ::isMasterRequest().
|
||||
*/
|
||||
class KernelEvent extends Event
|
||||
{
|
||||
private $kernel;
|
||||
private $request;
|
||||
private $requestType;
|
||||
|
||||
/**
|
||||
* @param int $requestType The request type the kernel is currently processing; one of
|
||||
* HttpKernelInterface::MASTER_REQUEST or HttpKernelInterface::SUB_REQUEST
|
||||
*/
|
||||
public function __construct(HttpKernelInterface $kernel, Request $request, ?int $requestType)
|
||||
{
|
||||
$this->kernel = $kernel;
|
||||
$this->request = $request;
|
||||
$this->requestType = $requestType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the kernel in which this event was thrown.
|
||||
*
|
||||
* @return HttpKernelInterface
|
||||
*/
|
||||
public function getKernel()
|
||||
{
|
||||
return $this->kernel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the request the kernel is currently processing.
|
||||
*
|
||||
* @return Request
|
||||
*/
|
||||
public function getRequest()
|
||||
{
|
||||
return $this->request;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the request type the kernel is currently processing.
|
||||
*
|
||||
* @return int One of HttpKernelInterface::MASTER_REQUEST and
|
||||
* HttpKernelInterface::SUB_REQUEST
|
||||
*/
|
||||
public function getRequestType()
|
||||
{
|
||||
return $this->requestType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if this is a master request.
|
||||
*
|
||||
* @return bool True if the request is a master request
|
||||
*/
|
||||
public function isMasterRequest()
|
||||
{
|
||||
@trigger_error('Symfony\Component\HttpKernel\Event\KernelEvent::isMasterRequest() is deprecated, use isMainRequest()', E_USER_DEPRECATED);
|
||||
return HttpKernelInterface::MASTER_REQUEST === $this->requestType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if this is a main request.
|
||||
*
|
||||
* @return bool True if the request is a main request
|
||||
*/
|
||||
public function isMainRequest()
|
||||
{
|
||||
return HttpKernelInterface::MASTER_REQUEST === $this->requestType;
|
||||
}
|
||||
}
|
|
@ -30,7 +30,7 @@ class RequestStack extends SymfonyRequestStack {
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getMasterRequest() {
|
||||
public function getMasterRequest(): ?Request {
|
||||
@trigger_error('Drupal\Core\Http\RequestStack::getMasterRequest() is deprecated, use getMainRequest() instead.', E_USER_DEPRECATED);
|
||||
return $this->getMainRequest();
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace Drupal\Core\Http;
|
||||
|
||||
use Symfony\Component\HttpFoundation\InputBag as SymfonyInputBag;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
/**
|
||||
|
@ -62,17 +61,7 @@ class TrustedHostsRequestFactory {
|
|||
if (empty($server['HTTP_HOST']) || ($server['HTTP_HOST'] === 'localhost' && $this->host !== 'localhost')) {
|
||||
$server['HTTP_HOST'] = $this->host;
|
||||
}
|
||||
$request = new Request($query, $request, $attributes, $cookies, $files, $server, $content);
|
||||
|
||||
// Replace ParameterBag with InputBag for compatibility with Symfony 5.
|
||||
// @todo Remove this when Symfony 4 is no longer supported.
|
||||
foreach (['request', 'query', 'cookies'] as $bag) {
|
||||
if (!($bag instanceof SymfonyInputBag)) {
|
||||
$request->$bag = new InputBag($request->$bag->all());
|
||||
}
|
||||
}
|
||||
|
||||
return $request;
|
||||
return new Request($query, $request, $attributes, $cookies, $files, $server, $content);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace Drupal\Core\ProxyClass\File\MimeType {
|
|||
*
|
||||
* @see \Drupal\Component\ProxyBuilder
|
||||
*/
|
||||
class ExtensionMimeTypeGuesser implements \Symfony\Component\Mime\MimeTypeGuesserInterface, \Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesserInterface
|
||||
class ExtensionMimeTypeGuesser implements \Symfony\Component\Mime\MimeTypeGuesserInterface
|
||||
{
|
||||
|
||||
use \Drupal\Core\DependencyInjection\DependencySerializationTrait;
|
||||
|
@ -78,7 +78,7 @@ namespace Drupal\Core\ProxyClass\File\MimeType {
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function guessMimeType($path): string
|
||||
public function guessMimeType($path): ?string
|
||||
{
|
||||
return $this->lazyLoadItself()->guessMimeType($path);
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace Drupal\Core\ProxyClass\File\MimeType {
|
|||
*
|
||||
* @see \Drupal\Component\ProxyBuilder
|
||||
*/
|
||||
class MimeTypeGuesser implements \Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesserInterface, \Symfony\Component\Mime\MimeTypeGuesserInterface
|
||||
class MimeTypeGuesser implements \Symfony\Component\Mime\MimeTypeGuesserInterface
|
||||
{
|
||||
|
||||
use \Drupal\Core\DependencyInjection\DependencySerializationTrait;
|
||||
|
@ -70,7 +70,7 @@ namespace Drupal\Core\ProxyClass\File\MimeType {
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function guessMimeType(string $path): string
|
||||
public function guessMimeType(string $path): ?string
|
||||
{
|
||||
return $this->lazyLoadItself()->guessMimeType($path);
|
||||
}
|
||||
|
@ -86,19 +86,11 @@ namespace Drupal\Core\ProxyClass\File\MimeType {
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function addMimeTypeGuesser($guesser, $priority = 0)
|
||||
public function addMimeTypeGuesser(\Symfony\Component\Mime\MimeTypeGuesserInterface $guesser, $priority = 0)
|
||||
{
|
||||
return $this->lazyLoadItself()->addMimeTypeGuesser($guesser, $priority);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function addGuesser(\Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesserInterface $guesser, $priority = 0)
|
||||
{
|
||||
return $this->lazyLoadItself()->addGuesser($guesser, $priority);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
@ -107,14 +99,6 @@ namespace Drupal\Core\ProxyClass\File\MimeType {
|
|||
return $this->lazyLoadItself()->isGuesserSupported();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function registerWithSymfonyGuesser(\Symfony\Component\DependencyInjection\ContainerInterface $container)
|
||||
{
|
||||
\Drupal\Core\File\MimeType\MimeTypeGuesser::registerWithSymfonyGuesser($container);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -437,7 +437,7 @@ abstract class EntityResourceTestBase extends ResourceTestBase {
|
|||
$this->assertResourceErrorResponse(403, $this->getExpectedUnauthorizedAccessMessage('GET'), $response, $expected_cacheability->getCacheTags(), $expected_cacheability->getCacheContexts(), 'MISS', FALSE);
|
||||
}
|
||||
else {
|
||||
$this->assertResourceErrorResponse(404, 'No route found for "GET ' . str_replace($this->baseUrl, '', $this->getEntityResourceUrl()->setAbsolute()->toString()) . '"', $response);
|
||||
$this->assertResourceErrorResponse(404, 'No route found for "GET ' . $this->getEntityResourceUrl()->setAbsolute()->toString() . '"', $response);
|
||||
}
|
||||
|
||||
$this->provisionEntityResource();
|
||||
|
@ -723,7 +723,7 @@ abstract class EntityResourceTestBase extends ResourceTestBase {
|
|||
|
||||
// DX: 404 when resource not provisioned.
|
||||
$response = $this->request('POST', $url, $request_options);
|
||||
$this->assertResourceErrorResponse(404, 'No route found for "POST ' . str_replace($this->baseUrl, '', $this->getEntityResourcePostUrl()->setAbsolute()->toString()) . '"', $response);
|
||||
$this->assertResourceErrorResponse(404, 'No route found for "POST ' . $this->getEntityResourcePostUrl()->setAbsolute()->toString() . '"', $response);
|
||||
|
||||
$this->provisionEntityResource();
|
||||
// Simulate the developer again forgetting the ?_format query string.
|
||||
|
@ -913,10 +913,10 @@ abstract class EntityResourceTestBase extends ResourceTestBase {
|
|||
// DX: 404 when resource not provisioned, 405 if canonical route.
|
||||
$response = $this->request('PATCH', $url, $request_options);
|
||||
if ($has_canonical_url) {
|
||||
$this->assertResourceErrorResponse(405, 'No route found for "PATCH ' . str_replace($this->baseUrl, '', $this->getEntityResourceUrl()->setAbsolute()->toString()) . '": Method Not Allowed (Allow: GET, POST, HEAD)', $response);
|
||||
$this->assertResourceErrorResponse(405, 'No route found for "PATCH ' . $this->getEntityResourceUrl()->setAbsolute()->toString() . '": Method Not Allowed (Allow: GET, POST, HEAD)', $response);
|
||||
}
|
||||
else {
|
||||
$this->assertResourceErrorResponse(404, 'No route found for "PATCH ' . str_replace($this->baseUrl, '', $this->getEntityResourceUrl()->setAbsolute()->toString()) . '"', $response);
|
||||
$this->assertResourceErrorResponse(404, 'No route found for "PATCH ' . $this->getEntityResourceUrl()->setAbsolute()->toString() . '"', $response);
|
||||
}
|
||||
|
||||
$this->provisionEntityResource();
|
||||
|
@ -1140,10 +1140,10 @@ abstract class EntityResourceTestBase extends ResourceTestBase {
|
|||
$response = $this->request('DELETE', $url, $request_options);
|
||||
if ($has_canonical_url) {
|
||||
$this->assertSame(['GET, POST, HEAD'], $response->getHeader('Allow'));
|
||||
$this->assertResourceErrorResponse(405, 'No route found for "DELETE ' . str_replace($this->baseUrl, '', $this->getEntityResourceUrl()->setAbsolute()->toString()) . '": Method Not Allowed (Allow: GET, POST, HEAD)', $response);
|
||||
$this->assertResourceErrorResponse(405, 'No route found for "DELETE ' . $this->getEntityResourceUrl()->setAbsolute()->toString() . '": Method Not Allowed (Allow: GET, POST, HEAD)', $response);
|
||||
}
|
||||
else {
|
||||
$this->assertResourceErrorResponse(404, 'No route found for "DELETE ' . str_replace($this->baseUrl, '', $this->getEntityResourceUrl()->setAbsolute()->toString()) . '"', $response);
|
||||
$this->assertResourceErrorResponse(404, 'No route found for "DELETE ' . $this->getEntityResourceUrl()->setAbsolute()->toString() . '"', $response);
|
||||
}
|
||||
|
||||
$this->provisionEntityResource();
|
||||
|
|
|
@ -12,6 +12,7 @@ use Symfony\Component\DependencyInjection\ContainerBuilder;
|
|||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Session\SessionInterface;
|
||||
use Symfony\Component\HttpKernel\Event\ResponseEvent;
|
||||
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass \Drupal\user\UserAuth
|
||||
|
@ -257,15 +258,12 @@ class UserAuthTest extends UnitTestCase {
|
|||
->method('remove')
|
||||
->with('check_logged_in');
|
||||
|
||||
$event_mock = $this->createMock(ResponseEvent::class);
|
||||
$event_mock
|
||||
->expects($this->once())
|
||||
->method('getResponse')
|
||||
->willReturn($response);
|
||||
$event_mock
|
||||
->expects($this->exactly(3))
|
||||
->method('getRequest')
|
||||
->willReturn($request);
|
||||
$event = new ResponseEvent(
|
||||
$this->createMock(HttpKernelInterface::class),
|
||||
$request,
|
||||
HttpKernelInterface::MAIN_REQUEST,
|
||||
$response
|
||||
);
|
||||
|
||||
$request
|
||||
->setSession($session_mock);
|
||||
|
@ -275,7 +273,7 @@ class UserAuthTest extends UnitTestCase {
|
|||
->disableOriginalConstructor()
|
||||
->onlyMethods([])
|
||||
->getMock()
|
||||
->addCheckToUrl($event_mock);
|
||||
->addCheckToUrl($event);
|
||||
|
||||
$this->assertSame("$frontend_url?check_logged_in=1", $response->getTargetUrl());
|
||||
}
|
||||
|
|
|
@ -9,7 +9,6 @@ use Drupal\KernelTests\KernelTestBase;
|
|||
use org\bovigo\vfs\vfsStream;
|
||||
use Prophecy\Argument;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpKernel\Event\KernelEvent;
|
||||
|
||||
/**
|
||||
* Tests DIC compilation to disk.
|
||||
|
@ -59,19 +58,6 @@ class DrupalKernelTest extends KernelTestBase {
|
|||
return $kernel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests KernelEvent class_alias() override.
|
||||
*
|
||||
* @todo https://www.drupal.org/project/drupal/issues/3197482 Remove this test
|
||||
* once Drupal is using Symfony 5.3 or higher.
|
||||
*/
|
||||
public function testKernelEvent() {
|
||||
$request = Request::createFromGlobals();
|
||||
$kernel = $this->getTestKernel($request);
|
||||
$event = new KernelEvent($kernel, $request, $kernel::MASTER_REQUEST);
|
||||
$this->assertTrue($event->isMainRequest());
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests DIC compilation.
|
||||
*/
|
||||
|
|
|
@ -89,19 +89,4 @@ class MimeTypeTest extends FileTestBase {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test deprecations.
|
||||
*
|
||||
* @group legacy
|
||||
*/
|
||||
public function testFileMimeTypeDetectionDeprecation() {
|
||||
$this->expectDeprecation('The "Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesser" class is deprecated since Symfony 4.3, use "Symfony\Component\Mime\MimeTypes" instead.');
|
||||
$this->expectDeprecation('The "Symfony\Component\HttpFoundation\File\MimeType\FileBinaryMimeTypeGuesser" class is deprecated since Symfony 4.3, use "Symfony\Component\Mime\FileBinaryMimeTypeGuesser" instead.');
|
||||
$this->expectDeprecation('The "Symfony\Component\HttpFoundation\File\MimeType\FileinfoMimeTypeGuesser" class is deprecated since Symfony 4.3, use "Symfony\Component\Mime\FileinfoMimeTypeGuesser" instead.');
|
||||
$this->expectDeprecation('Drupal\Core\File\MimeType\MimeTypeGuesser::guess() is deprecated in drupal:9.1.0 and is removed from drupal:10.0.0. Use ::guessMimeType() instead. See https://www.drupal.org/node/3133341');
|
||||
$guesser = $this->container->get('file.mime_type.guesser');
|
||||
$output = $guesser->guess('public://test.jar');
|
||||
$this->assertSame('application/java-archive', $output);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -74,7 +74,7 @@ class ExceptionHandlingTest extends KernelTestBase {
|
|||
|
||||
$this->assertEquals(Response::HTTP_NOT_FOUND, $response->getStatusCode());
|
||||
$this->assertEquals('application/json', $response->headers->get('Content-type'));
|
||||
$this->assertEquals('{"message":"No route found for \\u0022GET \\/not-found\\u0022"}', $response->getContent());
|
||||
$this->assertEquals('{"message":"No route found for \\u0022GET http:\/\/localhost\\/not-found\\u0022"}', $response->getContent());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -590,7 +590,7 @@ class TypedDataTest extends KernelTestBase {
|
|||
// Test translating violation messages when pluralization is used.
|
||||
$definition = DataDefinition::create('string')
|
||||
->setConstraints([
|
||||
'Length' => ['min' => 10, 'allowEmptyString' => FALSE],
|
||||
'Length' => ['min' => 10],
|
||||
]);
|
||||
$violations = $this->typedDataManager->create($definition, "short")->validate();
|
||||
$this->assertEquals(1, $violations->count());
|
||||
|
|
|
@ -8,7 +8,7 @@ use Symfony\Component\DependencyInjection\Container;
|
|||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
use Symfony\Component\EventDispatcher\Event as SymfonyEvent;
|
||||
use Symfony\Contracts\EventDispatcher\Event as SymfonyEvent;
|
||||
use Symfony\Component\EventDispatcher\GenericEvent;
|
||||
use Drupal\Component\EventDispatcher\Event;
|
||||
use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;
|
||||
|
@ -145,30 +145,6 @@ class ContainerAwareEventDispatcherTest extends TestCase {
|
|||
$this->assertSame($expectedListeners, $actualListeners);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests argument order deprecation.
|
||||
*
|
||||
* @group legacy
|
||||
*/
|
||||
public function testDispatchArgumentOrderDeprecation() {
|
||||
$this->expectDeprecation('Calling the Symfony\Component\EventDispatcher\EventDispatcherInterface::dispatch() method with a string event name as the first argument is deprecated in drupal:9.1.0, an Event object will be required instead in drupal:10.0.0. See https://www.drupal.org/node/3154407');
|
||||
$container = new ContainerBuilder();
|
||||
$dispatcher = new ContainerAwareEventDispatcher($container, []);
|
||||
$dispatcher->dispatch('foo');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests deprecation notice for Symfony Event class.
|
||||
*
|
||||
* @group legacy
|
||||
*/
|
||||
public function testSymfonyEventDeprecation() {
|
||||
$this->expectDeprecation('Symfony\Component\EventDispatcher\Event is deprecated in drupal:9.1.0 and will be replaced by Symfony\Contracts\EventDispatcher\Event in drupal:10.0.0. A new Drupal\Component\EventDispatcher\Event class is available to bridge the two versions of the class. See https://www.drupal.org/node/3159012');
|
||||
$container = new ContainerBuilder();
|
||||
$dispatcher = new ContainerAwareEventDispatcher($container, []);
|
||||
$dispatcher->dispatch(new SymfonyEvent());
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests dispatching Symfony events with core's event dispatcher.
|
||||
*/
|
||||
|
@ -178,18 +154,6 @@ class ContainerAwareEventDispatcherTest extends TestCase {
|
|||
$dispatcher->dispatch(new GenericEvent());
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests deprecation notice for Symfony Event class inheritance.
|
||||
*
|
||||
* @group legacy
|
||||
*/
|
||||
public function testSymfonyInheritedEventDeprecation() {
|
||||
$this->expectDeprecation('Symfony\Component\EventDispatcher\Event is deprecated in drupal:9.1.0 and will be replaced by Symfony\Contracts\EventDispatcher\Event in drupal:10.0.0. A new Drupal\Component\EventDispatcher\Event class is available to bridge the two versions of the class. See https://www.drupal.org/node/3159012');
|
||||
$container = new ContainerBuilder();
|
||||
$dispatcher = new ContainerAwareEventDispatcher($container, []);
|
||||
$dispatcher->dispatch(new SymfonyInheritedEvent());
|
||||
}
|
||||
|
||||
public function testDispatchWithServices() {
|
||||
$container = new ContainerBuilder();
|
||||
$container->register('listener_service', TestEventListener::class);
|
||||
|
|
|
@ -1,68 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\Core\DependencyInjection\Compiler;
|
||||
|
||||
use Drupal\Core\DependencyInjection\Compiler\MimeTypePass;
|
||||
use Drupal\Tests\UnitTestCase;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesserInterface as LegacyMimeTypeGuesserInterface;
|
||||
use Symfony\Component\Mime\MimeTypeGuesserInterface;
|
||||
use Drupal\Core\File\MimeType\MimeTypeGuesser;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass \Drupal\Core\DependencyInjection\Compiler\MimeTypePass
|
||||
* @group DependencyInjection
|
||||
* @group legacy
|
||||
* @runInSeparateProcess
|
||||
*/
|
||||
class MimeTypePassTest extends UnitTestCase {
|
||||
|
||||
protected function buildContainer($environment = 'dev') {
|
||||
$container = new ContainerBuilder();
|
||||
$container->setParameter('kernel.environment', $environment);
|
||||
return $container;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests backwards compatibility shim for MimeTypeGuesser interface changes.
|
||||
*/
|
||||
public function testProcessLegacy() {
|
||||
$this->expectDeprecation('The "Drupal\Tests\Core\DependencyInjection\Compiler\LegacyMimeTypeGuesser" class implements "Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesserInterface" that is deprecated since Symfony 4.3, use {@link MimeTypesInterface} instead.');
|
||||
$container = $this->buildContainer();
|
||||
$container
|
||||
->register('file.mime_type.guesser', MimeTypeGuesser::class);
|
||||
|
||||
$container
|
||||
->register('handler1', __NAMESPACE__ . '\NewMimeTypeGuesser')
|
||||
->addTag('mime_type_guesser', ['priority' => 200]);
|
||||
$container
|
||||
->register('handler2', __NAMESPACE__ . '\LegacyMimeTypeGuesser')
|
||||
->addTag('mime_type_guesser', ['priority' => 100]);
|
||||
|
||||
$handler_pass = new MimeTypePass();
|
||||
$handler_pass->process($container);
|
||||
$method_calls = $container->getDefinition('file.mime_type.guesser')->getMethodCalls();
|
||||
$this->assertCount(2, $method_calls);
|
||||
$this->assertSame(200, $method_calls[0][1][1]);
|
||||
$this->assertSame(100, $method_calls[1][1][1]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class NewMimeTypeGuesser implements MimeTypeGuesserInterface {
|
||||
|
||||
public function guessMimeType(string $string): string {
|
||||
return '';
|
||||
}
|
||||
|
||||
public function isGuesserSupported(): bool {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class LegacyMimeTypeGuesser implements LegacyMimeTypeGuesserInterface {
|
||||
|
||||
public function guess($string) {}
|
||||
|
||||
}
|
|
@ -92,20 +92,6 @@ class ContainerBuilderTest extends UnitTestCase {
|
|||
$this->assertFalse($service->isPublic());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::setDefinition
|
||||
*
|
||||
* @group legacy
|
||||
*/
|
||||
public function testLegacySetDefinition() {
|
||||
// Test a service with public set to default.
|
||||
$container = new ContainerBuilder();
|
||||
$definition = new Definition();
|
||||
$this->expectDeprecation('Not marking service definitions as public is deprecated in drupal:9.2.0 and is required in drupal:10.0.0. Call $definition->setPublic(TRUE) before calling ::setDefinition(). See https://www.drupal.org/node/3194517');
|
||||
$service = $container->setDefinition('foo', $definition);
|
||||
$this->assertTrue($service->isPublic());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::setAlias
|
||||
*/
|
||||
|
|
|
@ -23,7 +23,7 @@ class DrupalKernelLegacyTest extends UnitTestCase {
|
|||
$request = $this->createMock(Request::class);
|
||||
$event = new KernelEvent($kernel, $request, $kernel::MASTER_REQUEST);
|
||||
|
||||
$this->expectDeprecation('Symfony\Component\HttpKernel\Event\KernelEvent::isMasterRequest() is deprecated, use isMainRequest()');
|
||||
$this->expectDeprecation('Since symfony/http-kernel 5.3: "Symfony\Component\HttpKernel\Event\KernelEvent::isMasterRequest()" is deprecated, use "isMainRequest()" instead.');
|
||||
$this->assertTrue($event->isMasterRequest());
|
||||
}
|
||||
|
||||
|
|
|
@ -1,54 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\Core\File;
|
||||
|
||||
use Drupal\Core\DependencyInjection\ContainerBuilder;
|
||||
use Drupal\Core\File\MimeType\MimeTypeGuesser;
|
||||
use Drupal\Core\StreamWrapper\StreamWrapperManager;
|
||||
use Drupal\Tests\UnitTestCase;
|
||||
use Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesser as SymfonyMimeTypeGuesser;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass \Drupal\Core\File\MimeType\MimeTypeGuesser
|
||||
* @group DrupalKernel
|
||||
*/
|
||||
class MimeTypeGuesserTest extends UnitTestCase {
|
||||
|
||||
/**
|
||||
* @covers ::registerWithSymfonyGuesser
|
||||
*
|
||||
* @see Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesser
|
||||
*/
|
||||
public function testSymfonyGuesserRegistration() {
|
||||
// Make the guessers property accessible on Symfony's MimeTypeGuesser.
|
||||
$symfony_guesser = SymfonyMimeTypeGuesser::getInstance();
|
||||
// Test that the Drupal mime type guess is not being used before the
|
||||
// override method is called. It is possible that the test environment does
|
||||
// not support the default guessers.
|
||||
$reflected_guessers = new \ReflectionProperty($symfony_guesser, 'guessers');
|
||||
$reflected_guessers->setAccessible(TRUE);
|
||||
$guessers = $reflected_guessers->getValue($symfony_guesser);
|
||||
if (count($guessers)) {
|
||||
$this->assertNotInstanceOf('Drupal\Core\File\MimeType\MimeTypeGuesser', $guessers[0]);
|
||||
}
|
||||
$container = new ContainerBuilder();
|
||||
$container->set('file.mime_type.guesser', new MimeTypeGuesser(new StreamWrapperManager()));
|
||||
MimeTypeGuesser::registerWithSymfonyGuesser($container);
|
||||
$symfony_guesser = SymfonyMimeTypeGuesser::getInstance();
|
||||
$guessers = $reflected_guessers->getValue($symfony_guesser);
|
||||
$this->assertSame($container->get('file.mime_type.guesser'), $guessers[0]);
|
||||
$this->assertInstanceOf('Drupal\Core\File\MimeType\MimeTypeGuesser', $guessers[0]);
|
||||
$count = count($guessers);
|
||||
|
||||
$container = new ContainerBuilder();
|
||||
$container->set('file.mime_type.guesser', new MimeTypeGuesser(new StreamWrapperManager()));
|
||||
MimeTypeGuesser::registerWithSymfonyGuesser($container);
|
||||
$symfony_guesser = SymfonyMimeTypeGuesser::getInstance();
|
||||
$guessers = $reflected_guessers->getValue($symfony_guesser);
|
||||
$this->assertSame($container->get('file.mime_type.guesser'), $guessers[0]);
|
||||
$this->assertInstanceOf('Drupal\Core\File\MimeType\MimeTypeGuesser', $guessers[0]);
|
||||
$new_count = count($guessers);
|
||||
$this->assertEquals($count, $new_count, 'The count of mime type guessers remains the same after container re-init.');
|
||||
}
|
||||
|
||||
}
|
|
@ -4,7 +4,6 @@ namespace Drupal\Tests\Core\Http;
|
|||
|
||||
use Drupal\Core\Http\InputBag;
|
||||
use Drupal\Tests\UnitTestCase;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass \Drupal\Core\Http\InputBag
|
||||
|
@ -29,13 +28,4 @@ class InputBagTest extends UnitTestCase {
|
|||
$input_bag->all('bad');
|
||||
}
|
||||
|
||||
/**
|
||||
* @coversNothing
|
||||
* @todo Remove this when Symfony 4 is no longer supported.
|
||||
*/
|
||||
public function testRequestFactory() {
|
||||
$request = Request::create('');
|
||||
$this->assertInstanceOf(InputBag::class, $request->query);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -69,7 +69,6 @@ trait DeprecationListenerTrait {
|
|||
return TRUE;
|
||||
}
|
||||
$dynamic_skipped_deprecations = [
|
||||
'%The "[^"]+" class extends "Symfony\\\\Component\\\\EventDispatcher\\\\Event" that is deprecated since Symfony 4\.3, use "Symfony\\\\Contracts\\\\EventDispatcher\\\\Event" instead\.$%',
|
||||
'%The "Symfony\\\\Component\\\\Validator\\\\Context\\\\ExecutionContextInterface::.*\(\)" method is considered internal Used by the validator engine\. Should not be called by user\W+code\. It may change without further notice\. You should not extend it from "[^"]+".%',
|
||||
'%The "PHPUnit\\\\Framework\\\\TestCase::addWarning\(\)" method is considered internal%',
|
||||
// The following deprecations were not added as part of the original
|
||||
|
@ -84,8 +83,6 @@ trait DeprecationListenerTrait {
|
|||
// Skip DebugClassLoader false positives.
|
||||
'%Method "[^"]+" might add "[^"]+" as a native return type declaration in the future. Do the same in (child class|implementation) "(?!Drupal\\\\)[^"]+" now to avoid errors or add an explicit @return annotation to suppress this message%',
|
||||
'%The "Drupal\\\\[^"]+" method will require a new "[^"]+" argument in the next major version of its interface "Drupal\\\\[^"]+", not defining it is deprecated%',
|
||||
// Symfony 5.4
|
||||
'%Method "Symfony\\\\Component\\\\Serializer\\\\Normalizer\\\\NormalizerInterface::normalize\(\)" might add "array\|string\|int\|float\|bool\|\\\\ArrayObject\|null" as a native return type declaration in the future. Do the same in implementation "(?!Drupal\\\\)[^"]+" now to avoid errors or add an explicit @return annotation to suppress this message.%',
|
||||
];
|
||||
return (bool) preg_filter($dynamic_skipped_deprecations, '$0', $message);
|
||||
}
|
||||
|
@ -111,16 +108,6 @@ trait DeprecationListenerTrait {
|
|||
// The following deprecation messages are skipped for testing purposes.
|
||||
'\Drupal\Tests\SkippedDeprecationTest deprecation',
|
||||
'Return type of PhpDeprecation::getIterator() should either be compatible with IteratorAggregate::getIterator(): Traversable, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice',
|
||||
// The following Symfony deprecations are introduced in the Symfony 4
|
||||
// development cycle. They will need to be resolved prior to Symfony 5
|
||||
// compatibility.
|
||||
'The "Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesser" class is deprecated since Symfony 4.3, use "Symfony\Component\Mime\MimeTypes" instead.',
|
||||
'The "Drupal\Core\File\MimeType\MimeTypeGuesser" class implements "Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesserInterface" that is deprecated since Symfony 4.3, use {@link MimeTypesInterface} instead.',
|
||||
'The "Symfony\Component\HttpFoundation\File\MimeType\FileBinaryMimeTypeGuesser" class is deprecated since Symfony 4.3, use "Symfony\Component\Mime\FileBinaryMimeTypeGuesser" instead.',
|
||||
'The "Symfony\Component\HttpFoundation\File\MimeType\FileinfoMimeTypeGuesser" class is deprecated since Symfony 4.3, use "Symfony\Component\Mime\FileinfoMimeTypeGuesser" instead.',
|
||||
'The "Drupal\Tests\Core\DependencyInjection\Compiler\LegacyMimeTypeGuesser" class implements "Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesserInterface" that is deprecated since Symfony 4.3, use {@link MimeTypesInterface} instead.',
|
||||
'The "Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher::dispatch()" method will require a new "string|null $eventName" argument in the next major version of its interface "Symfony\Contracts\EventDispatcher\EventDispatcherInterface", not defining it is deprecated.',
|
||||
'The "Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher::dispatch()" method will require a new "string|null $eventName" argument in the next major version of its parent class "Symfony\Contracts\EventDispatcher\EventDispatcherInterface", not defining it is deprecated.',
|
||||
// The following deprecation is listed for Twig 2 compatibility when unit
|
||||
// testing using \Symfony\Component\ErrorHandler\DebugClassLoader.
|
||||
'The "Twig\Environment::getTemplateClass()" method is considered internal. It may change without further notice. You should not extend it from "Drupal\Core\Template\TwigEnvironment".',
|
||||
|
|
Loading…
Reference in New Issue