Skip to content

Navigation Menu

Sign in
Appearance settings

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

Commit c0f7463

Browse filesBrowse files
committed
bug #16352 Fix the server variables in the router_*.php files (leofeyer)
This PR was squashed before being merged into the 2.3 branch (closes #16352). Discussion ---------- Fix the server variables in the router_*.php files | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | none | License | MIT The built-in web server automatically rewrites everything to the `app_dev.php` script, but it does not adjust the server variables accordingly. Here is the output of `print_r($_SERVER)` on Apache with mod_rewrite enabled (relevant lines only): ``` Array ( [REQUEST_URI] => /text-elements.html [SCRIPT_NAME] => /app_dev.php [PHP_SELF] => /app_dev.php ) ``` And here is the output of the exact same script on the built-in server: ``` Array ( [REQUEST_URI] => /text-elements.html [SCRIPT_NAME] => /text-elements.html [PHP_SELF] => /text-elements.html ) ``` And here is the return value of Symfony's `Request::getScriptName()` method: ```php // Apache: http://localhost/text-elements.html echo $this->container->get('request_stack')->getCurrentRequest()->getScriptName(); // /app_dev.php // Built-in web server: http://127.0.0.1:8000/text-elements.html echo $this->container->get('request_stack')->getCurrentRequest()->getScriptName(); // /text-elements.html ``` This PR fixes the two server variables in the `router_dev.php` script. Commits ------- 4923411 Fix the server variables in the router_*.php files
2 parents f2e8722 + 4923411 commit c0f7463
Copy full SHA for c0f7463

File tree

2 files changed

+8
-0
lines changed
Filter options

2 files changed

+8
-0
lines changed

‎src/Symfony/Bundle/FrameworkBundle/Resources/config/router_dev.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Resources/config/router_dev.php
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@
3333
$_SERVER = array_merge($_SERVER, $_ENV);
3434
$_SERVER['SCRIPT_FILENAME'] = $_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR.'app_dev.php';
3535

36+
// Since we are rewriting to app_dev.php, adjust SCRIPT_NAME and PHP_SELF accordingly
37+
$_SERVER['SCRIPT_NAME'] = DIRECTORY_SEPARATOR.'app_dev.php';
38+
$_SERVER['PHP_SELF'] = DIRECTORY_SEPARATOR.'app_dev.php';
39+
3640
require 'app_dev.php';
3741

3842
error_log(sprintf('%s:%d [%d]: %s', $_SERVER['REMOTE_ADDR'], $_SERVER['REMOTE_PORT'], http_response_code(), $_SERVER['REQUEST_URI']), 4);

‎src/Symfony/Bundle/FrameworkBundle/Resources/config/router_prod.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Resources/config/router_prod.php
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@
3333
$_SERVER = array_merge($_SERVER, $_ENV);
3434
$_SERVER['SCRIPT_FILENAME'] = $_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR.'app.php';
3535

36+
// Since we are rewriting to app.php, adjust SCRIPT_NAME and PHP_SELF accordingly
37+
$_SERVER['SCRIPT_NAME'] = DIRECTORY_SEPARATOR.'app.php';
38+
$_SERVER['PHP_SELF'] = DIRECTORY_SEPARATOR.'app.php';
39+
3640
require 'app.php';
3741

3842
error_log(sprintf('%s:%d [%d]: %s', $_SERVER['REMOTE_ADDR'], $_SERVER['REMOTE_PORT'], http_response_code(), $_SERVER['REQUEST_URI']), 4);

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.