diff --git a/CHANGELOG.md b/CHANGELOG.md
index cd418619..fd0d7410 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,6 +7,10 @@ The change log describes what is "Added", "Removed", "Changed" or "Fixed" betwee
# 2.0.0 - (unreleased)
- Increased min PHP version to 8.1
+- Removed the deprecated `httplug_markup` twig filter. Use `@Httplug/http_message.html.twig` template instead.
+- Removed deprecated configuration options:
+ - `toolbar`: Use `profiling` instead.
+ - `respect_cache_headers`: Use `respect_response_cache_directives` instead.
- Removed the deprecated `Http\HttplugBundle\ClientFactory\PluginClientFactory`. Use `Http\Client\Common\PluginClientFactory` instead.
- Fixed a deprecation when creating a `HttpMethodsClient` via `http_methods_client: true`. Only PSR-17 factories are now passed as constructor arguments.
- Changed the default stream factory argument for the cache plugin. This now requires a PSR-17 StreamFactoryInterface instance.
diff --git a/src/Collector/Twig/HttpMessageMarkupExtension.php b/src/Collector/Twig/HttpMessageMarkupExtension.php
index 10bcf417..83c48a2f 100644
--- a/src/Collector/Twig/HttpMessageMarkupExtension.php
+++ b/src/Collector/Twig/HttpMessageMarkupExtension.php
@@ -32,42 +32,17 @@ public function __construct(?ClonerInterface $cloner = null, ?DataDumperInterfac
public function getFilters(): array
{
return [
- new TwigFilter('httplug_markup', $this->markup(...), ['is_safe' => ['html']]),
new TwigFilter('httplug_markup_body', $this->markupBody(...), ['is_safe' => ['html']]),
];
}
- /**
- * @param string $message http message
- */
- public function markup($message)
- {
- @trigger_error('"httplug_markup" twig extension is deprecated since version 1.17 and will be removed in 2.0. Use "@Httplug/http_message.html.twig" template instead.', E_USER_DEPRECATED);
-
- $safeMessage = htmlentities($message);
- $parts = preg_split('|\\r?\\n\\r?\\n|', $safeMessage, 2);
-
- if (!isset($parts[1])) {
- // This is not a HTTP message
- return $safeMessage;
- }
-
- if (empty($parts[1])) {
- $parts[1] = '(This message has no captured body)';
- }
-
- // make header names bold
- $headers = preg_replace("|\n(.*?): |si", "\n$1: ", $parts[0]);
-
- return sprintf("%s\n\n
%s
", $headers, $parts[1]);
- }
-
public function markupBody(string $body): ?string
{
- if (in_array(substr($body, 0, 1), ['{', '['], true)) {
- $json = json_decode($body, true);
- if (JSON_ERROR_NONE === json_last_error()) {
- $body = $json;
+ if ('' !== $body && in_array($body[0], ['{', '['], true)) {
+ try {
+ $body = json_decode($body, true, 512, JSON_THROW_ON_ERROR);
+ } catch (\JsonException) {
+ // ignore
}
}
diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php
index a27de5a1..8456049c 100644
--- a/src/DependencyInjection/Configuration.php
+++ b/src/DependencyInjection/Configuration.php
@@ -73,27 +73,6 @@ public function getConfigTreeBuilder(): TreeBuilder
return $v;
})
->end()
- ->beforeNormalization()
- ->ifTrue(fn ($v) => is_array($v) && array_key_exists('toolbar', $v) && is_array($v['toolbar']))
- ->then(function ($v) {
- if (array_key_exists('profiling', $v)) {
- throw new InvalidConfigurationException('Can\'t configure both "toolbar" and "profiling" section. The "toolbar" config is deprecated as of version 1.3.0, please only use "profiling".');
- }
-
- @trigger_error('"httplug.toolbar" config is deprecated since version 1.3 and will be removed in 2.0. Use "httplug.profiling" instead.', E_USER_DEPRECATED);
-
- if (array_key_exists('enabled', $v['toolbar']) && 'auto' === $v['toolbar']['enabled']) {
- @trigger_error('"auto" value in "httplug.toolbar" config is deprecated since version 1.3 and will be removed in 2.0. Use a boolean value instead.', E_USER_DEPRECATED);
- $v['toolbar']['enabled'] = $this->debug;
- }
-
- $v['profiling'] = $v['toolbar'];
-
- unset($v['toolbar']);
-
- return $v;
- })
- ->end()
->fixXmlConfig('client')
->children()
->booleanNode('default_client_autowiring')
@@ -718,12 +697,6 @@ private function createCachePluginNode(): NodeDefinition
->fixXmlConfig('respect_response_cache_directive')
->fixXmlConfig('cache_listener')
->addDefaultsIfNotSet()
- ->validate()
- ->ifTrue(fn ($config) =>
- // Cannot set both respect_cache_headers and respect_response_cache_directives
- isset($config['respect_cache_headers'], $config['respect_response_cache_directives']))
- ->thenInvalid('You can\'t provide config option "respect_cache_headers" and "respect_response_cache_directives" simultaneously. Use "respect_response_cache_directives" instead.')
- ->end()
->children()
->scalarNode('cache_key_generator')
->info('This must be a service id to a service implementing '.CacheKeyGenerator::class)
@@ -778,20 +751,6 @@ private function createCachePluginNode(): NodeDefinition
->prototype('scalar')
->end()
->end()
- ->scalarNode('respect_cache_headers')
- ->info('Whether we should care about cache headers or not [DEPRECATED]')
- ->beforeNormalization()
- ->always(function ($v) {
- @trigger_error('The option "respect_cache_headers" is deprecated since version 1.3 and will be removed in 2.0. Use "respect_response_cache_directives" instead.', E_USER_DEPRECATED);
-
- return $v;
- })
- ->end()
- ->validate()
- ->ifNotInArray([null, true, false])
- ->thenInvalid('Value for "respect_cache_headers" must be null or boolean')
- ->end()
- ->end()
->variableNode('respect_response_cache_directives')
->info('A list of cache directives to respect when caching responses. Omit or set to null to respect the default set of directives.')
->validate()
diff --git a/tests/Resources/Fixtures/config/bc/cache_config.yml b/tests/Resources/Fixtures/config/bc/cache_config.yml
deleted file mode 100644
index f6d7b4a6..00000000
--- a/tests/Resources/Fixtures/config/bc/cache_config.yml
+++ /dev/null
@@ -1,6 +0,0 @@
-httplug:
- plugins:
- cache:
- cache_pool: my_cache_pool
- config:
- respect_cache_headers: true
diff --git a/tests/Resources/Fixtures/config/bc/issue-166.yml b/tests/Resources/Fixtures/config/bc/issue-166.yml
deleted file mode 100644
index ca9d0dff..00000000
--- a/tests/Resources/Fixtures/config/bc/issue-166.yml
+++ /dev/null
@@ -1,6 +0,0 @@
-httplug:
- plugins:
- cache:
- cache_pool: my_cache_pool
- config:
- respect_cache_headers: false
diff --git a/tests/Resources/Fixtures/config/bc/profiling_toolbar.yml b/tests/Resources/Fixtures/config/bc/profiling_toolbar.yml
deleted file mode 100644
index 079e6ade..00000000
--- a/tests/Resources/Fixtures/config/bc/profiling_toolbar.yml
+++ /dev/null
@@ -1,4 +0,0 @@
-httplug:
- profiling: ~
- toolbar:
- enabled: auto
diff --git a/tests/Resources/Fixtures/config/bc/toolbar.yml b/tests/Resources/Fixtures/config/bc/toolbar.yml
deleted file mode 100644
index 380413de..00000000
--- a/tests/Resources/Fixtures/config/bc/toolbar.yml
+++ /dev/null
@@ -1,5 +0,0 @@
-httplug:
- toolbar:
- enabled: true
- formatter: null
- captured_body_length: 0
diff --git a/tests/Resources/Fixtures/config/bc/toolbar_auto.yml b/tests/Resources/Fixtures/config/bc/toolbar_auto.yml
deleted file mode 100644
index 75ba9668..00000000
--- a/tests/Resources/Fixtures/config/bc/toolbar_auto.yml
+++ /dev/null
@@ -1,3 +0,0 @@
-httplug:
- toolbar:
- enabled: auto
diff --git a/tests/Resources/Fixtures/config/invalid_cache_config.yml b/tests/Resources/Fixtures/config/invalid_cache_config.yml
deleted file mode 100644
index 4c94f331..00000000
--- a/tests/Resources/Fixtures/config/invalid_cache_config.yml
+++ /dev/null
@@ -1,9 +0,0 @@
-httplug:
- plugins:
- cache:
- cache_pool: my_cache_pool
- config:
- respect_cache_headers: true
- respect_response_cache_directives:
- - X-Foo
- - X-Bar
diff --git a/tests/Unit/DependencyInjection/ConfigurationTest.php b/tests/Unit/DependencyInjection/ConfigurationTest.php
index a375ed1f..b7654501 100644
--- a/tests/Unit/DependencyInjection/ConfigurationTest.php
+++ b/tests/Unit/DependencyInjection/ConfigurationTest.php
@@ -350,82 +350,6 @@ public function testInvalidAuthentication(): void
$this->assertProcessedConfigurationEquals([], [$file]);
}
- /**
- * @group legacy
- */
- public function testInvalidCacheConfig(): void
- {
- $file = __DIR__.'/../../Resources/Fixtures/config/invalid_cache_config.yml';
-
- $this->expectException(InvalidConfigurationException::class);
- $this->expectExceptionMessage('Invalid configuration for path "httplug.plugins.cache.config": You can\'t provide config option "respect_cache_headers" and "respect_response_cache_directives" simultaneously. Use "respect_response_cache_directives" instead.');
- $this->assertProcessedConfigurationEquals([], [$file]);
- }
-
- /**
- * @group legacy
- */
- public function testBackwardCompatibility(): void
- {
- $formats = array_map(fn ($path) => __DIR__.'/../../Resources/Fixtures/'.$path, [
- 'config/bc/toolbar.yml',
- 'config/bc/toolbar_auto.yml',
- ]);
-
- foreach ($formats as $format) {
- $this->assertProcessedConfigurationEquals($this->emptyConfig, [$format]);
- }
- }
-
- /**
- * @group legacy
- */
- public function testCacheConfigDeprecationCompatibility(): void
- {
- $file = __DIR__.'/../../Resources/Fixtures/config/bc/cache_config.yml';
- $config = $this->emptyConfig;
- $config['plugins']['cache'] = array_merge($config['plugins']['cache'], [
- 'enabled' => true,
- 'cache_pool' => 'my_cache_pool',
- 'config' => [
- 'methods' => ['GET', 'HEAD'],
- 'respect_cache_headers' => true,
- 'blacklisted_paths' => [],
- 'cache_listeners' => [],
- ],
- ]);
- $this->assertProcessedConfigurationEquals($config, [$file]);
- }
-
- /**
- * @group legacy
- */
- public function testCacheConfigDeprecationCompatibilityIssue166(): void
- {
- $file = __DIR__.'/../../Resources/Fixtures/config/bc/issue-166.yml';
- $config = $this->emptyConfig;
- $config['plugins']['cache'] = array_merge($config['plugins']['cache'], [
- 'enabled' => true,
- 'cache_pool' => 'my_cache_pool',
- 'config' => [
- 'methods' => ['GET', 'HEAD'],
- 'respect_cache_headers' => false,
- 'blacklisted_paths' => [],
- 'cache_listeners' => [],
- ],
- ]);
- $this->assertProcessedConfigurationEquals($config, [$file]);
- }
-
- public function testProfilingToolbarCollision(): void
- {
- $file = __DIR__.'/../../Resources/Fixtures/config/bc/profiling_toolbar.yml';
-
- $this->expectException(InvalidConfigurationException::class);
- $this->expectExceptionMessage('Can\'t configure both "toolbar" and "profiling" section. The "toolbar" config is deprecated as of version 1.3.0, please only use "profiling".');
- $this->assertProcessedConfigurationEquals([], [$file]);
- }
-
public function testClientCacheConfigMustHavePool(): void
{
$file = __DIR__.'/../../Resources/Fixtures/config/client_cache_config_with_no_pool.yml';
diff --git a/tests/Unit/DependencyInjection/HttplugExtensionTest.php b/tests/Unit/DependencyInjection/HttplugExtensionTest.php
index 539dc879..8e105771 100644
--- a/tests/Unit/DependencyInjection/HttplugExtensionTest.php
+++ b/tests/Unit/DependencyInjection/HttplugExtensionTest.php
@@ -6,7 +6,6 @@
use Http\Adapter\Guzzle7\Client;
use Http\Client\Plugin\Vcr\Recorder\InMemoryRecorder;
-use Http\HttplugBundle\Collector\PluginClientFactoryListener;
use Http\HttplugBundle\DependencyInjection\HttplugExtension;
use Matthias\SymfonyDependencyInjectionTest\PhpUnit\AbstractExtensionTestCase;
use Psr\Http\Client\ClientInterface;
@@ -204,28 +203,6 @@ public function testClientPlugins(): void
$this->assertContainerBuilderHasService('httplug.client.mock');
}
- /**
- * @group legacy
- */
- public function testNoProfilingWhenToolbarIsDisabled(): void
- {
- $this->load(
- [
- 'toolbar' => [
- 'enabled' => false,
- ],
- 'clients' => [
- 'acme' => [
- 'factory' => 'httplug.factory.curl',
- 'plugins' => ['foo'],
- ],
- ],
- ]
- );
-
- $this->verifyProfilingDisabled();
- }
-
public function testNoProfilingWhenNotInDebugMode(): void
{
$this->setParameter('kernel.debug', false);
@@ -243,29 +220,6 @@ public function testNoProfilingWhenNotInDebugMode(): void
$this->verifyProfilingDisabled();
}
- /**
- * @group legacy
- */
- public function testProfilingWhenToolbarIsSpecificallyOn(): void
- {
- $this->setParameter('kernel.debug', false);
- $this->load(
- [
- 'toolbar' => [
- 'enabled' => true,
- ],
- 'clients' => [
- 'acme' => [
- 'factory' => 'httplug.factory.curl',
- 'plugins' => ['foo'],
- ],
- ],
- ]
- );
-
- $this->assertContainerBuilderHasService(PluginClientFactoryListener::class);
- }
-
public function testOverrideProfilingFormatter(): void
{
$this->load(