Fix various PHP 8 deprecations

This commit is contained in:
Hypolite Petovan 2022-11-19 19:10:02 -05:00
parent a147038c2e
commit 6f93ee7e49
10 changed files with 19 additions and 23 deletions

View file

@ -383,7 +383,7 @@ class APContact
// kroeg:blocks, updated
// When the photo is too large, try to shorten it by removing parts
if (strlen($apcontact['photo']) > 255) {
if (strlen($apcontact['photo'] ?? '') > 255) {
$parts = parse_url($apcontact['photo']);
unset($parts['fragment']);
$apcontact['photo'] = (string)Uri::fromParts($parts);
@ -574,7 +574,7 @@ class APContact
*
* @param array $apcontact
*
* @return bool
* @return bool
*/
public static function isRelay(array $apcontact): bool
{

View file

@ -210,7 +210,7 @@ class Item
$fields['raw-body'] = BBCode::removeSharedData($fields['raw-body']);
}
}
Post\Media::insertFromAttachmentData($item['uri-id'], $fields['body']);
$content_fields = ['raw-body' => trim($fields['raw-body'] ?? $fields['body'])];
@ -337,7 +337,7 @@ class Item
* generate a resource-id and therefore aren't intimately linked to the item.
*/
/// @TODO: this should first check if photo is used elsewhere
if (strlen($item['resource-id'])) {
if ($item['resource-id']) {
Photo::delete(['resource-id' => $item['resource-id'], 'uid' => $item['uid']]);
}

View file

@ -279,7 +279,7 @@ class Media
if (!empty($contact['gsid'])) {
$gserver = DBA::selectFirst('gserver', ['url', 'site_name'], ['id' => $contact['gsid']]);
}
$media['type'] = self::ACTIVITY;
$media['media-uri-id'] = $item['uri-id'];
$media['height'] = null;
@ -687,7 +687,7 @@ class Media
$previews[] = $medium['preview'];
}
$type = explode('/', current(explode(';', $medium['mimetype'])));
$type = explode('/', explode(';', $medium['mimetype'])[0]);
if (count($type) < 2) {
Logger::info('Unknown MimeType', ['type' => $type, 'media' => $medium]);
$filetype = 'unkn';