Skip to content

Do not set $_SERVER['HTTP_ACCEPT'] variable #6489

@Chi-teck

Description

@Chi-teck

Describe the bug
Symfony Var Dumper now relies on this variable to resolve appropriate dumper when format is not specified explicitly.

symfony/symfony#58070

To Reproduce
Dump a variable in Drush command on Drupal 8.3 site.

Expected behavior
A dump in CLI format

Actual behavior
A dump in HTML format

Workaround
Put this line to settings.php

$_SERVER['VAR_DUMPER_FORMAT'] = \PHP_SAPI === 'cli' ? 'cli' : 'html';

System Configuration

Q A
Drush version? 13.7
Drupal version? 11.3
PHP version 8.4
OS? Linux

Additional information
The $_SERVER['HTTP_ACCEPT'] is set in \Drush\Boot\DrupalBoot8::bootstrapDrupalSiteValidate.
I suppose we can simply remove $request->overrideGlobals(); call as there is no point to set 'HTTP_' variables in CLI SAPI. The other way is setting HTTP_ACCEPT manually like follows.

$server = [
    'SCRIPT_FILENAME' => getcwd() . '/index.php',
    'SCRIPT_NAME' => isset($parsed_url['path']) ? $parsed_url['path'] . 'index.php' : '/index.php',
    'HTTP_ACCEPT' => '',
] + $_SERVER;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions