From a329033f7d523ee7e729fb600808930df8c84adc Mon Sep 17 00:00:00 2001 From: Angel Fernando Quiroz Campos <1697880+AngelFQC@users.noreply.github.com> Date: Tue, 2 Jul 2024 00:47:31 -0500 Subject: [PATCH] Internal: Validate if theme asset exists - refs BT#21621 --- src/CoreBundle/ServiceHelper/MailHelper.php | 1 - src/CoreBundle/ServiceHelper/ThemeHelper.php | 10 +++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/CoreBundle/ServiceHelper/MailHelper.php b/src/CoreBundle/ServiceHelper/MailHelper.php index 8ff3c5f53f6..19b7f3c702e 100644 --- a/src/CoreBundle/ServiceHelper/MailHelper.php +++ b/src/CoreBundle/ServiceHelper/MailHelper.php @@ -99,7 +99,6 @@ public function send( 'link' => $additionalParameters['link'] ?? '', 'automatic_email_text' => $automaticEmailText, 'content' => $body, - 'theme' => $this->themeHelper->getVisualTheme(), ]; if (!empty($recipientEmail)) { diff --git a/src/CoreBundle/ServiceHelper/ThemeHelper.php b/src/CoreBundle/ServiceHelper/ThemeHelper.php index 6fb71e52802..62354d46376 100644 --- a/src/CoreBundle/ServiceHelper/ThemeHelper.php +++ b/src/CoreBundle/ServiceHelper/ThemeHelper.php @@ -8,6 +8,9 @@ use Chamilo\CoreBundle\Settings\SettingsManager; use Chamilo\CourseBundle\Settings\SettingsCourseManager; +use League\Flysystem\FilesystemException; +use League\Flysystem\FilesystemOperator; +use Symfony\Component\DependencyInjection\Attribute\Autowire; use Symfony\Component\Routing\Generator\UrlGeneratorInterface; use Symfony\Component\Routing\RouterInterface; @@ -22,6 +25,7 @@ public function __construct( private readonly CidReqHelper $cidReqHelper, private readonly SettingsCourseManager $settingsCourseManager, private readonly RouterInterface $router, + #[Autowire(service: 'oneup_flysystem.themes_filesystem')] private readonly FilesystemOperator $filesystem, ) {} /** @@ -71,7 +75,11 @@ public function getThemeAssetUrl(string $path, bool $absolute = false): string { $themeName = $this->getVisualTheme(); - if (empty($themeName)) { + try { + if (!$this->filesystem->fileExists($themeName.DIRECTORY_SEPARATOR.$path)) { + return ''; + } + } catch (FilesystemException) { return ''; }