Skip to content

Commit abc1faa

Browse files
☁️ (#53623)
* work on cloud env * Apply fixes from StyleCI * remove override * output * attempt fix * work on cloud * revert change * formatting --------- Co-authored-by: StyleCI Bot <[email protected]>
1 parent dbd579c commit abc1faa

File tree

4 files changed

+22
-7
lines changed

4 files changed

+22
-7
lines changed

src/Illuminate/Console/Scheduling/CommandBuilder.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ protected function buildForegroundCommand(Event $event)
3232
{
3333
$output = ProcessUtils::escapeArgument($event->output);
3434

35-
return $this->ensureCorrectUser(
36-
$event, $event->command.($event->shouldAppendOutput ? ' >> ' : ' > ').$output.' 2>&1'
37-
);
35+
return laravel_cloud()
36+
? $this->ensureCorrectUser($event, $event->command.' 2>&1 | tee '.($event->shouldAppendOutput ? '-a ' : '').$output)
37+
: $this->ensureCorrectUser($event, $event->command.($event->shouldAppendOutput ? ' >> ' : ' > ').$output.' 2>&1');
3838
}
3939

4040
/**

src/Illuminate/Console/Scheduling/Event.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,11 @@ protected function execute($container)
206206
{
207207
return Process::fromShellCommandline(
208208
$this->buildCommand(), base_path(), null, null, null
209-
)->run();
209+
)->run(
210+
laravel_cloud()
211+
? fn ($type, $line) => fwrite($type === 'out' ? STDOUT : STDERR, $line)
212+
: fn () => true
213+
);
210214
}
211215

212216
/**

src/Illuminate/Http/Middleware/TrustProxies.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,7 @@ protected function setTrustedProxyIpAddresses(Request $request)
6868
{
6969
$trustedIps = $this->proxies() ?: config('trustedproxy.proxies');
7070

71-
if (is_null($trustedIps) &&
72-
(($_ENV['LARAVEL_CLOUD'] ?? false) === '1' ||
73-
($_SERVER['LARAVEL_CLOUD'] ?? false) === '1')) {
71+
if (is_null($trustedIps) && laravel_cloud()) {
7472
$trustedIps = '*';
7573
}
7674

src/Illuminate/Support/helpers.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,19 @@ function object_get($object, $key, $default = null)
225225
}
226226
}
227227

228+
if (! function_exists('laravel_cloud')) {
229+
/**
230+
* Determine if the appliation is running on Laravel Cloud.
231+
*
232+
* @return bool
233+
*/
234+
function laravel_cloud()
235+
{
236+
return ($_ENV['LARAVEL_CLOUD'] ?? false) === '1' ||
237+
($_SERVER['LARAVEL_CLOUD'] ?? false) === '1';
238+
}
239+
}
240+
228241
if (! function_exists('once')) {
229242
/**
230243
* Ensures a callable is only called once, and returns the result on subsequent calls.

0 commit comments

Comments
 (0)