Skip to content
This repository was archived by the owner on Oct 15, 2025. It is now read-only.

Commit 4a2cdd0

Browse files
author
Flo Faber
committed
Fixed DB::read_picture and DB::get_picture returning false when they shoudln't
1 parent cf0b176 commit 4a2cdd0

2 files changed

Lines changed: 11 additions & 3 deletions

File tree

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## v1.2.1
4+
5+
### Fixes
6+
* Fixed DB::get_picture and DB::read_picture incorrectly returning false when file did not contain an image.
7+
8+
39
## v1.2.0
410

511
### Improvements

src/DB.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -226,8 +226,7 @@ public function get_picture(string $uri, bool $include_binary = true)
226226
do{
227227

228228
$picture_data = $this->mphpd->cmd("readpicture", [$uri, $offset]);
229-
if($picture_data === false){ return false; }
230-
if(!isset($picture_data["size"])){ return [ "size" => 0, "type" => null, "binary" => null ]; }
229+
if($picture_data === false){ return [ "size" => 0, "type" => null, "binary" => null ]; }
231230

232231
$size = $picture_data["size"];
233232
$type = $picture_data["type"];
@@ -253,7 +252,10 @@ public function get_picture(string $uri, bool $include_binary = true)
253252
*/
254253
public function read_picture(string $uri)
255254
{
256-
return $this->get_picture($uri, true)["binary"] ?? false;
255+
$gp = $this->get_picture($uri, true);
256+
if($gp === false){ return false; }
257+
if($gp["binary"] === null){ return ""; }
258+
return $gp["binary"];
257259
}
258260

259261

0 commit comments

Comments
 (0)