Bug #50080

Broken concept for CLI/Web separation

Added by Philipp Gampe over 8 years ago. Updated about 8 years ago.

Status:
Needs Feedback
Priority:
Should have
Category:
Core
Target version:
-
Start date:
2013-07-16
Due date:
% Done:

0%

Estimated time:
PHP Version:
Has patch:
No
Complexity:
medium

Description

Currently Flow tries to detect a CLI request by looking into the PHP_SAPI constant. This is a wrong approach and completely breaks on host that use CGI for both web and console requests.

The German hoster Domainfactory is such a hoster. The PHP_SAPI in both web and console is cgi-fcgi, thus there is no way to distinguish a web from a cli request.

I tried to fix it myself in the code, but got lost in the various bootstrap methods (and their orders) and the sub-request cycles: https://notes.typo3.org/p/neos-domainfactory

@see http://www.php.net/manual/en/function.php-sapi-name.php#89858

IMHO Flow should take advantage of the different entry scripts and set a constant very early in the entry point that distinguishes the request types. Then it could also separate cli from cli-sub and web requests.
It would be cheaper in terms of processing time and less error prone.

#1

Updated by Philipp Gampe over 8 years ago

TYPO3 CMS also uses a constant to detect cli requests.

#2

Updated by Karsten Dambekalns about 8 years ago

  • Status changed from New to Needs Feedback
  • Assignee set to Karsten Dambekalns
  • PHP Version deleted (5.4)

It is inherently wrong to use the CGI binary for CLI purposes, someone should fix those hosters. The CLI binary behaves different than the CGI binary, see http://www.php.net/manual/en/features.commandline.differences.php

So even if everything we currently do in a CLI context works with CGI as well, there is no guarantee it stays like this.

#3

Updated by Philipp Gampe about 8 years ago

OK, there is actually CLI support for DF since a while ... they added it for Flow and Symfony 2 ;)
http://www.df.eu/blog/2011/10/26/php-5-3-8-cli-und-python-sphinx/

Anyway, I still think that Flow should try to support non-cli env too. Not all hosters support a CLI binary and the required changes are pretty low, if you set a constant at the entry scripts.

#4

Updated by Karsten Dambekalns about 8 years ago

Philipp Gampe wrote:

OK, there is actually CLI support for DF since a while ...

That blog post is 2 years old. "For a while" is a slight understatement. :)

Anyway, I still think that Flow should try to support non-cli env too. Not all hosters support a CLI binary and the required changes are pretty low

I still think for CLI work you need a CLI environment. As I wrote, even if it works currently, there is no guarantee we will be relying on CLI specifics in the future.

Also available in: Atom PDF