Merge pull request #12604 from nupplaphil/bug/marco_r

Some Bugfixings (thx to Marco R.)
This commit is contained in:
Hypolite Petovan 2023-01-03 15:14:15 -05:00 committed by GitHub
commit 0ab5fed64c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 2 deletions

View file

@ -62,10 +62,14 @@ class ExternalResource implements ICanReadFromStorage
if (!empty($fetchResult) && $fetchResult->isSuccess()) { if (!empty($fetchResult) && $fetchResult->isSuccess()) {
Logger::debug('Got picture', ['Content-Type' => $fetchResult->getHeader('Content-Type'), 'uid' => $data->uid, 'url' => $data->url]); Logger::debug('Got picture', ['Content-Type' => $fetchResult->getHeader('Content-Type'), 'uid' => $data->uid, 'url' => $data->url]);
return $fetchResult->getBody(); return $fetchResult->getBody();
} else {
if (empty($fetchResult)) {
throw new ReferenceStorageException(sprintf('External resource failed to get %s', $reference));
} else { } else {
throw new ReferenceStorageException(sprintf('External resource failed to get %s', $reference), $fetchResult->getReturnCode(), new Exception($fetchResult->getBody())); throw new ReferenceStorageException(sprintf('External resource failed to get %s', $reference), $fetchResult->getReturnCode(), new Exception($fetchResult->getBody()));
} }
} }
}
/** /**
* @inheritDoc * @inheritDoc

View file

@ -126,7 +126,7 @@ class Link
$timeout = DI::config()->get('system', 'xrd_timeout'); $timeout = DI::config()->get('system', 'xrd_timeout');
$curlResult = HTTPSignature::fetchRaw($url, 0, [HttpClientOptions::TIMEOUT => $timeout, HttpClientOptions::ACCEPT_CONTENT => $accept]); $curlResult = HTTPSignature::fetchRaw($url, 0, [HttpClientOptions::TIMEOUT => $timeout, HttpClientOptions::ACCEPT_CONTENT => $accept]);
if (!$curlResult->isSuccess()) { if (empty($curlResult) || !$curlResult->isSuccess()) {
return []; return [];
} }
$fields = ['mimetype' => $curlResult->getHeader('Content-Type')[0]]; $fields = ['mimetype' => $curlResult->getHeader('Content-Type')[0]];