]> git.mxchange.org Git - friendica.git/blobdiff - update.php
Remove deprecated, impossible code for discarding with FID
[friendica.git] / update.php
index 49287cd0b2a86205a9c944d4f36047fb4b0692bc..85f407d36ce223e1a2d222f967bbf7a1918638ed 100644 (file)
@@ -55,6 +55,7 @@ use Friendica\Model\Photo;
 use Friendica\Model\Post;
 use Friendica\Model\Profile;
 use Friendica\Model\Storage;
+use Friendica\Security\PermissionSet\Depository\PermissionSet;
 use Friendica\Worker\Delivery;
 
 // Post-update script of PR 5751
@@ -192,8 +193,8 @@ function update_1330()
        }
 
        // Update attachments and photos
-       if (!DBA::p("UPDATE `photo` SET `photo`.`backend-class` = SUBSTR(`photo`.`backend-class`, 25) WHERE `photo`.`backend-class` LIKE 'Friendica\\\Model\\\Storage\\\%' ESCAPE '|'") ||
-           !DBA::p("UPDATE `attach` SET `attach`.`backend-class` = SUBSTR(`attach`.`backend-class`, 25) WHERE `attach`.`backend-class` LIKE 'Friendica\\\Model\\\Storage\\\%' ESCAPE '|'")) {
+       if (!DBA::e("UPDATE `photo` SET `photo`.`backend-class` = SUBSTR(`photo`.`backend-class`, 25) WHERE `photo`.`backend-class` LIKE 'Friendica\\\Model\\\Storage\\\%' ESCAPE '|'") ||
+           !DBA::e("UPDATE `attach` SET `attach`.`backend-class` = SUBSTR(`attach`.`backend-class`, 25) WHERE `attach`.`backend-class` LIKE 'Friendica\\\Model\\\Storage\\\%' ESCAPE '|'")) {
                return Update::FAILED;
        };
 
@@ -206,7 +207,7 @@ function update_1332()
        $profiles = DBA::select('profile', [], $condition);
 
        while ($profile = DBA::fetch($profiles)) {
-               DI::profileField()->migrateFromLegacyProfile($profile);
+               Profile::migrate($profile);
        }
        DBA::close($profiles);
 
@@ -1005,4 +1006,58 @@ function update_1435()
        while ($contact = DBA::fetch($contacts)) {
                Contact\User::insertForContactArray($contact);
        }
-}
\ No newline at end of file
+}
+
+function update_1438()
+{
+       DBA::update('photo', ['photo-type' => Photo::USER_AVATAR], ['profile' => true]);
+       DBA::update('photo', ['photo-type' => Photo::CONTACT_AVATAR], ["NOT `profile` AND NOT `contact-id` IS NULL AND `contact-id` != ?", 0]);
+       DBA::update('photo', ['photo-type' => Photo::DEFAULT], ["NOT `profile` AND (`contact-id` IS NULL OR `contact-id` = ?) AND `photo-type` IS NULL AND `album` != ?", 0, Photo::CONTACT_PHOTOS]);
+}
+
+function update_1439()
+{
+       $intros = DBA::select('intro', ['id', 'fid'], ["NOT `fid` IS NULL AND `fid` != ?", 0]);
+       while ($intro = DBA::fetch($intros)) {
+               $fcontact = DBA::selectFirst('fcontact', ['url'], ['id' => $intro['fid']]);
+               if (!empty($fcontact['url'])) {
+                       $id = Contact::getIdForURL($fcontact['url']);
+                       if (!empty($id)) {
+                               DBA::update('intro',['suggest-cid' => $id], ['id' => $intro['id']]);
+                       }
+               }
+       }
+       DBA::close($intros);
+}
+
+function update_1440()
+{
+       // Fix wrong public permissionset
+       DBA::p("UPDATE `profile_field` SET `psid` = ? WHERE psid IN (SELECT `id` FROM `permissionset` WHERE `id` != ? AND `allow_cid` = '' AND `allow_gid` = '' AND `deny_cid` = '' AND `deny_gid` = '')", PermissionSet::PUBLIC, PermissionSet::PUBLIC);
+       DBA::delete('permissionset', ["`id` != ? AND `allow_cid` = '' AND `allow_gid` = '' AND `deny_cid` = '' AND `deny_gid` = ''", PermissionSet::PUBLIC]);
+
+       return Update::SUCCESS;
+}
+
+function update_1441()
+{
+       $languages = DI::l10n()->getAvailableLanguages();
+
+       $albums = [Photo::PROFILE_PHOTOS];
+       foreach ($languages as $language) {
+               $albums[] = DI::l10n()->withLang($language)->t(Photo::PROFILE_PHOTOS);
+       }
+       $albums = array_unique($albums);
+
+       Photo::update(['photo-type' => Photo::USER_AVATAR], ['album' => $albums]);
+
+       return Update::SUCCESS;
+}
+
+function update_1442()
+{
+       // transform blocked intros into ignored intros
+       DBA::update('intro', ['ignore' => 1, 'blocked' => 0], ['blocked' => 1]);
+
+       return Update::SUCCESS;
+}