Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Marketplace/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ private function request(string $method, string $endpoint, array $params = [])
return $this->cache()->rememberWithExpiration($key, function () use ($method, $endpoint, $params) {
$response = Guzzle::request($method, $endpoint, [
'verify' => $this->verifySsl,
'timeout' => 5,
($method === 'GET' ? 'query' : 'json') => $params,
]);

Expand Down
8 changes: 4 additions & 4 deletions src/Marketplace/Marketplace.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Statamic\Marketplace;

use Facades\Statamic\Marketplace\Client;
use GuzzleHttp\Exception\RequestException;
use GuzzleHttp\Exception\TransferException;
use Illuminate\Support\Facades\Cache;
use Statamic\Facades\Addon;
use Statamic\Marketplace\Addon as AddonProduct;
Expand All @@ -23,7 +23,7 @@ public function packages(array $packages)
$response = Client::post($uri, ['packages' => $packages]);

return [60 => collect($response['data'])];
} catch (RequestException $e) {
} catch (TransferException $e) {
return [5 => collect()];
}
});
Expand All @@ -46,7 +46,7 @@ public function releases($package, $params = [])
'data' => collect($response['data']),
'meta' => $response['meta'] ?? null,
]];
} catch (RequestException $e) {
} catch (TransferException $e) {
return $fallback;
}
});
Expand Down Expand Up @@ -81,7 +81,7 @@ public function themes()
$response = Client::get($uri);

return [60 => collect($response['data'])];
} catch (RequestException $e) {
} catch (TransferException $e) {

return [5 => collect()];
}
Expand Down
15 changes: 15 additions & 0 deletions tests/Composer/CoreChangelogTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@

namespace Tests\Composer;

use Facades\GuzzleHttp\Client;
use Facades\Statamic\Version;
use GuzzleHttp\Exception\ConnectException;
use GuzzleHttp\Psr7\Request;
use PHPUnit\Framework\Attributes\Test;
use Statamic\Updater\CoreChangelog;
use Tests\TestCase;

Expand All @@ -18,4 +22,15 @@ protected function changelog()

return new CoreChangelog;
}

#[Test]
public function it_returns_an_empty_changelog_when_the_marketplace_times_out()
{
Client::shouldReceive('request')
->withArgs(fn ($method, $uri, $options) => $options['timeout'] === 5)
->once()
->andThrow(new ConnectException('', new Request('GET', '/api/v1/marketplace/packages/statamic/cms/releases')));

$this->assertCount(0, $this->changelog()->get());
}
}
Loading