6.0.0-beta1
▾
Tasks
New Task
Search
Photos
Wiki
▾
Tickets
New Ticket
Search
dev.horde.org
Toggle Alerts Log
Help
10/23/25
H
istory
A
ttachments
C
omment
W
atch
Download
Comment on [#3791] Horde_CLI::runningFromCLI() can erroneously return 'false' after Horde_CLI::init() is called
*
Your Email Address
*
Spam protection
Enter the letters below:
. .. ..__..___\ / |\ || || |[__ >< | \||/\||__\| / \
Comment
> The Horde_CLI::runningFromCLI() function can erroneously return > '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'); > > } > > } > >
Attachment
Watch this ticket
N
ew Ticket
M
y Tickets
S
earch
Q
uery Builder
R
eports
Saved Queries
Open Bugs
Bugs waiting for Feedback
Open Bugs in Releases
Open Enhancements
Enhancements waiting for Feedback
Bugs with Patches
Enhancements with Patches
Release Showstoppers
Stalled Tickets
New Tickets
Horde 5 Showstoppers