Add return type never, fix more errors

This commit is contained in:
Art4 2024-11-17 22:55:42 +00:00
parent 12ed714a9e
commit 24f75cd618
5 changed files with 26 additions and 5 deletions

View file

@ -103,6 +103,8 @@ class BaseURL extends Uri implements UriInterface
* @throws HTTPException\TemporaryRedirectException * @throws HTTPException\TemporaryRedirectException
* *
* @throws HTTPException\InternalServerErrorException In Case the given URL is not relative to the Friendica node * @throws HTTPException\InternalServerErrorException In Case the given URL is not relative to the Friendica node
*
* @return never
*/ */
public function redirect(string $toUrl = '', bool $ssl = false) public function redirect(string $toUrl = '', bool $ssl = false)
{ {

View file

@ -393,6 +393,8 @@ class System
/** /**
* Exit the program execution. * Exit the program execution.
*
* @return never
*/ */
public static function exit() public static function exit()
{ {
@ -506,6 +508,8 @@ class System
* @throws TemporaryRedirectException * @throws TemporaryRedirectException
* *
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*
* @return never
*/ */
public static function externalRedirect($url, $code = 302) public static function externalRedirect($url, $code = 302)
{ {

View file

@ -143,6 +143,8 @@ class Photo extends BaseApi
$cacheable = ($photo['allow_cid'] . $photo['allow_gid'] . $photo['deny_cid'] . $photo['deny_gid'] === '') && (isset($photo['cacheable']) ? $photo['cacheable'] : true); $cacheable = ($photo['allow_cid'] . $photo['allow_gid'] . $photo['deny_cid'] . $photo['deny_gid'] === '') && (isset($photo['cacheable']) ? $photo['cacheable'] : true);
$stamp = microtime(true); $stamp = microtime(true);
$imgdata = '';
$mimetype = false;
if (empty($request['blur']) || empty($photo['blurhash'])) { if (empty($request['blur']) || empty($photo['blurhash'])) {
$imgdata = MPhoto::getImageDataForPhoto($photo); $imgdata = MPhoto::getImageDataForPhoto($photo);
@ -150,7 +152,9 @@ class Photo extends BaseApi
} }
if (empty($imgdata) && empty($photo['blurhash'])) { if (empty($imgdata) && empty($photo['blurhash'])) {
throw new HTTPException\NotFoundException(); throw new HTTPException\NotFoundException();
} elseif (empty($imgdata) && !empty($photo['blurhash'])) { }
if (empty($imgdata) && !empty($photo['blurhash'])) {
$image = new Image('', image_type_to_mime_type(IMAGETYPE_WEBP)); $image = new Image('', image_type_to_mime_type(IMAGETYPE_WEBP));
$image->getFromBlurHash($photo['blurhash'], $photo['width'], $photo['height']); $image->getFromBlurHash($photo['blurhash'], $photo['width'], $photo['height']);
$imgdata = $image->asString(); $imgdata = $image->asString();
@ -376,6 +380,9 @@ class Photo extends BaseApi
Logger::debug('Expected Content-Type', ['mime' => $mimetext, 'url' => $url]); Logger::debug('Expected Content-Type', ['mime' => $mimetext, 'url' => $url]);
} }
} }
$url = '';
if (empty($mimetext) && !empty($contact['blurhash'])) { if (empty($mimetext) && !empty($contact['blurhash'])) {
$image = new Image('', image_type_to_mime_type(IMAGETYPE_WEBP)); $image = new Image('', image_type_to_mime_type(IMAGETYPE_WEBP));
$image->getFromBlurHash($contact['blurhash'], $customsize, $customsize); $image->getFromBlurHash($contact['blurhash'], $customsize, $customsize);

View file

@ -78,7 +78,7 @@ class Remove extends \Friendica\BaseModule
$tag_text = Tag::getCSVByURIId($item['uri-id']); $tag_text = Tag::getCSVByURIId($item['uri-id']);
$tags = explode(',', $tag_text); $tags = explode(',', $tag_text);
if (empty($tags)) { if (!is_array($tags)) {
$this->baseUrl->redirect($returnUrl); $this->baseUrl->redirect($returnUrl);
} }

View file

@ -125,6 +125,10 @@ class Photos extends \Friendica\Module\BaseProfile
} }
$ret = ['src' => '', 'filename' => '', 'filesize' => 0, 'type' => '']; $ret = ['src' => '', 'filename' => '', 'filesize' => 0, 'type' => ''];
$src = null;
$filename = '';
$filesize = 0;
$type = '';
Hook::callAll('photo_post_file', $ret); Hook::callAll('photo_post_file', $ret);
@ -164,7 +168,11 @@ class Photos extends \Friendica\Module\BaseProfile
$this->systemMessages->addNotice($this->t('Server can\'t accept new file upload at this time, please contact your administrator')); $this->systemMessages->addNotice($this->t('Server can\'t accept new file upload at this time, please contact your administrator'));
break; break;
} }
if ($src !== null) {
@unlink($src); @unlink($src);
}
$foo = 0; $foo = 0;
Hook::callAll('photo_post_end', $foo); Hook::callAll('photo_post_end', $foo);
return; return;