Merge pull request '[Composer] Change gofabian/negotiation-middleware dependency requirement to support PHP 8.2' (#96) from MrPetovan/friendica-directory:bug/php-8 into stable

Reviewed-on: friendica/friendica-directory#96
This commit is contained in:
Tobias Diekershoff 2023-08-09 07:01:21 +02:00
commit 13b95e22da
8 changed files with 289 additions and 264 deletions

View file

@ -23,9 +23,10 @@
"byjg/migration": "^4.0",
"byjg/uri": "^1.0.4",
"gettext/gettext": "^4.6",
"gofabian/negotiation-middleware": "^0.1.3",
"gofabian/negotiation-middleware": "dev-master",
"guzzlehttp/guzzle": "^6.5",
"laminas/laminas-escaper": "^2.6",
"laminas/laminas-zendframework-bridge": "^1.4",
"masterminds/html5": "^2.3",
"monolog/monolog": "^1.17",
"mrpetovan/net_ping": "^1.2",
@ -55,7 +56,7 @@
},
"config": {
"platform": {
"php": "7.1.0"
"php": "7.3.0"
},
"process-timeout" : 0,
"autoloader-suffix": "FriendicaDirectory",

526
composer.lock generated

File diff suppressed because it is too large Load diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 325 B

After

Width:  |  Height:  |  Size: 2.6 KiB

View file

@ -14,12 +14,18 @@ class Photo
* @var \Atlas\Pdo\Connection
*/
private $atlas;
/**
* @var string
*/
private $defaultProfilePictureSmallPath;
public function __construct(
\Atlas\Pdo\Connection $atlas
\Atlas\Pdo\Connection $atlas,
string $defaultProfilePictureSmallPath
)
{
$this->atlas = $atlas;
$this->defaultProfilePictureSmallPath = $defaultProfilePictureSmallPath;
}
public function render(Request $request, Response $response, array $args): Response
@ -30,7 +36,7 @@ class Photo
);
if (!$data) {
$data = file_get_contents('public/images/default-profile-sm.jpg');
$data = file_get_contents($this->defaultProfilePictureSmallPath);
}
//Try and cache our result.

View file

@ -290,6 +290,9 @@ class Server
} else {
$this->logger->info('SSL-verified URL probe failed with error code: ' . $e->getCode());
}
} catch (\InvalidArgumentException $e) {
$this->logger->error('Invalid argument provided to HTTP client', ['base_url' => $base_url, 'exception' => $e]);
return ['data' => false, 'time' => 0, 'curl_info' => [], 'ssl_state' => null];
}
$probe_end = microtime(true);

View file

@ -10,7 +10,8 @@ class Photo extends BaseRoute
public function __invoke(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args): \Slim\Http\Response
{
return (new \Friendica\Directory\Controllers\Api\Photo(
$this->container->atlas
$this->container->atlas,
$this->container->get('defaultProfilePictureSmallPath')
))->render($request, $response, $args);
}
}

View file

@ -165,12 +165,12 @@ class L10n
$foundLang = $language;
}
if (strtolower($key) == strtolower(str_replace('-', '_', $locale))) {
$foundLocale = true;
$foundLocale = $language;
break;
}
}
return $foundLocale ? $language : $foundLang ?: $locale;
return $foundLocale ?: $foundLang ?: $locale;
}
/**

View file

@ -99,6 +99,8 @@ $container['http'] = function (ContainerInterface $c): GuzzleHttp\ClientInterfac
return new GuzzleHttp\Client(['timeout' => 20, 'headers' => ['User-Agent' => 'FriendicaDirectory/' . trim($version) . ' ' . \GuzzleHttp\default_user_agent()]]);
};
$container['defaultProfilePictureSmallPath'] = __DIR__ . '/../public/assets/images/default-profile-sm.jpg';
// Internal Dependency Injection
$container[\Friendica\Directory\Models\Profile::class] = function (ContainerInterface $c): Friendica\Directory\Models\Profile {