From 0904368d95ac5a218086807029c5ab461c1c8494 Mon Sep 17 00:00:00 2001 From: Marco Gulino Date: Mon, 7 Nov 2022 21:54:05 +0000 Subject: [PATCH] Fix null pointer crash when final is not set --- CHANGELOG.md | 7 +++++++ blueprints.yaml | 2 +- classes/Image.php | 9 +++++---- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b200529..3250eac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +# v1.0.9 +## 07/11/2022 + +1. [](#bugfix) + * Fix null pointer when no revision is marked as final + + # v1.0.8 ## 18/10/2022 diff --git a/blueprints.yaml b/blueprints.yaml index fed0d23..44bc897 100644 --- a/blueprints.yaml +++ b/blueprints.yaml @@ -1,5 +1,5 @@ name: Astrobin -version: 1.0.8 +version: 1.0.9 description: "This plugin provides astrobin shortcodes for images and galleries" icon: picture-o author: diff --git a/classes/Image.php b/classes/Image.php index a6d8835..f34a21e 100644 --- a/classes/Image.php +++ b/classes/Image.php @@ -20,6 +20,7 @@ public function __construct($info, $api) $revision_obj = $api->request($revision, [], false); array_push($this->revisions, $revision_obj); } + // $this->grav['log']->info(print_r($this->revisions, true)); // dump($this); } @@ -60,11 +61,11 @@ public function url($format, $revision_type="final", $animated=false) { } } - if(is_null($revision_obj)) { - $revision_obj = $this->revisions[0]; - } + + } + if(is_null($revision_obj)) { + $revision_obj = $this->revisions[0]; } - // dump($revision_obj); $url = $revision_obj->{'url_' . $format}; if($animated) { $url .= '?animated';