Skip to content
This repository was archived by the owner on Jan 30, 2020. It is now read-only.

Commit 89c9e70

Browse files
committed
Merge branch 'hotfix/182' into develop
Forward port #182
2 parents 94f1ac7 + 7d2fbf8 commit 89c9e70

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ All notable changes to this project will be documented in this file, in reverse
4646

4747
- [#204](https://github.com/zendframework/zend-http/pull/204) fixes numerous header classes to cast field value to string (since `HeaderInterface::getFieldValue()` specifies a return value of a string).
4848

49+
- [#182](https://github.com/zendframework/zend-http/pull/182) fixes detecting base uri in Request. Now `argv` is used only for CLI request as a fallback to detect script filename.
50+
4951
## 2.11.0 - 2019-12-03
5052

5153
### Added

src/PhpEnvironment/Request.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -490,9 +490,13 @@ protected function detectBaseUrl()
490490
// Backtrack up the SCRIPT_FILENAME to find the portion
491491
// matching PHP_SELF.
492492

493-
$argv = $this->getServer()->get('argv', []);
494-
if (isset($argv[0]) && strpos($filename, $argv[0]) === 0) {
495-
$filename = substr($filename, strlen($argv[0]));
493+
// Only for CLI requests argv[0] contains script filename
494+
// @see https://www.php.net/manual/en/reserved.variables.server.php
495+
if (PHP_SAPI === 'cli') {
496+
$argv = $this->getServer()->get('argv', []);
497+
if (isset($argv[0]) && is_string($argv[0]) && $argv[0] !== '' && strpos($filename, $argv[0]) === 0) {
498+
$filename = substr($filename, strlen($argv[0]));
499+
}
496500
}
497501

498502
$baseUrl = '/';

0 commit comments

Comments
 (0)