Skip to content

Commit

Permalink
Small fixes in preparation for new phpstan
Browse files Browse the repository at this point in the history
  • Loading branch information
shish committed Jan 29, 2025
1 parent 45b9002 commit 5dfb7fd
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 13 deletions.
8 changes: 5 additions & 3 deletions core/imageboard/image.php
Original file line number Diff line number Diff line change
Expand Up @@ -345,22 +345,24 @@ public function save_to_db(): void
/**
* Get this image's tags as an array.
*
* @return list<string>
* @return array<string>
*/
#[Field(name: "tags", type: "[string!]!")]
public function get_tag_array(): array
{
global $database;
if (!isset($this->tag_array)) {
$this->tag_array = $database->get_col("
$tarr = $database->get_col("
SELECT tag
FROM image_tags
JOIN tags ON image_tags.tag_id = tags.id
WHERE image_id=:id
ORDER BY tag
", ["id" => $this->id]);
sort($this->tag_array);
sort($tarr);
$this->tag_array = $tarr;
}
assert(is_array($this->tag_array));
return $this->tag_array;
}

Expand Down
15 changes: 5 additions & 10 deletions ext/bulk_add_csv/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,23 +87,18 @@ private function add_csv(string $csvfile): void
$list = "";
$csvhandle = \Safe\fopen($csvfile, "r");

while (($csvdata = fgetcsv($csvhandle, 0, ",")) !== false) {
while (($csvdata = \Safe\fgetcsv($csvhandle, 0, ",")) !== false) {
if (count($csvdata) != 5) {
if (strlen($list) > 0) {
$this->theme->add_status("Error", "<b>Encountered malformed data. Line $linenum $csvfile</b><br>".$list);
fclose($csvhandle);
return;
} else {
$this->theme->add_status("Error", "<b>Encountered malformed data. Line $linenum $csvfile</b><br>Check <a href=\"" . make_link("ext_doc/bulk_add_csv") . "\">here</a> for the expected format");
fclose($csvhandle);
return;
}
fclose($csvhandle);
return;
}
$fullpath = $csvdata[0];
$tags = Tag::explode(trim($csvdata[1]));
$source = $csvdata[2];
$rating = $csvdata[3];
$thumbfile = $csvdata[4];
[$fullpath, $tags_string, $source, $rating, $thumbfile] = $csvdata;
$tags = Tag::explode(trim($tags_string));
$shortpath = pathinfo($fullpath, PATHINFO_BASENAME);
$list .= "<br>".html_escape("$shortpath (".implode(", ", $tags).")... ");
if (file_exists($csvdata[0]) && is_file($csvdata[0])) {
Expand Down
1 change: 1 addition & 0 deletions ext/handle_video/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ protected function media_check_properties(MediaCheckPropertiesEvent $event): voi
$event->image->video_codec = $video_codec;
$event->image->audio = $audio;
if ($event->image->get_mime() == MimeType::MKV &&
$event->image->video_codec != null &&
VideoContainers::is_video_codec_supported(VideoContainers::WEBM, $event->image->video_codec)) {
// WEBMs are MKVs with the VP9 or VP8 codec
// For browser-friendliness, we'll just change the mime type
Expand Down

0 comments on commit 5dfb7fd

Please sign in to comment.