Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[HttpKernel] remove deprecated features #22886

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion 10 src/Symfony/Component/HttpKernel/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,22 @@ CHANGELOG
4.0.0
-----

* removed the `DataCollector::varToString()` method, use `DataCollector::cloneVar()`
instead
* using the `DataCollector::cloneVar()` method requires the VarDumper component
* removed the `ValueExporter` class
* removed `ControllerResolverInterface::getArguments()`
* removed `TraceableControllerResolver::getArguments()`
* removed `ControllerResolver::getArguments()` and the ability to resolve arguments
* removed the `argument_resolver` service dependency from the `debug.controller_resolver`
* removed `LazyLoadingFragmentHandler::addRendererService()`
* removed `Psr6CacheClearer::addPool()`
* removed `Extension::addClassesToCompile()` and `Extension::getClassesToCompile()`
* removed `Kernel::loadClassCache()`, `Kernel::doLoadClassCache()` and `Kernel::setClassCache()`
* removed `Kernel::loadClassCache()`, `Kernel::doLoadClassCache()`, `Kernel::setClassCache()`,
and `Kernel::getEnvParameters()`
* support for the `X-Status-Code` when handling exceptions in the `HttpKernel`
has been dropped, use the `HttpKernel::allowCustomResponseCode()` method
instead

3.3.0
-----
Expand Down
42 changes: 4 additions & 38 deletions 42 src/Symfony/Component/HttpKernel/DataCollector/DataCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

namespace Symfony\Component\HttpKernel\DataCollector;

use Symfony\Component\HttpKernel\DataCollector\Util\ValueExporter;
use Symfony\Component\VarDumper\Caster\ClassStub;
use Symfony\Component\VarDumper\Cloner\ClonerInterface;
use Symfony\Component\VarDumper\Cloner\Data;
Expand All @@ -29,11 +28,6 @@ abstract class DataCollector implements DataCollectorInterface, \Serializable
{
protected $data = array();

/**
* @var ValueExporter
*/
private $valueExporter;

/**
* @var ClonerInterface
*/
Expand Down Expand Up @@ -62,42 +56,14 @@ public function unserialize($data)
protected function cloneVar($var)
{
if (null === self::$cloner) {
if (class_exists(ClassStub::class)) {
self::$cloner = new VarCloner();
self::$cloner->setMaxItems(-1);
} else {
@trigger_error(sprintf('Using the %s() method without the VarDumper component is deprecated since version 3.2 and won\'t be supported in 4.0. Install symfony/var-dumper version 3.2 or above.', __METHOD__), E_USER_DEPRECATED);
self::$cloner = false;
}
}
if (false === self::$cloner) {
if (null === $this->valueExporter) {
$this->valueExporter = new ValueExporter();
if (!class_exists(ClassStub::class)) {
throw new \LogicException(sprintf('The VarDumper component is needed for the %s() method. Install symfony/var-dumper version 3.2 or above.', __METHOD__));
}

return $this->valueExporter->exportValue($var);
self::$cloner = new VarCloner();
self::$cloner->setMaxItems(-1);
}

return self::$cloner->cloneVar($var);
}

/**
* Converts a PHP variable to a string.
*
* @param mixed $var A PHP variable
*
* @return string The string representation of the variable
*
* @deprecated since version 3.2, to be removed in 4.0. Use cloneVar() instead.
*/
protected function varToString($var)
{
@trigger_error(sprintf('The %s() method is deprecated since version 3.2 and will be removed in 4.0. Use cloneVar() instead.', __METHOD__), E_USER_DEPRECATED);

if (null === $this->valueExporter) {
$this->valueExporter = new ValueExporter();
}

return $this->valueExporter->exportValue($var);
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function render($uri, Request $request, array $options = array())
{
if (!$this->surrogate || !$this->surrogate->hasSurrogateCapability($request)) {
if ($uri instanceof ControllerReference && $this->containsNonScalars($uri->attributes)) {
@trigger_error('Passing non-scalar values as part of URI attributes to the ESI and SSI rendering strategies is deprecated since version 3.1, and will be removed in 4.0. Use a different rendering strategy or pass scalar values.', E_USER_DEPRECATED);
throw new \InvalidArgumentException('Passing non-scalar values as part of URI attributes to the ESI and SSI rendering strategies is not supported. Use a different rendering strategy or pass scalar values.');
}

return $this->inlineStrategy->render($uri, $request, $options);
Expand Down
8 changes: 1 addition & 7 deletions 8 src/Symfony/Component/HttpKernel/HttpKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -239,13 +239,7 @@ private function handleException(\Exception $e, $request, $type)
$response = $event->getResponse();

// the developer asked for a specific status code
if ($response->headers->has('X-Status-Code')) {
@trigger_error(sprintf('Using the X-Status-Code header is deprecated since version 3.3 and will be removed in 4.0. Use %s::allowCustomResponseCode() instead.', GetResponseForExceptionEvent::class), E_USER_DEPRECATED);

$response->setStatusCode($response->headers->get('X-Status-Code'));

$response->headers->remove('X-Status-Code');
} elseif (!$event->isAllowingCustomResponseCode() && !$response->isClientError() && !$response->isServerError() && !$response->isRedirect()) {
if (!$event->isAllowingCustomResponseCode() && !$response->isClientError() && !$response->isServerError() && !$response->isRedirect()) {
// ensure that we actually have an error response
if ($e instanceof HttpExceptionInterface) {
// keep the HTTP status code and headers
Expand Down
53 changes: 12 additions & 41 deletions 53 src/Symfony/Component/HttpKernel/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -544,50 +544,21 @@ protected function getKernelParameters()
);
}

return array_merge(
array(
'kernel.root_dir' => realpath($this->rootDir) ?: $this->rootDir,
'kernel.project_dir' => realpath($this->projectDir) ?: $this->projectDir,
'kernel.environment' => $this->environment,
'kernel.debug' => $this->debug,
'kernel.name' => $this->name,
'kernel.cache_dir' => realpath($this->getCacheDir()) ?: $this->getCacheDir(),
'kernel.logs_dir' => realpath($this->getLogDir()) ?: $this->getLogDir(),
'kernel.bundles' => $bundles,
'kernel.bundles_metadata' => $bundlesMetadata,
'kernel.charset' => $this->getCharset(),
'kernel.container_class' => $this->getContainerClass(),
),
$this->getEnvParameters(false)
return array(
'kernel.root_dir' => realpath($this->rootDir) ?: $this->rootDir,
'kernel.project_dir' => realpath($this->projectDir) ?: $this->projectDir,
'kernel.environment' => $this->environment,
'kernel.debug' => $this->debug,
'kernel.name' => $this->name,
'kernel.cache_dir' => realpath($this->getCacheDir()) ?: $this->getCacheDir(),
'kernel.logs_dir' => realpath($this->getLogDir()) ?: $this->getLogDir(),
'kernel.bundles' => $bundles,
'kernel.bundles_metadata' => $bundlesMetadata,
'kernel.charset' => $this->getCharset(),
'kernel.container_class' => $this->getContainerClass(),
);
}

/**
* Gets the environment parameters.
*
* Only the parameters starting with "SYMFONY__" are considered.
*
* @return array An array of parameters
*
* @deprecated since version 3.3, to be removed in 4.0
*/
protected function getEnvParameters()
{
if (0 === func_num_args() || func_get_arg(0)) {
@trigger_error(sprintf('The %s() method is deprecated as of 3.3 and will be removed in 4.0. Use the %%env()%% syntax to get the value of any environment variable from configuration files instead.', __METHOD__), E_USER_DEPRECATED);
}

$parameters = array();
foreach ($_SERVER as $key => $value) {
if (0 === strpos($key, 'SYMFONY__')) {
@trigger_error(sprintf('The support of special environment variables that start with SYMFONY__ (such as "%s") is deprecated as of 3.3 and will be removed in 4.0. Use the %%env()%% syntax instead to get the value of environment variables in configuration files.', $key), E_USER_DEPRECATED);
$parameters[strtolower(str_replace('__', '.', substr($key, 9)))] = $value;
}
}

return $parameters;
}

/**
* Builds the service container.
*
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,6 @@ public function testRenderFallbackToInlineStrategyIfEsiNotSupported()
$strategy->render('/', Request::create('/'));
}

/**
* @group legacy
* @expectedDeprecation Passing non-scalar values as part of URI attributes to the ESI and SSI rendering strategies is deprecated %s.
*/
public function testRenderFallbackWithObjectAttributesIsDeprecated()
{
$strategy = new EsiFragmentRenderer(new Esi(), $this->getInlineStrategy(true), new UriSigner('foo'));
$request = Request::create('/');
$reference = new ControllerReference('main_controller', array('foo' => array('a' => array(), 'b' => new \stdClass())), array());
$strategy->render($reference, $request);
}

public function testRender()
{
$strategy = new EsiFragmentRenderer(new Esi(), $this->getInlineStrategy());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@

use PHPUnit\Framework\TestCase;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpKernel\Controller\ArgumentResolver;
use Symfony\Component\HttpKernel\Controller\ControllerResolverInterface;
use Symfony\Component\HttpKernel\Controller\ControllerReference;
use Symfony\Component\HttpKernel\HttpKernel;
use Symfony\Component\HttpKernel\Fragment\InlineFragmentRenderer;
Expand Down Expand Up @@ -53,27 +51,6 @@ public function testRenderWithObjectsAsAttributes()
$this->assertSame('foo', $strategy->render(new ControllerReference('main_controller', array('object' => $object), array()), Request::create('/'))->getContent());
}

/**
* @group legacy
*/
public function testRenderWithObjectsAsAttributesPassedAsObjectsInTheController()
{
$resolver = $this->getMockBuilder(ControllerResolverInterface::class)->getMock();
$resolver
->expects($this->once())
->method('getController')
->will($this->returnValue(function (\stdClass $object, Bar $object1) {
return new Response($object1->getBar());
}))
;

$kernel = new HttpKernel(new EventDispatcher(), $resolver, new RequestStack(), new ArgumentResolver());
$renderer = new InlineFragmentRenderer($kernel);

$response = $renderer->render(new ControllerReference('main_controller', array('object' => new \stdClass(), 'object1' => new Bar()), array()), Request::create('/'));
$this->assertEquals('bar', $response->getContent());
}

public function testRenderWithTrustedHeaderDisabled()
{
Request::setTrustedProxies(array(), 0);
Expand Down
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.