]> git.mxchange.org Git - friendica.git/blobdiff - src/Protocol/DFRN.php
Merge pull request #9655 from MrPetovan/bug/fatal-errors
[friendica.git] / src / Protocol / DFRN.php
index 22a889a85132533bc193f310300324091c943f0b..71ae052eb649dc0289c534296e2410ff2dc1b88a 100644 (file)
@@ -2199,13 +2199,13 @@ class DFRN
         * @throws \ImagickException
         * @todo  Add type-hints
         */
-       private static function processEntry($header, $xpath, $entry, $importer, $xml)
+       private static function processEntry($header, $xpath, $entry, $importer, $xml, $protocol)
        {
                Logger::log("Processing entries");
 
                $item = $header;
 
-               $item["protocol"] = Conversation::PARCEL_DFRN;
+               $item["protocol"] = $protocol;
 
                $item["source"] = $xml;
 
@@ -2601,7 +2601,7 @@ class DFRN
         * @throws \ImagickException
         * @todo  set proper type-hints
         */
-       public static function import($xml, $importer, $sort_by_date = false)
+       public static function import($xml, $importer, $sort_by_date = false, $protocol = Conversation::PARCEL_DFRN)
        {
                if ($xml == "") {
                        return 400;
@@ -2705,14 +2705,20 @@ class DFRN
                }
 
                $deletions = $xpath->query("/atom:feed/at:deleted-entry");
-               foreach ($deletions as $deletion) {
-                       self::processDeletion($xpath, $deletion, $importer);
+               if (!empty($deletions)) {
+                       foreach ($deletions as $deletion) {
+                               self::processDeletion($xpath, $deletion, $importer);
+                       }
+                       if (count($deletions) > 0) {
+                               Logger::notice('Deletions had been processed');
+                               return 200;
+                       }
                }
 
                if (!$sort_by_date) {
                        $entries = $xpath->query("/atom:feed/atom:entry");
                        foreach ($entries as $entry) {
-                               self::processEntry($header, $xpath, $entry, $importer, $xml);
+                               self::processEntry($header, $xpath, $entry, $importer, $xml, $protocol);
                        }
                } else {
                        $newentries = [];
@@ -2726,7 +2732,7 @@ class DFRN
                        ksort($newentries);
 
                        foreach ($newentries as $entry) {
-                               self::processEntry($header, $xpath, $entry, $importer, $xml);
+                               self::processEntry($header, $xpath, $entry, $importer, $xml, $protocol);
                        }
                }
                Logger::log("Import done for user " . $importer["importer_uid"] . " from contact " . $importer["id"], Logger::DEBUG);