aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xlib/private/Template/ResourceLocator.php7
-rw-r--r--tests/lib/Template/ResourceLocatorTest.php9
2 files changed, 14 insertions, 2 deletions
diff --git a/lib/private/Template/ResourceLocator.php b/lib/private/Template/ResourceLocator.php
index 377f0e0b6a8..df085776068 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 @@ abstract class ResourceLocator {
*/
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 e74e72014c5..d549c50c959 100644
--- a/tests/lib/Template/ResourceLocatorTest.php
+++ b/tests/lib/Template/ResourceLocatorTest.php
@@ -29,8 +29,13 @@ class ResourceLocatorTest extends \Test\TestCase {
$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],