8
8
* @license LGPL-3.0+
9
9
*/
10
10
11
+ if (0 === strpos(__FILE__, 'phar:') && ini_get('register_argc_argv')) {
12
+ echo 'Contao Manager cannot be run safely on non-CLI SAPIs with register_argc_argv=On. Aborting.'.PHP_EOL;
13
+ exit(1);
14
+ }
15
+
11
16
setlocale(LC_ALL, 'C');
12
17
require __DIR__.'/../vendor/autoload.php';
13
18
@@ -29,38 +34,50 @@ if (function_exists('ini_set')) {
29
34
@ini_set('display_errors', 1);
30
35
@ini_set('zlib.output_compression', 0);
31
36
32
- $memoryInBytes = static function ($value) {
33
- $unit = strtolower(substr($value, -1, 1));
34
- $value = (int) $value;
35
- switch($unit) {
36
- /** @noinspection PhpMissingBreakStatementInspection */
37
- case 'g':
38
- $value *= 1024;
39
- // no break (cumulative multiplier)
40
- /** @noinspection PhpMissingBreakStatementInspection */
41
- case 'm':
42
- $value *= 1024;
43
- // no break (cumulative multiplier)
44
- case 'k':
45
- $value *= 1024;
46
- }
47
-
48
- return $value;
49
- };
50
-
51
- $memoryLimit = trim(ini_get('memory_limit'));
52
- // Increase memory_limit if it is lower than 1.5GB
53
- if ($memoryLimit != -1 && $memoryInBytes($memoryLimit) < 1024 * 1024 * 1536) {
54
- @ini_set('memory_limit', '1536M');
55
- }
56
37
// Set user defined memory limit
57
38
if ($memoryLimit = getenv('COMPOSER_MEMORY_LIMIT')) {
58
39
@ini_set('memory_limit', $memoryLimit);
40
+ } else {
41
+ $memoryInBytes = static function ($value) {
42
+ $unit = strtolower(substr($value, -1, 1));
43
+ $value = (int) $value;
44
+ switch($unit) {
45
+ /** @noinspection PhpMissingBreakStatementInspection */
46
+ case 'g':
47
+ $value *= 1024;
48
+ // no break (cumulative multiplier)
49
+ /** @noinspection PhpMissingBreakStatementInspection */
50
+ case 'm':
51
+ $value *= 1024;
52
+ // no break (cumulative multiplier)
53
+ case 'k':
54
+ $value *= 1024;
55
+ }
56
+
57
+ return $value;
58
+ };
59
+
60
+ $memoryLimit = trim(ini_get('memory_limit'));
61
+ // Increase memory_limit if it is lower than 1.5GB
62
+ if ($memoryLimit != -1 && $memoryInBytes($memoryLimit) < 1024 * 1024 * 1536) {
63
+ @ini_set('memory_limit', '1536M');
64
+ }
65
+ unset($memoryInBytes);
66
+ }
67
+ unset($memoryLimit);
68
+ }
69
+
70
+ // Workaround PHP bug on Windows where env vars containing Unicode chars are mangled in $_SERVER
71
+ // see https://github.com/php/php-src/issues/7896
72
+ if (PHP_VERSION_ID >= 70113 && (PHP_VERSION_ID < 80016 || (PHP_VERSION_ID >= 80100 && PHP_VERSION_ID < 80103)) && Platform::isWindows()) {
73
+ foreach ($_SERVER as $serverVar => $serverVal) {
74
+ if (($serverVal = getenv($serverVar)) !== false) {
75
+ $_SERVER[$serverVar] = $serverVal;
76
+ }
59
77
}
60
- unset($memoryInBytes, $memoryLimit);
61
78
}
62
79
63
- putenv ('COMPOSER_BINARY='. realpath($_SERVER['argv'][0]));
80
+ Platform::putEnv ('COMPOSER_BINARY', realpath($_SERVER['argv'][0]));
64
81
65
82
// Always create kernel to initialize the application
66
83
$kernel = new ApiKernel('@symfony_env@' === 'prod' ? 'prod' : 'dev');
0 commit comments