Fix various PHP 8 deprecations
This commit is contained in:
parent
a147038c2e
commit
6f93ee7e49
|
@ -244,12 +244,8 @@ class Nav
|
||||||
}
|
}
|
||||||
|
|
||||||
$gdirpath = 'directory';
|
$gdirpath = 'directory';
|
||||||
|
if (DI::config()->get('system', 'singleuser') && DI::config()->get('system', 'directory')) {
|
||||||
if (strlen(DI::config()->get('system', 'singleuser'))) {
|
$gdirpath = Profile::zrl(DI::config()->get('system', 'directory'), true);
|
||||||
$gdir = DI::config()->get('system', 'directory');
|
|
||||||
if (strlen($gdir)) {
|
|
||||||
$gdirpath = Profile::zrl($gdir, true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((DI::userSession()->getLocalUserId() || DI::config()->get('system', 'community_page_style') != Community::DISABLED_VISITOR) &&
|
if ((DI::userSession()->getLocalUserId() || DI::config()->get('system', 'community_page_style') != Community::DISABLED_VISITOR) &&
|
||||||
|
|
|
@ -383,7 +383,7 @@ class APContact
|
||||||
// kroeg:blocks, updated
|
// kroeg:blocks, updated
|
||||||
|
|
||||||
// When the photo is too large, try to shorten it by removing parts
|
// 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']);
|
$parts = parse_url($apcontact['photo']);
|
||||||
unset($parts['fragment']);
|
unset($parts['fragment']);
|
||||||
$apcontact['photo'] = (string)Uri::fromParts($parts);
|
$apcontact['photo'] = (string)Uri::fromParts($parts);
|
||||||
|
@ -574,7 +574,7 @@ class APContact
|
||||||
*
|
*
|
||||||
* @param array $apcontact
|
* @param array $apcontact
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public static function isRelay(array $apcontact): bool
|
public static function isRelay(array $apcontact): bool
|
||||||
{
|
{
|
||||||
|
|
|
@ -210,7 +210,7 @@ class Item
|
||||||
$fields['raw-body'] = BBCode::removeSharedData($fields['raw-body']);
|
$fields['raw-body'] = BBCode::removeSharedData($fields['raw-body']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Post\Media::insertFromAttachmentData($item['uri-id'], $fields['body']);
|
Post\Media::insertFromAttachmentData($item['uri-id'], $fields['body']);
|
||||||
|
|
||||||
$content_fields = ['raw-body' => trim($fields['raw-body'] ?? $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.
|
* generate a resource-id and therefore aren't intimately linked to the item.
|
||||||
*/
|
*/
|
||||||
/// @TODO: this should first check if photo is used elsewhere
|
/// @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']]);
|
Photo::delete(['resource-id' => $item['resource-id'], 'uid' => $item['uid']]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -279,7 +279,7 @@ class Media
|
||||||
if (!empty($contact['gsid'])) {
|
if (!empty($contact['gsid'])) {
|
||||||
$gserver = DBA::selectFirst('gserver', ['url', 'site_name'], ['id' => $contact['gsid']]);
|
$gserver = DBA::selectFirst('gserver', ['url', 'site_name'], ['id' => $contact['gsid']]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$media['type'] = self::ACTIVITY;
|
$media['type'] = self::ACTIVITY;
|
||||||
$media['media-uri-id'] = $item['uri-id'];
|
$media['media-uri-id'] = $item['uri-id'];
|
||||||
$media['height'] = null;
|
$media['height'] = null;
|
||||||
|
@ -687,7 +687,7 @@ class Media
|
||||||
$previews[] = $medium['preview'];
|
$previews[] = $medium['preview'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$type = explode('/', current(explode(';', $medium['mimetype'])));
|
$type = explode('/', explode(';', $medium['mimetype'])[0]);
|
||||||
if (count($type) < 2) {
|
if (count($type) < 2) {
|
||||||
Logger::info('Unknown MimeType', ['type' => $type, 'media' => $medium]);
|
Logger::info('Unknown MimeType', ['type' => $type, 'media' => $medium]);
|
||||||
$filetype = 'unkn';
|
$filetype = 'unkn';
|
||||||
|
|
|
@ -46,7 +46,7 @@ class Home extends BaseModule
|
||||||
DI::baseUrl()->redirect('network');
|
DI::baseUrl()->redirect('network');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strlen($config->get('system', 'singleuser'))) {
|
if ($config->get('system', 'singleuser')) {
|
||||||
DI::baseUrl()->redirect('/profile/' . $config->get('system', 'singleuser'));
|
DI::baseUrl()->redirect('/profile/' . $config->get('system', 'singleuser'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -254,7 +254,7 @@ class HttpClient implements ICanSendHttpRequests
|
||||||
$urlResult = $this->resolver->resolveURL($url);
|
$urlResult = $this->resolver->resolveURL($url);
|
||||||
|
|
||||||
if ($urlResult->didErrorOccur()) {
|
if ($urlResult->didErrorOccur()) {
|
||||||
throw new TransferException($urlResult->getErrorMessageString(), $urlResult->getHTTPStatusCode());
|
throw new TransferException($urlResult->getErrorMessageString(), $urlResult->getHTTPStatusCode() ?? 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $urlResult->getURL();
|
return $urlResult->getURL();
|
||||||
|
|
|
@ -3638,7 +3638,7 @@ class Diaspora
|
||||||
|
|
||||||
Logger::info('Got relayable data ' . $type . ' for item ' . $item['guid'] . ' (' . $item['id'] . ')');
|
Logger::info('Got relayable data ' . $type . ' for item ' . $item['guid'] . ' (' . $item['id'] . ')');
|
||||||
|
|
||||||
$msg = json_decode($item['signed_text'], true);
|
$msg = json_decode($item['signed_text'] ?? '', true);
|
||||||
|
|
||||||
$message = [];
|
$message = [];
|
||||||
if (is_array($msg)) {
|
if (is_array($msg)) {
|
||||||
|
|
|
@ -81,7 +81,7 @@ final class FriendicaSmartyEngine extends TemplateEngine
|
||||||
|
|
||||||
// "middleware": inject variables into templates
|
// "middleware": inject variables into templates
|
||||||
$arr = [
|
$arr = [
|
||||||
'template' => basename($this->smarty->filename),
|
'template' => basename($this->smarty->filename ?? ''),
|
||||||
'vars' => $vars
|
'vars' => $vars
|
||||||
];
|
];
|
||||||
Hook::callAll('template_vars', $arr);
|
Hook::callAll('template_vars', $arr);
|
||||||
|
|
|
@ -336,7 +336,7 @@ class Notifier
|
||||||
foreach ($items as $item) {
|
foreach ($items as $item) {
|
||||||
$recipients[] = $item['contact-id'];
|
$recipients[] = $item['contact-id'];
|
||||||
// pull out additional tagged people to notify (if public message)
|
// pull out additional tagged people to notify (if public message)
|
||||||
if ($public_message && strlen($item['inform'])) {
|
if ($public_message && $item['inform']) {
|
||||||
$people = explode(',',$item['inform']);
|
$people = explode(',',$item['inform']);
|
||||||
foreach ($people as $person) {
|
foreach ($people as $person) {
|
||||||
if (substr($person,0,4) === 'cid:') {
|
if (substr($person,0,4) === 'cid:') {
|
||||||
|
|
|
@ -132,16 +132,16 @@ class Color {
|
||||||
|
|
||||||
$var_1 = 2 * $L - $var_2;
|
$var_1 = 2 * $L - $var_2;
|
||||||
|
|
||||||
$r = round(255 * self::_huetorgb( $var_1, $var_2, $H + (1/3) ));
|
$r = 255 * self::_huetorgb( $var_1, $var_2, $H + (1/3) );
|
||||||
$g = round(255 * self::_huetorgb( $var_1, $var_2, $H ));
|
$g = 255 * self::_huetorgb( $var_1, $var_2, $H );
|
||||||
$b = round(255 * self::_huetorgb( $var_1, $var_2, $H - (1/3) ));
|
$b = 255 * self::_huetorgb( $var_1, $var_2, $H - (1/3) );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convert to hex
|
// Convert to hex
|
||||||
$r = dechex($r);
|
$r = dechex(round($r));
|
||||||
$g = dechex($g);
|
$g = dechex(round($g));
|
||||||
$b = dechex($b);
|
$b = dechex(round($b));
|
||||||
|
|
||||||
// Make sure we get 2 digits for decimals
|
// Make sure we get 2 digits for decimals
|
||||||
$r = (strlen("".$r)===1) ? "0".$r:$r;
|
$r = (strlen("".$r)===1) ? "0".$r:$r;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user