Skip to content

Commit f539019

Browse files
committed
Fix Request::get() removal in Symfony 8 and bump Latest fixture
dd-trace-php is using `Request::get()` in multiple locations, but that method has been removed in Symfony 8.0: symfony/http-foundation@e7e0520 This commit fixes the issue, and extends the Symfony testsuite to cover Symfony 8.0.
1 parent d82f834 commit f539019

19 files changed

Lines changed: 694 additions & 565 deletions

src/DDTrace/Integrations/Symfony/SymfonyIntegration.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ static function() {
432432

433433
// Try with locale suffix (Symfony i18n routing convention)
434434
if ($path === null) {
435-
$locale = $request->get('_locale');
435+
$locale = $request->attributes->get('_locale');
436436
if ($locale !== null) {
437437
$path = EndpointCatalog::pathForRoute($route_name . '.' . $locale, $container);
438438
}
@@ -471,7 +471,7 @@ static function(SpanData $span, $args, $response) use ($handle_http_route) {
471471
$rootSpan->meta[Tag::HTTP_STATUS_CODE] = $response->getStatusCode();
472472
}
473473

474-
$route_name = $request->get('_route');
474+
$route_name = $request->attributes->get('_route');
475475
if ($route_name !== null) {
476476
if (dd_trace_env_config("DD_HTTP_SERVER_ROUTE_BASED_NAMING")) {
477477
$rootSpan->resource = $route_name;
@@ -480,7 +480,7 @@ static function(SpanData $span, $args, $response) use ($handle_http_route) {
480480
$handle_http_route($route_name, $request, $rootSpan);
481481
}
482482

483-
$parameters = $request->get('_route_params');
483+
$parameters = $request->attributes->get('_route_params');
484484
if (!empty($parameters) &&
485485
is_array($parameters) &&
486486
function_exists('datadog\appsec\push_addresses')) {

tests/Frameworks/Symfony/Latest/composer.json

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,23 @@
44
"minimum-stability": "stable",
55
"prefer-stable": true,
66
"require": {
7-
"php": ">=8.2",
7+
"php": "^8.4",
88
"ext-ctype": "*",
99
"ext-iconv": "*",
10-
"doctrine/annotations": "^2.0",
11-
"doctrine/dbal": "3.10.1",
12-
"doctrine/doctrine-bundle": "^2.11",
13-
"doctrine/doctrine-migrations-bundle": "^3.3",
14-
"doctrine/orm": "^2.17",
10+
"doctrine/dbal": "^4.3",
11+
"doctrine/doctrine-bundle": "^3.0",
12+
"doctrine/doctrine-migrations-bundle": "^4.0",
13+
"doctrine/orm": "^3.0",
1514
"phpdocumentor/reflection-docblock": "^5.6",
1615
"phpstan/phpdoc-parser": "^2.0",
17-
"symfony/console": "7.3.4",
18-
"symfony/doctrine-messenger": "^7.1",
16+
"symfony/console": "8.0.*",
17+
"symfony/doctrine-messenger": "^8.0",
1918
"symfony/dotenv": "*",
20-
"symfony/event-dispatcher": "7.3.*",
19+
"symfony/event-dispatcher": "8.0.*",
2120
"symfony/flex": "^2",
2221
"symfony/form": "*",
23-
"symfony/framework-bundle": "7.3.4",
24-
"symfony/messenger": "7.3.3",
25-
"symfony/monolog-bundle": "^3.10",
22+
"symfony/framework-bundle": "8.0.*",
23+
"symfony/messenger": "8.0.*",
2624
"symfony/property-access": "*",
2725
"symfony/property-info": "*",
2826
"symfony/runtime": "*",
@@ -31,6 +29,7 @@
3129
"symfony/twig-bundle": "*",
3230
"symfony/validator": "*",
3331
"symfony/yaml": "*",
32+
"symfony/monolog-bundle": "^4.0",
3433
"symfonycasts/verify-email-bundle": "^1.16"
3534
},
3635
"config": {
@@ -89,7 +88,7 @@
8988
"extra": {
9089
"symfony": {
9190
"allow-contrib": false,
92-
"require": "7.*"
91+
"require": "8.*"
9392
}
9493
},
9594
"require-dev": {
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Enable stateless CSRF protection for forms and logins/logouts
2+
framework:
3+
form:
4+
csrf_protection:
5+
token_id: submit
6+
7+
csrf_protection:
8+
stateless_token_ids:
9+
- submit
10+
- authenticate
11+
- logout

tests/Frameworks/Symfony/Latest/config/packages/doctrine.yaml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@ doctrine:
88

99
profiling_collect_backtrace: '%kernel.debug%'
1010
orm:
11-
auto_generate_proxy_classes: true
12-
enable_lazy_ghost_objects: true
13-
report_fields_where_declared: true
1411
validate_xml_mapping: true
1512
naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware
1613
auto_mapping: true
@@ -31,8 +28,6 @@ when@test:
3128
when@prod:
3229
doctrine:
3330
orm:
34-
auto_generate_proxy_classes: false
35-
proxy_dir: '%kernel.build_dir%/doctrine/orm/Proxies'
3631
query_cache_driver:
3732
type: pool
3833
pool: doctrine.system_cache_pool
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
framework:
2+
property_info:
3+
with_constructor_extractor: true
Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1 @@
1-
when@dev:
2-
_errors:
3-
resource: '@FrameworkBundle/Resources/config/routing/errors.xml'
4-
prefix: /_error
1+
# Error routing is registered automatically by FrameworkBundle in Symfony 8+

tests/Frameworks/Symfony/Latest/src/Controller/CommonScenariosController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
66
use Symfony\Component\HttpFoundation\Request;
77
use Symfony\Component\HttpFoundation\Response;
8-
use Symfony\Component\Routing\Annotation\Route;
8+
use Symfony\Component\Routing\Attribute\Route;
99

1010
class CommonScenariosController extends AbstractController
1111
{

tests/Frameworks/Symfony/Latest/src/Controller/LoginController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
66
use Symfony\Component\HttpFoundation\Response;
7-
use Symfony\Component\Routing\Annotation\Route;
7+
use Symfony\Component\Routing\Attribute\Route;
88
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
99
use Psr\Log\LoggerInterface;
1010

tests/Frameworks/Symfony/Latest/src/Controller/LuckyController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use App\Message\LuckyNumberNotification;
66
use Symfony\Component\HttpFoundation\Response;
77
use Symfony\Component\Messenger\MessageBusInterface;
8-
use Symfony\Component\Routing\Annotation\Route;
8+
use Symfony\Component\Routing\Attribute\Route;
99

1010
class LuckyController
1111
{

tests/Frameworks/Symfony/Latest/src/Controller/RegistrationController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
use Symfony\Component\HttpFoundation\Request;
1212
use Symfony\Component\HttpFoundation\Response;
1313
use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface;
14-
use Symfony\Component\Routing\Annotation\Route;
14+
use Symfony\Component\Routing\Attribute\Route;
1515

1616
class RegistrationController extends AbstractController
1717
{

0 commit comments

Comments
 (0)