diff --git a/lib/private/Template/ResourceLocator.php b/lib/private/Template/ResourceLocator.php index 377f0e0b6a873..df085776068cf 100755 --- a/lib/private/Template/ResourceLocator.php +++ b/lib/private/Template/ResourceLocator.php @@ -7,6 +7,7 @@ */ namespace OC\Template; +use OC\SystemConfig; use Psr\Log\LoggerInterface; abstract class ResourceLocator { @@ -20,6 +21,8 @@ abstract class ResourceLocator { protected LoggerInterface $logger; + private const LOG_LARGE_ASSET_OFFSET = 1024 * 1024; + public function __construct(LoggerInterface $logger) { $this->logger = $logger; $this->mapping = [ @@ -76,6 +79,10 @@ public function find($resources) { */ protected function appendIfExist($root, $file, $webRoot = null) { if ($root !== false && is_file($root.'/'.$file)) { + $systemConfig = \OCP\Server::get(SystemConfig::class); + if ($systemConfig->getValue('debug', false) && filesize($root.'/'.$file) > self::LOG_LARGE_ASSET_OFFSET) { + $this->logger->debug("$root/$file is larger then 1MB, consider reducing the size for javascript entrypoints"); + } $this->append($root, $file, $webRoot, false); return true; } diff --git a/tests/lib/Template/ResourceLocatorTest.php b/tests/lib/Template/ResourceLocatorTest.php index e74e72014c5d5..d549c50c959a6 100644 --- a/tests/lib/Template/ResourceLocatorTest.php +++ b/tests/lib/Template/ResourceLocatorTest.php @@ -29,8 +29,13 @@ public function getResourceLocator($theme) { $systemConfig ->expects($this->any()) ->method('getValue') - ->with('theme', '') - ->willReturn($theme); + ->willReturnCallback(function ($key, $default = null) use ($theme) { + if ($key === 'theme') { + return $theme; + } + + return $default; + }); $this->overwriteService(SystemConfig::class, $systemConfig); return $this->getMockForAbstractClass('OC\Template\ResourceLocator', [$this->logger],