]> git.mxchange.org Git - friendica.git/commitdiff
Partially revert changes for the RC
authorMichael <heluecht@pirati.ca>
Sun, 9 Jan 2022 15:45:14 +0000 (15:45 +0000)
committerMichael <heluecht@pirati.ca>
Sun, 9 Jan 2022 15:45:14 +0000 (15:45 +0000)
include/api.php
src/Model/User.php
src/Util/Images.php
static/dbstructure.config.php
update.php

index 9e8b3dd33692cc1b71dc1ae19677eb2114ad9505..7914b4dbd612fee42f4e31d74acf43a577217e0a 100644 (file)
@@ -34,6 +34,7 @@ use Friendica\Model\Photo;
 use Friendica\Model\Post;
 use Friendica\Module\BaseApi;
 use Friendica\Network\HTTPException;
+use Friendica\Util\Images;
 
 $API = [];
 
@@ -162,12 +163,6 @@ function prepare_photo_data($type, $scale, $photo_id, $uid)
                $photo_id
        ));
 
-       $typetoext = [
-               'image/jpeg' => 'jpg',
-               'image/png' => 'png',
-               'image/gif' => 'gif'
-       ];
-
        // prepare output data for photo
        if (DBA::isResult($r)) {
                $data = ['photo' => $r[0]];
@@ -182,14 +177,14 @@ function prepare_photo_data($type, $scale, $photo_id, $uid)
                        for ($k = intval($data['photo']['minscale']); $k <= intval($data['photo']['maxscale']); $k++) {
                                $data['photo']['links'][$k . ":link"]["@attributes"] = ["type" => $data['photo']['type'],
                                                                                "scale" => $k,
-                                                                               "href" => DI::baseUrl() . "/photo/" . $data['photo']['resource-id'] . "-" . $k . "." . $typetoext[$data['photo']['type']]];
+                                                                               "href" => DI::baseUrl() . "/photo/" . $data['photo']['resource-id'] . "-" . $k . "." . Images::getExtensionByMimeType($data['photo']['type'])];
                        }
                } else {
                        $data['photo']['link'] = [];
                        // when we have profile images we could have only scales from 4 to 6, but index of array always needs to start with 0
                        $i = 0;
                        for ($k = intval($data['photo']['minscale']); $k <= intval($data['photo']['maxscale']); $k++) {
-                               $data['photo']['link'][$i] = DI::baseUrl() . "/photo/" . $data['photo']['resource-id'] . "-" . $k . "." . $typetoext[$data['photo']['type']];
+                               $data['photo']['link'][$i] = DI::baseUrl() . "/photo/" . $data['photo']['resource-id'] . "-" . $k . "." . Images::getExtensionByMimeType($data['photo']['type']);
                                $i++;
                        }
                }
@@ -331,11 +326,7 @@ function api_fr_photos_list($type)
                WHERE `uid` = ? AND NOT `photo-type` IN (?, ?) GROUP BY `resource-id`, `album`, `filename`, `type`",
                $uid, Photo::CONTACT_AVATAR, Photo::CONTACT_BANNER
        ));
-       $typetoext = [
-               'image/jpeg' => 'jpg',
-               'image/png' => 'png',
-               'image/gif' => 'gif'
-       ];
+
        $data = ['photo'=>[]];
        if (DBA::isResult($r)) {
                foreach ($r as $rr) {
@@ -344,7 +335,7 @@ function api_fr_photos_list($type)
                        $photo['album'] = $rr['album'];
                        $photo['filename'] = $rr['filename'];
                        $photo['type'] = $rr['type'];
-                       $thumb = DI::baseUrl() . "/photo/" . $rr['resource-id'] . "-" . $rr['scale'] . "." . $typetoext[$rr['type']];
+                       $thumb = DI::baseUrl() . "/photo/" . $rr['resource-id'] . "-" . $rr['scale'] . "." . Images::getExtensionByMimeType($rr['type']);
                        $photo['created'] = $rr['created'];
                        $photo['edited'] = $rr['edited'];
                        $photo['desc'] = $rr['desc'];
index ccc9261fd22e4168c99acaa01d17cd4bd92f4dae..d99588e05bb74246e779805291debec4c28b0140 100644 (file)
@@ -890,6 +890,9 @@ class User
                        if (in_array($photo['type'], ['image/png', 'image/gif'])) {
                                $imagetype = IMAGETYPE_PNG;
                        }
+               } else {
+                       // Only for the RC phase: Don't return an image link for the default picture
+                       return '';
                }
 
                return $url . $user['nickname'] . image_type_to_extension($imagetype) . ($updated ? '?ts=' . strtotime($updated) : '');
index cd4704dcee068018ec0f1a4c4b8a701930e257f6..997f3c6f9dee66ea74223a282f8c6367a9a055f4 100644 (file)
@@ -46,6 +46,30 @@ class Images
                return $m;
        }
 
+       /**
+        * Return file extension for mime type
+        * @param string $mimetype
+        * @return string
+        */
+       public static function getExtensionByMimeType(string $mimetype): string
+       {
+               switch ($mimetype) {
+                       case 'image/png':
+                               $imagetype = IMAGETYPE_PNG;
+                               break;
+
+                       case 'image/gif':
+                               $imagetype = IMAGETYPE_GIF;
+                               break;
+
+                       default:
+                               $imagetype = IMAGETYPE_JPC;
+                               break;
+               }
+
+               return image_type_to_extension($imagetype);
+       }
+
        /**
         * Returns supported image mimetypes and corresponding file extensions
         *
index 39481348e215184486f0db3bccddea538fea2266..ca52dace8b0a29441701a4da9c31fd4354fa009f 100644 (file)
@@ -55,7 +55,7 @@
 use Friendica\Database\DBA;
 
 if (!defined('DB_UPDATE_VERSION')) {
-       define('DB_UPDATE_VERSION', 1449);
+       define('DB_UPDATE_VERSION', 1448);
 }
 
 return [
index ed5962cf1f1e8230359a8b8df5586df6fe624b71..7b5f6778be7df92807978de0e88126016fa10e9f 100644 (file)
@@ -1087,16 +1087,3 @@ function update_1446()
 
        return Update::SUCCESS;
 }
-
-function update_1449()
-{
-       $users = DBA::select('user', ['uid']);
-       while ($user = DBA::fetch($users)) {
-               if (Contact::updateSelfFromUserID($user['uid'])) {
-                       Profile::publishUpdate($user['uid']);
-               }
-       }
-       DBA::close($users);
-
-       return Update::SUCCESS;
-}