?
avatar photodude
photodude
2 May 2016

mod_fcgid: stderr: PHP Notice: Undefined index: HTTP_HOST in /libraries/joomla/application/web.php on line 863

Steps to reproduce the issue

Unknown - just started showing up in the server logs for one site where I'm testing 3rdparty components with 3.5.1

Expected result

proper handling of situations where HTTP_HOST is undefined.

Actual result

mod_fcgid: stderr: PHP Notice: Undefined index: HTTP_HOST in /libraries/joomla/application/web.php on line 863

System information (as much as possible)

Setting Value
PHP Built On Linux lamp x86_64
Database Version 5.5.42-cll-lve
Database Collation utf8_general_ci
Database Connection Collation utf8mb4_general_ci
Database Type MySQLi
PHP Version 5.6.16
Web Server Apache
WebServer to PHP Interface cgi-fcgi
Joomla! Version Joomla! 3.5.1
Joomla! Platform Version 13.1.0
User Agent Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.75 Safari/537.36
Cache off
Cache Memcache
Session Handler Memcache
Error Reporting development
Search Engine Friendly URLs yes
Use URL Rewriting yes, with default .htaccess

Additional comments

I'm sure something much more complex than

$uri = $scheme . isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : "undefined" .  $_SERVER['REQUEST_URI'];

would be needed to fix this issue.

avatar photodude photodude - open - 2 May 2016
avatar photodude photodude - change - 2 May 2016
The description was changed
avatar andrepereiradasilva
andrepereiradasilva - comment - 2 May 2016

does that happens in CLI scripts?

avatar photodude
photodude - comment - 2 May 2016

@andrepereiradasilva I'm not sure, but I would venture to say that it's not CLI scripts.

The server logs just say mod_fcgid: stderr: mod_fcgid: stderr: PHP Notice: Undefined index: HTTP_HOST /libraries/joomla/application/web.php on line 863

avatar andrepereiradasilva
andrepereiradasilva - comment - 2 May 2016

i said that because in CLI scripts normally the HTTP_HOST doesn't exist.

Bur the method is detectRequestUri and i don't believe some CLI script is calling that.

avatar andrepereiradasilva
andrepereiradasilva - comment - 2 May 2016

is this the same as #7757 ?

avatar photodude
photodude - comment - 2 May 2016

@andrepereiradasilva I don't believe that /libraries/joomla/application/web.php is ever used via CLI.

As far as I know all the use on the site for testing is related to web access not cli. I don't believe this is the same, or even related to the issue you mentioned (as it's throwing the error from a completly different file).

avatar mbabker
mbabker - comment - 2 May 2016

JApplicationWeb CAN be booted from a CLI environment. So in some ways it's relevant.

avatar photodude
photodude - comment - 2 May 2016

Thank @mbabker I was unaware that "JApplicationWeb CAN be booted from a CLI environment."

So CLI is relevant, but unknown if CLI is part or source of the issue.

avatar andrepereiradasilva
andrepereiradasilva - comment - 2 May 2016

check your cron

avatar photodude
photodude - comment - 2 May 2016

I have no server level cron tasks, and the one extension that I know has a cron like task that runs in CLI doesn't seem to call JApplicationWeb or JUri

I will note that I recently read "$_SERVER['HTTP_HOST'] is not available when php is executed on the command line "

Which sounds like all cases where code is accessible via CLI will need to address the possibility that Undefined index: HTTP_HOST will happen under CLI

I did take a GEOIP check against the IP that triggered the notice and I am sure it's just someone who happened onto the site via the web. So the issue is caused by either a script the triggers running something in CLI, or it's some other issue.

avatar brianteeman brianteeman - change - 2 May 2016
Labels Added: ?
avatar wilsonge
wilsonge - comment - 7 May 2016

I mean JApplicationWeb should only be called from web interface (hence its name). Without some way of reproducing how to handle HTTP_HOST not being defined I'm not sure there's a lot we can do. I'm going to close the issue for now. But if we find a reproducible valid use case we can easily reopen it :)

avatar wilsonge wilsonge - change - 7 May 2016
Status New Closed
Closed_Date 0000-00-00 00:00:00 2016-05-07 19:47:15
Closed_By wilsonge
avatar wilsonge wilsonge - close - 7 May 2016
avatar wilsonge wilsonge - close - 7 May 2016
avatar mbabker
mbabker - comment - 7 May 2016

With 5f03cec it shouldn't be an issue anymore.

If JApplicationWeb can ONLY be called from a web compatible SAPI then like it's CLI counterpart there should be measures to block instantiation in a non-compatible environment. Fact is aside from the lack of $_SERVER data to deal with its URI features the web app is fully usable in a CLI environment and we (ab)use it in Framework apps (all of our apps that have Twig extensions have a dependency to an application class, usually web, and to compile Twig's cache from a command-line context Twig needs this dependency to boot the extensions).

avatar photodude
photodude - comment - 9 May 2016

@mbabker Since the error was on line 863 related to Apache I don't believe 5f03cec will fix this issue. Line 860 at the first if would need to be corrected with isset($_SERVER['HTTP_HOST'])

As I stated in opening this "I'm sure something much more complex than isset($_SERVER['HTTP_HOST']) is needed to properly correct this"

avatar nauseous
nauseous - comment - 3 Oct 2017

This is not related to Apache. The error is related to Joomla. We have NginX with the same error message. They do have a fix in the Joomla area.

avatar brianteeman
brianteeman - comment - 3 Oct 2017

Do you have a set of instructions for how to trigger this error?

avatar nauseous
nauseous - comment - 3 Oct 2017

Yes, when we're logged into the admin area we hit the site name at the top right to direct to the main page to check our changes, when the page loads, it's leaving off the /en/ which is a redirect error for languages.

So instead of loading

https://www.website.com/en/

it instead loads

http://www.website.com

If you hit reload, it loads fine.

avatar brianteeman
brianteeman - comment - 3 Oct 2017

Re-opened now we have some reproducable method to test

avatar brianteeman brianteeman - change - 3 Oct 2017
The description was changed
Status Closed New
Closed_Date 2016-05-07 19:47:14
Closed_By wilsonge
avatar brianteeman brianteeman - reopen - 3 Oct 2017
avatar franz-wohlkoenig franz-wohlkoenig - change - 5 Oct 2017
Category CLI
avatar joomla-cms-bot joomla-cms-bot - edited - 5 Oct 2017
avatar franz-wohlkoenig franz-wohlkoenig - change - 5 Oct 2017
The description was changed
Status New Discussion
avatar Quy
Quy - comment - 4 Nov 2017

This can be closed per PR #17655.

avatar franz-wohlkoenig franz-wohlkoenig - change - 4 Nov 2017
Status Discussion Closed
Closed_Date 0000-00-00 00:00:00 2017-11-04 06:29:20
Closed_By franz-wohlkoenig
avatar joomla-cms-bot joomla-cms-bot - change - 4 Nov 2017
Closed_By franz-wohlkoenig joomla-cms-bot
avatar joomla-cms-bot joomla-cms-bot - close - 4 Nov 2017
avatar joomla-cms-bot
joomla-cms-bot - comment - 4 Nov 2017
avatar franz-wohlkoenig
franz-wohlkoenig - comment - 4 Nov 2017

closed in Favor of Pull Request #17655.

Thanks for Hint @Quy.

Add a Comment

Login with GitHub to post a comment