| Summary | Horde_CLI::runningFromCLI() can erroneously return 'false' after Horde_CLI::init() is called |
| Queue | Horde Framework Packages |
| Queue Version | FRAMEWORK_3 |
| Type | Bug |
| State | Resolved |
| Priority | 1. Low |
| Owners | |
| Requester | dorm (at) dorm (dot) org |
| Created | 04/19/2006 (7128 days ago) |
| Due | |
| Updated | 04/19/2006 (7128 days ago) |
| Assigned | |
| Resolved | 04/19/2006 (7128 days ago) |
| Github Issue Link | |
| Github Pull Request | |
| Milestone | |
| Patch | No |
State ⇒ Resolved
what I committed.
State ⇒ Not A Bug
doesn't catch if you try to run the cli scripts on a localhost web
server.
State ⇒ Unconfirmed
Priority ⇒ 1. Low
Type ⇒ Bug
Summary ⇒ Horde_CLI::runningFromCLI() can erroneously return 'false' after Horde_CLI::init() is called
Queue ⇒ Horde Framework Packages
'false' when it should return 'true' after a call to
Horde_CLI::init(). This is because Horde_CLI::init() sets
$_SERVER['SERVER_NAME'] to '127.0.0.1'. Horde_CLI::runningFromCLI()
checks for an empty($_SERVER['SERVER_NAME']) to confirm that we are
running from CLI if php_sapi_name() returns 'cgi'. Since
$_SERVER['SERVER_NAME'] has been set to '127.0.0.1' by a previous call
to Horde_CLI::init(), Horde_CLI::runningFromCLI() returns false.
This does not seem to be a major issue, except if the static method
Horde_CLI::init() is called before instantiating the Horde_CLI class,
then the class constructor incorrectly sets values for
$this->_newline, $this->_indent, etc. You get HTML output instead of
vt100/xterm/etc. output from the command line.
FYI I discovered this while working with the ansel/scripts/ansel.php
CLI script.
The following patch adds a check for $_SERVER['SERVER_NAME'] ==
'127.0.0.1' to Horde_CLI::runningFromCLI(), and is working well for me:
@@ -336,7 +336,7 @@
if ($sapi == 'cli') {
return true;
} else {
- return $sapi == 'cgi' && empty($_SERVER['SERVER_NAME']);
+ return $sapi == 'cgi' && (empty($_SERVER['SERVER_NAME'])
|| $_SERVER['SERVER_NAME'] == '127.0.0.1');
}
}