[TYPO3-core] RFC: cli_dispatch.phpsh

Kasper Skårhøj kasper2006 at typo3.com
Wed Nov 29 17:35:31 CET 2006


I agree.

And its a no-go if it can't work with symlinks.

- kasper

On Nov 29, 2006, at 17:28 , Ernesto Baschny [cron IT] wrote:

> Ernesto Baschny [cron IT] wrote: on 29.11.2006 10:46:
>
>> Kasper added the nice "cli_dispatch.phpsh" script to TYPO3 core. I  
>> was
>> trying to use it to call some CLI's, but it failed with:
>>
>> ERROR: /home/ernst/typo3cvs.cron.stgt.vpn/typo3/ was not a file.  
>> Maybe your
>> environment does not support running this script with a relative  
>> path? Try
>> to run the script with its absolute path and you should be fine.
>>
>> Neither $_ENV['_'] nor $_SERVER['_'] is set on my server ("standard"
>> SuSE Linux with PHP 4.3.8).
>> (...)
>> -$temp_PATH_thisScript = isset($_ENV['_']) ? $_ENV['_'] : $_SERVER 
>> ['_'];
>> +$temp_PATH_thisScript = $_SERVER['argv'][0];
>
> I've got feedback from Kasper (please follow-up to typo3.team.core,
> Kasper). He prefers to add the checking for $_SERVER['argv'][0]  
> instead
> of replacing what we already have there:
>
> isset($_ENV['_']) ? $_ENV['_'] : (isset($_SERVER['_']) ? $_SERVER 
> ['_'] :
> $_SERVER['argv'][0]);
>
> The problem with that, as Martin explained, is that it will never work
> when calling the script using the syntax:
>
> % php -f <path>/typo3/cli_dispatch.phpsh
>
> This is required on Windows, and some people prefer to do that also
> unter Unix.
>
> As "$_SERVER['argv'][0]" is the documented way of accessing the
> information, I would prefer to turn it around in checking that  
> first and
> just if it fails, continue with checking for $_ENV['_'], which I would
> call non-standard.
>
> Votes?
>
> Martin Kutschker wrote on 29.11.2006 11:34:
>
>> There is another error:
>>
>>     // First argument is a key that
>> define('TYPO3_cliKey', $_SERVER["argv"][0]);
>>
>> Index 0 contains (as your patch suggests) the program not the  
>> argument.
>
> True, as this is not used anywhere in init.php, I would also vote (+1)
> for dropping this define, as it probably comes from some original
> CLI-script which was transformed into the "dispatcher".
>
> Votes about this?
>
>> There is a potential problem with the guessing of the path via
>> $_SERVER['PWD']. The working directory has nothing to do with  
>> location
>> of the script. Furthermore the "is absolute path" check is not  
>> portable
>> (will break on Windows).
>
> If we called script with relative adressing, the current path has an
> important role into finding out the "full path" of the script. Just
> append one to the other. The current setup only works under Unix,
> because of this condition:
>
> if ($temp_PATH_thisScript{0}!='/')      {
>
> An absolute path on Windows won't start with "/". While this  
> fallback of
> finding the "real path" works under Unix it will break any call to it
> under Windows. But I have no time currently to do more intensive
> researches on that currently, and would be happy if this first patch
> could make it through.
>
>> A better way is to use realpath(). The caveat here is that returns  
>> the
>> absolute path and resolves symlinks. But it is probably better than
>> PWD, which can be anything.
>
> Using realpath has the same problem as using __FILE__ as you noted
> before, because you will get the path of the typo3_src directory  
> and not
> the current real installation directory, where "typo3/" might just  
> be a
> symlink to the sources.
>
>> PS: Does it work at all? It doesn't seem to set TYPO3_cliInclude and
>> does not refer to $TYPO3_CONF_VARS['SC_OPTIONS']['GLOBAL']['cliKeys']
>> except in a comment.
>
> It does work, because init.php will set TYPO3_cliInclude if being  
> called
> from this dispatcher script. When init.php finishes, the dispatcher  
> will
> then just include the desired CLI-script.
>
> Cheers,
> Ernesto
> _______________________________________________
> TYPO3-team-core mailing list
> TYPO3-team-core at lists.netfielders.de
> http://lists.netfielders.de/cgi-bin/mailman/listinfo/typo3-team-core

- kasper
-------------------------------
kasper2006 at typo3.com | +45 20 999 115 | skype: kasperskaarhoej |  
gizmo: kasper_typo3

	"Peace be with you till we meet again
	Where we walk those streets of Gold
	And we'll never, never grow old
	I found rest for my soul
	Till we meet again"


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.netfielders.de/pipermail/typo3-team-core/attachments/20061129/22b7a428/attachment.htm 


More information about the TYPO3-team-core mailing list