summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--apps/theming/lib/ImageManager.php13
-rw-r--r--apps/theming/tests/ImageManagerTest.php7
-rw-r--r--lib/private/Server.php2
3 files changed, 19 insertions, 3 deletions
diff --git a/apps/theming/lib/ImageManager.php b/apps/theming/lib/ImageManager.php
index 5d7c11b6e4c..dfbdb582da6 100644
--- a/apps/theming/lib/ImageManager.php
+++ b/apps/theming/lib/ImageManager.php
@@ -31,6 +31,7 @@ use OCP\IConfig;
use OCP\Files\IAppData;
use OCP\Files\NotFoundException;
use OCP\Files\NotPermittedException;
+use OCP\ILogger;
use OCP\IURLGenerator;
class ImageManager {
@@ -45,6 +46,8 @@ class ImageManager {
private $supportedImageKeys = ['background', 'logo', 'logoheader', 'favicon'];
/** @var ICacheFactory */
private $cacheFactory;
+ /** @var ILogger */
+ private $logger;
/**
* ImageManager constructor.
@@ -53,16 +56,19 @@ class ImageManager {
* @param IAppData $appData
* @param IURLGenerator $urlGenerator
* @param ICacheFactory $cacheFactory
+ * @param ILogger $logger
*/
public function __construct(IConfig $config,
IAppData $appData,
IURLGenerator $urlGenerator,
- ICacheFactory $cacheFactory
+ ICacheFactory $cacheFactory,
+ ILogger $logger
) {
$this->config = $config;
$this->appData = $appData;
$this->urlGenerator = $urlGenerator;
$this->cacheFactory = $cacheFactory;
+ $this->logger = $logger;
}
public function getImageUrl(string $key, bool $useSvg = true): string {
@@ -95,6 +101,7 @@ class ImageManager {
* @throws NotPermittedException
*/
public function getImage(string $key, bool $useSvg = true): ISimpleFile {
+ $pngFile = null;
$logo = $this->config->getAppValue('theming', $key . 'Mime', false);
$folder = $this->appData->getFolder('images');
if ($logo === false || !$folder->fileExists($key)) {
@@ -110,10 +117,14 @@ class ImageManager {
$pngFile = $folder->newFile($key . '.png');
$pngFile->putContent($finalIconFile->getImageBlob());
} catch (\ImagickException $e) {
+ $this->logger->info('The image was requested to be no SVG file, but converting it to PNG failed.', $e->getMessage());
+ $pngFile = null;
}
} else {
$pngFile = $folder->getFile($key . '.png');
}
+ }
+ if ($pngFile !== null) {
return $pngFile;
}
return $folder->getFile($key);
diff --git a/apps/theming/tests/ImageManagerTest.php b/apps/theming/tests/ImageManagerTest.php
index 6bfa5b330a6..38f5fb04969 100644
--- a/apps/theming/tests/ImageManagerTest.php
+++ b/apps/theming/tests/ImageManagerTest.php
@@ -28,6 +28,7 @@ use OCA\Theming\ThemingDefaults;
use OCP\Files\SimpleFS\ISimpleFile;
use OCP\ICacheFactory;
use OCP\IConfig;
+use OCP\ILogger;
use OCP\IURLGenerator;
use Test\TestCase;
use OCP\Files\SimpleFS\ISimpleFolder;
@@ -46,6 +47,8 @@ class ImageManagerTest extends TestCase {
private $urlGenerator;
/** @var ICacheFactory|\PHPUnit_Framework_MockObject_MockObject */
private $cacheFactory;
+ /** @var ILogger|\PHPUnit_Framework_MockObject_MockObject */
+ private $logger;
protected function setUp() {
parent::setUp();
@@ -53,11 +56,13 @@ class ImageManagerTest extends TestCase {
$this->appData = $this->createMock(IAppData::class);
$this->urlGenerator = $this->createMock(IURLGenerator::class);
$this->cacheFactory = $this->createMock(ICacheFactory::class);
+ $this->logger = $this->createMock(ILogger::class);
$this->imageManager = new ImageManager(
$this->config,
$this->appData,
$this->urlGenerator,
- $this->cacheFactory
+ $this->cacheFactory,
+ $this->logger
);
}
diff --git a/lib/private/Server.php b/lib/private/Server.php
index 15fb06a2e03..d1818c287e1 100644
--- a/lib/private/Server.php
+++ b/lib/private/Server.php
@@ -954,7 +954,7 @@ class Server extends ServerContainer implements IServerContainer {
$c->getURLGenerator(),
$c->getMemCacheFactory(),
new Util($c->getConfig(), $this->getAppManager(), $c->getAppDataDir('theming')),
- new ImageManager($c->getConfig(), $c->getAppDataDir('theming'), $c->getURLGenerator(), $this->getMemCacheFactory()),
+ new ImageManager($c->getConfig(), $c->getAppDataDir('theming'), $c->getURLGenerator(), $this->getMemCacheFactory(), $this->getLogger()),
$c->getAppManager()
);
}