]> git.mxchange.org Git - friendica.git/commitdiff
Move contact deleted check from RemoveContent to Remove task
authorHypolite Petovan <hypolite@mrpetovan.com>
Wed, 20 Oct 2021 13:43:43 +0000 (09:43 -0400)
committerHypolite Petovan <hypolite@mrpetovan.com>
Wed, 3 Nov 2021 20:02:20 +0000 (16:02 -0400)
src/Worker/Contact/Remove.php
src/Worker/Contact/RemoveContent.php

index a3378fd5aa1248391408d485da52492eca5961ea..4510e575e27203d242ef642c4cf0222d235fbbd3 100644 (file)
@@ -29,19 +29,21 @@ use Friendica\Database\DBA;
  */
 class Remove extends RemoveContent
 {
-       public static function execute(int $id): array
+       public static function execute(int $id): bool
        {
-               $contact = parent::execute($id);
+               // Only delete if the contact is to be deleted
+               $contact = DBA::selectFirst('contact', ['id', 'uid', 'url', 'nick', 'name'], ['deleted' => true, 'id' => $id]);
+               if (!DBA::isResult($contact)) {
+                       return false;
+               }
 
-               if (!empty($contact)) {
-                       return [];
+               if (!parent::execute($id)) {
+                       return false;
                }
 
                $ret = DBA::delete('contact', ['id' => $id]);
                Logger::info('Deleted contact', ['id' => $id, 'result' => $ret]);
 
-               $contact['id'] = null;
-
-               return $contact;
+               return true;
        }
 }
index cdb32141120d8c7624e4cd8876aa21eaacf6d96e..615a47be10252fb0ea679fca936f1f4806d1ea19 100644 (file)
@@ -33,19 +33,13 @@ use Friendica\Model\Post;
  */
 class RemoveContent
 {
-       public static function execute(int $id): array
+       public static function execute(int $id): bool
        {
                if (empty($id)) {
-                       return [];
+                       return false;
                }
 
-               // Only delete if the contact is to be deleted
-               $contact = DBA::selectFirst('contact', ['id', 'uid', 'url', 'nick', 'name'], ['deleted' => true, 'id' => $id]);
-               if (!DBA::isResult($contact)) {
-                       return [];
-               }
-
-               Logger::info('Start deleting contact content', ['contact' => $contact]);
+               Logger::info('Start deleting contact content', ['cid' => $id]);
 
                // Now we delete the contact and all depending tables
                DBA::delete('post-tag', ['cid' => $id]);
@@ -87,6 +81,6 @@ class RemoveContent
                DBA::delete('group_member', ['contact-id' => $id]);
                DI::intro()->delete(DI::introFactory()->createDummy($id));
 
-               return $contact;
+               return true;
        }
 }