]> git.mxchange.org Git - friendica.git/commitdiff
Ensure to never delete the "0" user
authorMichael <heluecht@pirati.ca>
Wed, 18 Nov 2020 05:24:04 +0000 (05:24 +0000)
committerMichael <heluecht@pirati.ca>
Wed, 18 Nov 2020 05:24:04 +0000 (05:24 +0000)
src/Database/DBStructure.php
src/Worker/ExpireAndRemoveUsers.php

index 143526c0382a5f9007d768fc0f023c01bfb0885e..dbe68aca1651a9ddcc063219eefd950349cb4cb7 100644 (file)
@@ -1058,7 +1058,12 @@ class DBStructure
                        DBA::insert('user', ['uid' => 0]);
                        $lastid = DBA::lastInsertId();
                        if ($lastid != 0) {
-                               DBA::update('user', ['uid' => 0], ['uid' => $lastid]);
+                               $user = [
+                                       "verified" => true,
+                                       "page-flags" => User::PAGE_FLAGS_SOAPBOX,
+                                       "account-type" => User::ACCOUNT_TYPE_RELAY,
+                               ];
+                               DBA::update('user', $user, ['uid' => $lastid]);
                        }
                }
 
index c8344b6fd956cba4b5d3f11b8d7f71333112ce95..f28f410b965e24af141810281ec9f879f622fe99 100644 (file)
@@ -33,9 +33,14 @@ class ExpireAndRemoveUsers
        public static function execute()
        {
                // expire any expired regular accounts. Don't expire forums.
-               $condition = ["NOT `account_expired` AND `account_expires_on` > ? AND `account_expires_on` < UTC_TIMESTAMP() AND `page-flags` = 0", DBA::NULL_DATETIME];
+               $condition = ["NOT `account_expired` AND `account_expires_on` > ? AND `account_expires_on` < UTC_TIMESTAMP() AND `page-flags` = ? AND `uid` != ?",
+                       DBA::NULL_DATETIME, User::PAGE_FLAGS_NORMAL, 0];
                DBA::update('user', ['account_expired' => true], $condition);
 
+               // Ensure to never remove the user with uid=0
+               DBA::update('user', ['account_expired' => false, 'account_removed' => false,
+                       'account_expires_on' => DBA::NULL_DATETIME], ['uid' => 0]);
+
                // Remove any freshly expired account
                $users = DBA::select('user', ['uid'], ['account_expired' => true, 'account_removed' => false]);
                while ($user = DBA::fetch($users)) {