]> git.mxchange.org Git - friendica.git/commitdiff
Measures against several warnings and errors in the log
authorMichael <heluecht@pirati.ca>
Tue, 20 Dec 2022 06:22:11 +0000 (06:22 +0000)
committerMichael <heluecht@pirati.ca>
Tue, 20 Dec 2022 06:22:11 +0000 (06:22 +0000)
src/Model/Contact.php
src/Network/Probe.php
src/Object/Image.php
src/Protocol/Diaspora.php

index b703f82a005dd764fdf80d2a8f417f53e5cdfdaf..392f7776154b863f1f1bfe54998907450fd40526 100644 (file)
@@ -1386,14 +1386,18 @@ class Contact
                if ($data['network'] == Protocol::DIASPORA) {
                        try {
                                DI::dsprContact()->updateFromProbeArray($data);
+                       } catch (HTTPException\NotFoundException $e) {
+                               Logger::notice($e->getMessage(), ['url' => $url, 'data' => $data]);
                        } catch (\InvalidArgumentException $e) {
-                               Logger::error($e->getMessage(), ['url' => $url, 'data' => $data]);
+                               Logger::notice($e->getMessage(), ['url' => $url, 'data' => $data]);
                        }
                } elseif (!empty($data['networks'][Protocol::DIASPORA])) {
                        try {
                                DI::dsprContact()->updateFromProbeArray($data['networks'][Protocol::DIASPORA]);
+                       } catch (HTTPException\NotFoundException $e) {
+                               Logger::notice($e->getMessage(), ['url' => $url, 'data' => $data['networks'][Protocol::DIASPORA]]);
                        } catch (\InvalidArgumentException $e) {
-                               Logger::error($e->getMessage(), ['url' => $url, 'data' => $data['networks'][Protocol::DIASPORA]]);
+                               Logger::notice($e->getMessage(), ['url' => $url, 'data' => $data['networks'][Protocol::DIASPORA]]);
                        }
                }
 
@@ -2498,14 +2502,18 @@ class Contact
                if ($data['network'] == Protocol::DIASPORA) {
                        try {
                                DI::dsprContact()->updateFromProbeArray($data);
+                       } catch (HTTPException\NotFoundException $e) {
+                               Logger::notice($e->getMessage(), ['id' => $id, 'network' => $network, 'contact' => $contact, 'data' => $data]);
                        } catch (\InvalidArgumentException $e) {
-                               Logger::error($e->getMessage(), ['id' => $id, 'network' => $network, 'contact' => $contact, 'data' => $data]);
+                               Logger::notice($e->getMessage(), ['id' => $id, 'network' => $network, 'contact' => $contact, 'data' => $data]);
                        }
                } elseif (!empty($data['networks'][Protocol::DIASPORA])) {
                        try {
                                DI::dsprContact()->updateFromProbeArray($data['networks'][Protocol::DIASPORA]);
+                       } catch (HTTPException\NotFoundException $e) {
+                               Logger::notice($e->getMessage(), ['id' => $id, 'network' => $network, 'contact' => $contact, 'data' => $data]);
                        } catch (\InvalidArgumentException $e) {
-                               Logger::error($e->getMessage(), ['id' => $id, 'network' => $network, 'contact' => $contact, 'data' => $data]);
+                               Logger::notice($e->getMessage(), ['id' => $id, 'network' => $network, 'contact' => $contact, 'data' => $data]);
                        }
                }
 
index 5a8f75e2d8cc30820cf63b3b40073c40c6692787..44348dcd7454d505f0a9e5f3f664317d9c3dd344 100644 (file)
@@ -139,8 +139,17 @@ class Probe
                foreach ([Protocol::DIASPORA, Protocol::OSTATUS] as $network) {
                        if (!empty($data['networks'][$network])) {
                                $data['networks'][$network]['subscribe'] = $newdata['subscribe'] ?? '';
-                               $data['networks'][$network]['baseurl'] = $newdata['baseurl'] ?? '';
-                               $data['networks'][$network]['gsid'] = $newdata['gsid'] ?? 0;
+                               if (empty($data['networks'][$network]['baseurl'])) {
+                                       $data['networks'][$network]['baseurl'] = $newdata['baseurl'] ?? '';
+                               } else {
+                                       $newdata['baseurl'] = $data['networks'][$network]['baseurl'];
+                               }
+                               if (!empty($newdata['baseurl'])) {
+                                       $newdata['gsid'] = $data['networks'][$network]['gsid'] = GServer::getID($newdata['baseurl']);
+                               } else {
+                                       $newdata['gsid'] = $data['networks'][$network]['gsid'] = null;
+                               }
+
                                $newdata['networks'][$network] = self::rearrangeData($data['networks'][$network]);
                                unset($newdata['networks'][$network]['networks']);
                        }
index 06498f963fcb859b78d4d96c5381824ddd6b0794..7069f7a47f561aacf53e399ea2ebe829b6ff47c9 100644 (file)
@@ -66,6 +66,7 @@ class Image
                $this->type = $type;
 
                if ($this->isImagick() && (empty($data) || $this->loadData($data))) {
+                       $this->valid = !empty($data);
                        return;
                } else {
                        // Failed to load with Imagick, fallback
@@ -158,12 +159,11 @@ class Image
                                        $this->image->setCompressionQuality($quality);
                        }
 
-                       // The 'width' and 'height' properties are only used by non-Imagick routines.
                        $this->width  = $this->image->getImageWidth();
                        $this->height = $this->image->getImageHeight();
-                       $this->valid  = true;
+                       $this->valid  = !empty($this->image);
 
-                       return true;
+                       return $this->valid;
                }
 
                $this->valid = false;
@@ -210,9 +210,6 @@ class Image
                        return false;
                }
 
-               if ($this->isImagick()) {
-                       return $this->image->getImageWidth();
-               }
                return $this->width;
        }
 
@@ -225,9 +222,6 @@ class Image
                        return false;
                }
 
-               if ($this->isImagick()) {
-                       return $this->image->getImageHeight();
-               }
                return $this->height;
        }
 
@@ -353,6 +347,9 @@ class Image
                        do {
                                $this->image->rotateImage(new ImagickPixel(), -$degrees); // ImageMagick rotates in the opposite direction of imagerotate()
                        } while ($this->image->nextImage());
+
+                       $this->width  = $this->image->getImageWidth();
+                       $this->height = $this->image->getImageHeight();
                        return;
                }
 
@@ -576,7 +573,6 @@ class Image
                                }
                        } while ($this->image->nextImage());
 
-                       // These may not be necessary anymore
                        $this->width  = $this->image->getImageWidth();
                        $this->height = $this->image->getImageHeight();
                } else {
@@ -659,7 +655,7 @@ class Image
                if ($this->image) {
                        imagedestroy($this->image);
                }
-               $this->image = $dest;
+               $this->image  = $dest;
                $this->width  = imagesx($this->image);
                $this->height = imagesy($this->image);
 
@@ -734,7 +730,7 @@ class Image
        public function getBlurHash(): string
        {
                $image = New Image($this->asString());
-               if (empty($image)) {
+               if (empty($image) || !$this->isValid()) {
                        return '';
                }
 
@@ -809,12 +805,14 @@ class Image
 
                if ($this->isImagick()) {
                        $this->image->drawImage($draw);
+                       $this->width  = $this->image->getImageWidth();
+                       $this->height = $this->image->getImageHeight();
                } else {
                        $this->width  = imagesx($this->image);
                        $this->height = imagesy($this->image);
                }
 
-               $this->valid = true;
+               $this->valid = !empty($this->image);
 
                $this->scaleUp(min($width, $height));
        }
index fe5b27d334f313d0b1817ac1bafb46e09b925113..16b0c918e10793e3a1693ce8d8615e4ab6acbba8 100644 (file)
@@ -499,7 +499,7 @@ class Diaspora
                }
 
                if (!($fields = self::validPosting($msg))) {
-                       Logger::warning('Invalid posting', ['msg' => $msg]);
+                       Logger::notice('Invalid posting', ['msg' => $msg]);
                        return false;
                }