]> git.mxchange.org Git - friendica.git/commitdiff
Remove items more memory friendly
authorMichael <heluecht@pirati.ca>
Wed, 24 Oct 2018 04:46:45 +0000 (04:46 +0000)
committerMichael <heluecht@pirati.ca>
Wed, 24 Oct 2018 04:46:45 +0000 (04:46 +0000)
src/Worker/RemoveContact.php
src/Worker/RemoveUser.php

index 8f986eab11559c18630315429dd783910dfa9205..8485adda6b5df943a490ff7f910067a5d7e74b44 100644 (file)
@@ -7,6 +7,7 @@ namespace Friendica\Worker;
 
 use Friendica\Database\DBA;
 use Friendica\Core\Protocol;
+use Friendica\Model\Item;
 
 require_once 'include/dba.php';
 
@@ -21,6 +22,15 @@ class RemoveContact {
                }
 
                // Now we delete the contact and all depending tables
+               $condition = ['contact-id' => $id];
+               do {
+                       $items = Item::select(['id'], $condition, ['limit' => 100]);
+                       while ($item = Item::fetch($items)) {
+                               DBA::delete('item', ['id' => $item['id']]);
+                       }
+                       DBA::close($items);
+               } while (Item::exists($condition));
+
                DBA::delete('contact', ['id' => $id]);
        }
 }
index dfa5ccc097c7e9ea14c2c6f66d8488e22ab2e710..d8966e5a491f661c10bf536e799c60dd206f4b53 100644 (file)
@@ -20,6 +20,13 @@ class RemoveUser {
                }
 
                // Now we delete all user items
-               Item::delete(['uid' => $uid], PRIORITY_LOW);
+               $condition = ['uid' => $uid, 'deleted' => false];
+               do {
+                       $items = Item::select(['id'], $condition, ['limit' => 100]);
+                       while ($item = Item::fetch($items)) {
+                               Item::deleteById($item['id'], PRIORITY_LOW);
+                       }
+                       DBA::close($items);
+               } while (Item::exists($condition));
        }
 }