Created
January 3, 2022 21:42
-
-
Save sarim/e8f8b5bb2b3263c5c2e7d68d31bb2f3c to your computer and use it in GitHub Desktop.
SEGFAULT with symfony cache + http-client in php8.1+symfony6. Works fine in php7.4/symfony5.4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// composer require symfony/cache | |
// composer require symfony/http-client | |
// rm -rf /tmp/symfony-cache/ | |
// php main.php | |
use Symfony\Component\Cache\Adapter\FilesystemAdapter; | |
use Symfony\Component\HttpClient\NativeHttpClient; | |
use Symfony\Component\HttpClient\ScopingHttpClient; | |
use Symfony\Contracts\Cache\ItemInterface; | |
require 'vendor/autoload.php'; | |
$cache = new FilesystemAdapter(); | |
// Tried with both Curl and Native client, same crash. | |
$client = new NativeHttpClient(); | |
$apiClient = ScopingHttpClient::forBaseUri($client, 'https://xkcd.com'); | |
$comicId = '0'; | |
$infos = $cache->get('comic_'.$comicId, function (ItemInterface $item) use ($comicId, $apiClient) { | |
$response = $apiClient->request('GET', "/info.{$comicId}.json"); | |
return $response->toArray(); | |
}); | |
\print_r($infos); | |
echo "Success\n"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Crashes here