From 428f9686c4171912ee186ebd919640a7427da768 Mon Sep 17 00:00:00 2001 From: Andre Klapper Date: Wed, 27 Dec 2023 17:38:40 +0100 Subject: [PATCH] Composing a custom project picture: Remove misaligned empty icon Summary: Do not assume that all items under `/resources/builtin/projects/` are image files (some can be subdirectories). Only add PNG files to the map. Could be nicer to use `is_file()` or `is_dir()` but we are dealing only with string representations of files and folders. Closes T15696 Test Plan: Go to `/project/picture/1/` and click the `Choose Icon and Color...` button; check last icon shown under "Choose Icon". Reviewers: O1 Blessed Committers, valerio.bozzolan Reviewed By: O1 Blessed Committers, valerio.bozzolan Subscribers: tobiaswiese, valerio.bozzolan, Matthew, Cigaryno Maniphest Tasks: T15696 Differential Revision: https://we.phorge.it/D25499 --- .../PhabricatorFilesComposeIconBuiltinFile.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/applications/files/builtin/PhabricatorFilesComposeIconBuiltinFile.php b/src/applications/files/builtin/PhabricatorFilesComposeIconBuiltinFile.php index 0bb56490cc..ac16ba7f6b 100644 --- a/src/applications/files/builtin/PhabricatorFilesComposeIconBuiltinFile.php +++ b/src/applications/files/builtin/PhabricatorFilesComposeIconBuiltinFile.php @@ -51,12 +51,14 @@ final class PhabricatorFilesComposeIconBuiltinFile $map = array(); $list = Filesystem::listDirectory($root, $include_hidden = false); foreach ($list as $file) { - $short = preg_replace('/\.png$/', '', $file); - - $map[$short] = array( - 'path' => $root.$file, - 'quip' => idx($quips, $short, $short), - ); + $count = 0; + $short = preg_replace('/\.png$/', '', $file, -1, $count); + if ($count === 1) { + $map[$short] = array( + 'path' => $root.$file, + 'quip' => idx($quips, $short, $short), + ); + } } return $map;