Skip to content

Commit

Permalink
Merge branch '11.x' into fix/aluisio/policies-stub
Browse files Browse the repository at this point in the history
  • Loading branch information
Aluisio-Pires committed Nov 22, 2024
2 parents 23b9e22 + abc1faa commit 25673dd
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/Illuminate/Console/Scheduling/CommandBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ protected function buildForegroundCommand(Event $event)
{
$output = ProcessUtils::escapeArgument($event->output);

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

/**
Expand Down
6 changes: 5 additions & 1 deletion src/Illuminate/Console/Scheduling/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,11 @@ protected function execute($container)
{
return Process::fromShellCommandline(
$this->buildCommand(), base_path(), null, null, null
)->run();
)->run(
laravel_cloud()
? fn ($type, $line) => fwrite($type === 'out' ? STDOUT : STDERR, $line)
: fn () => true
);
}

/**
Expand Down
4 changes: 1 addition & 3 deletions src/Illuminate/Http/Middleware/TrustProxies.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,7 @@ protected function setTrustedProxyIpAddresses(Request $request)
{
$trustedIps = $this->proxies() ?: config('trustedproxy.proxies');

if (is_null($trustedIps) &&
(($_ENV['LARAVEL_CLOUD'] ?? false) === '1' ||
($_SERVER['LARAVEL_CLOUD'] ?? false) === '1')) {
if (is_null($trustedIps) && laravel_cloud()) {
$trustedIps = '*';
}

Expand Down
13 changes: 13 additions & 0 deletions src/Illuminate/Support/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,19 @@ function object_get($object, $key, $default = null)
}
}

if (! function_exists('laravel_cloud')) {
/**
* Determine if the appliation is running on Laravel Cloud.
*
* @return bool
*/
function laravel_cloud()
{
return ($_ENV['LARAVEL_CLOUD'] ?? false) === '1' ||
($_SERVER['LARAVEL_CLOUD'] ?? false) === '1';
}
}

if (! function_exists('once')) {
/**
* Ensures a callable is only called once, and returns the result on subsequent calls.
Expand Down

0 comments on commit 25673dd

Please sign in to comment.