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

Commit 89a0887

Browse files
committed
Merge branch 'hotfix/182'
Close #182
2 parents 036b262 + 7d2fbf8 commit 89a0887

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
@@ -24,6 +24,8 @@ All notable changes to this project will be documented in this file, in reverse
2424

2525
- [#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).
2626

27+
- [#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.
28+
2729
## 2.11.0 - 2019-12-03
2830

2931
### 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)