From 68393d2cf2a5d8053b4aa796b8dbf3b9521229eb Mon Sep 17 00:00:00 2001 From: Alexander Rosenberg Date: Sun, 15 Sep 2024 02:39:19 -0700 Subject: [PATCH] Fix more bugs --- root/Album.php | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/root/Album.php b/root/Album.php index 5dc7271..7415f1c 100644 --- a/root/Album.php +++ b/root/Album.php @@ -38,10 +38,8 @@ class Album { $this->thumbnail = $root->{'thumbnail'}; $this->images = $root->{'images'}; if (property_exists($root, 'metadata')) { - $this->metadata = $root->{'metadata'}; - } else { - $this->metadata = null; - } + $this->metadata; + } } private function invalidate() { @@ -129,12 +127,27 @@ class Album { 'longitude' => '' ]; } - $description = $this->metadata->{$image}->{'description'}; - $date = $this->metadata->{$image}->{'date'}; - $time = $this->metadata->{$image}->{'time'}; - $lat= $this->metadata->{$image}->{'latitude'}; - $lon = $this->metadata->{$image}->{'longitude'}; - if (preg_match($this::NUMBER_REGEX, $lat) === false || preg_match($this::NUMBER_REGEX, $lon) === false) { + $description = null; + $date = null; + $time = null; + $lat = null; + $lon = null; + if (property_exists($this->metadata->{$image}, 'description')) { + $description = $this->metadata->{$image}?->{'description'}; + } + if (property_exists($this->metadata->{$image}, 'date')) { + $date = $this->metadata->{$image}?->{'date'}; + } + if (property_exists($this->metadata->{$image}, 'time')) { + $time = $this->metadata->{$image}?->{'time'}; + } + if (property_exists($this->metadata->{$image}, 'latitude')) { + $lat= $this->metadata->{$image}?->{'latitude'}; + } + if (property_exists($this->metadata->{$image}, 'longitude')) { + $lon = $this->metadata->{$image}?->{'longitude'}; + } + if ($lat && $lon && (preg_match($this::NUMBER_REGEX, $lat) === false || preg_match($this::NUMBER_REGEX, $lon) === false)) { $lat = null; $lon = null; }