[TYPO3-core] RFC: Bug / Feature #5838: Get cli_dispatch.phpsh to work on windows platforms
Martin Kutschker
martin.kutschker-n0spam at no5pam-blackbox.net
Fri Oct 26 16:58:36 CEST 2007
Christian Trabold schrieb:
> Hi Andreas,
>
>> Christian Trabold wrote:
>>> Solution:
>>> Do not set $temp_CURRENT_DIR on Windows. See attached patch.
>>
>> The PHP constant will be defined in typo3/init.php on line 70 again which
>> will throw a notice like:
>>
>> Notice: Constant TYPO3_OS already defined in test.php on line 7 Call
>> Stack: 0.0009 53432 1. {main}() test.php:0
>> 0.0010 53684 2. define() test.php:7
>>
>> So, defining the constant TYPO3_OS in that early stage might not be
>> the best
>> idea.
> ...
>> Maybe a new PHP constant TYPO3_cliOS could be introduced for this stage.
>
> introducing a "new" constant with the exact property as "TYPO3_OS" has
> sounds / feels a bit odd. What do you think about this solution:
>
>
> if (stristr(PHP_OS,'win')&&!stristr(PHP_OS,'darwin'))) {
> $temp_CURRENT_DIR = $_SERVER['PWD'].'/';
> }
AFAIK $_SERVER['PWD'] is not set on Windows. So all you can do is to
avoid the die().
if (stristr(PHP_OS,'win')&&!stristr(PHP_OS,'darwin'))) {
if (preg_match('/^([A-Z]:)?\\'/, $temp_PATH_thisScript)) {
die('ERROR: Relative paths are not supported on Windows. Try to run
the script with its absolute path.'.chr(10).chr(10));
}
} elseif ($temp_PATH_thisScript{0} != '/') {
if ($_SERVER['PWD']) {
$temp_PATH_thisScript =
$_SERVER['PWD'].'/'.ereg_replace('\.\/','',$temp_PATH_thisScript);
if (!@is_file($temp_PATH_thisScript)) {
die(wordwrap('ERROR: '.$temp_PATH_thisScript.' 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.'.chr(10).chr(10)));
} else {
die('ERROR: Relative paths are not supported in your enviroment. Try
to run the script with its absolute path.'.chr(10).chr(10));
}
}
Or maybe $_SERVER['PWD'] is available on some Windows installations,
then it must be more like this:
$relativePath = FALSE;
if (stristr(PHP_OS,'win')&&!stristr(PHP_OS,'darwin'))) {
if (!preg_match('/^([A-Z]:)?\\'/, $temp_PATH_thisScript)) {
$relativePath = TRUE;
}
} else {
if ($temp_PATH_thisScript{0} != '/') {
$relativePath = TRUE;
}
}
if ($relativePath) {
if ($_SERVER['PWD']) {
$temp_PATH_thisScript =
$_SERVER['PWD'].'/'.ereg_replace('\.\/','',$temp_PATH_thisScript);
if (!@is_file($temp_PATH_thisScript)) {
die ('relative path found and an error occured during resolving
of the absolute path.');
}
} else {
die ('relative path found, but resolving absolute path is not
supported on this platform.');
}
}
Masi
More information about the TYPO3-team-core
mailing list