diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/base.php | 11 | ||||
-rw-r--r-- | lib/private/assetic/separatorfilter.php | 57 | ||||
-rw-r--r-- | lib/private/lock/dblockingprovider.php | 4 | ||||
-rw-r--r-- | lib/private/preview.php | 16 | ||||
-rw-r--r-- | lib/private/preview/image.php | 6 | ||||
-rw-r--r-- | lib/private/response.php | 2 | ||||
-rw-r--r-- | lib/private/templatelayout.php | 6 | ||||
-rw-r--r-- | lib/private/updater.php | 16 | ||||
-rw-r--r-- | lib/public/appframework/http/contentsecuritypolicy.php | 1 | ||||
-rw-r--r-- | lib/public/util.php | 6 |
10 files changed, 43 insertions, 82 deletions
diff --git a/lib/base.php b/lib/base.php index 32b90cad1fa..889801f9653 100644 --- a/lib/base.php +++ b/lib/base.php @@ -237,7 +237,7 @@ class OC { // Check if config is writable $configFileWritable = is_writable($configFilePath); if (!$configFileWritable && !OC_Helper::isReadOnlyConfigEnabled() - || !$configFileWritable && \OCP\Util::needUpgrade()) { + || !$configFileWritable && self::checkUpgrade(false)) { if (self::$CLI) { echo $l->t('Cannot write into "config" directory!')."\n"; echo $l->t('This can usually be fixed by giving the webserver write access to the config directory')."\n"; @@ -678,7 +678,7 @@ class OC { */ public static function registerCacheHooks() { //don't try to do this before we are properly setup - if (\OC::$server->getSystemConfig()->getValue('installed', false) && !\OCP\Util::needUpgrade()) { + if (\OC::$server->getSystemConfig()->getValue('installed', false) && !self::checkUpgrade(false)) { // NOTE: This will be replaced to use OCP $userSession = self::$server->getUserSession(); @@ -714,7 +714,7 @@ class OC { */ public static function registerLogRotate() { $systemConfig = \OC::$server->getSystemConfig(); - if ($systemConfig->getValue('installed', false) && $systemConfig->getValue('log_rotate_size', false) && !\OCP\Util::needUpgrade()) { + if ($systemConfig->getValue('installed', false) && $systemConfig->getValue('log_rotate_size', false) && !self::checkUpgrade(false)) { //don't try to do this before we are properly setup //use custom logfile path if defined, otherwise use default of owncloud.log in data directory \OCP\BackgroundJob::registerJob('OC\Log\Rotate', $systemConfig->getValue('logfile', $systemConfig->getValue('datadirectory', OC::$SERVERROOT . '/data') . '/owncloud.log')); @@ -807,8 +807,7 @@ class OC { // Load minimum set of apps if (!self::checkUpgrade(false) - && !$systemConfig->getValue('maintenance', false) - && !\OCP\Util::needUpgrade()) { + && !$systemConfig->getValue('maintenance', false)) { // For logged-in users: Load everything if(OC_User::isLoggedIn()) { OC_App::loadApps(); @@ -821,7 +820,7 @@ class OC { if (!self::$CLI and (!isset($_GET["logout"]) or ($_GET["logout"] !== 'true'))) { try { - if (!$systemConfig->getValue('maintenance', false) && !\OCP\Util::needUpgrade()) { + if (!$systemConfig->getValue('maintenance', false) && !self::checkUpgrade(false)) { OC_App::loadApps(array('filesystem', 'logging')); OC_App::loadApps(); } diff --git a/lib/private/assetic/separatorfilter.php b/lib/private/assetic/separatorfilter.php deleted file mode 100644 index ee6d5c11c20..00000000000 --- a/lib/private/assetic/separatorfilter.php +++ /dev/null @@ -1,57 +0,0 @@ -<?php -/** - * @author Morris Jobke <hey@morrisjobke.de> - * @author Robin McCorkell <rmccorkell@karoshi.org.uk> - * - * @copyright Copyright (c) 2015, ownCloud, Inc. - * @license AGPL-3.0 - * - * This code is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License, version 3, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License, version 3, - * along with this program. If not, see <http://www.gnu.org/licenses/> - * - */ - -namespace OC\Assetic; - -use Assetic\Filter\FilterInterface; -use Assetic\Asset\AssetInterface; - -/** - * Inserts a separator between assets to prevent merge failures - * e.g. missing semicolon at the end of a JS file - */ -class SeparatorFilter implements FilterInterface -{ - /** - * @var string - */ - private $separator; - - /** - * Constructor. - * - * @param string $separator Separator to use between assets - */ - public function __construct($separator = ';') - { - $this->separator = $separator; - } - - public function filterLoad(AssetInterface $asset) - { - } - - public function filterDump(AssetInterface $asset) - { - $asset->setContent($asset->getContent() . $this->separator); - } -} diff --git a/lib/private/lock/dblockingprovider.php b/lib/private/lock/dblockingprovider.php index a08357a6024..8f017a713c1 100644 --- a/lib/private/lock/dblockingprovider.php +++ b/lib/private/lock/dblockingprovider.php @@ -102,10 +102,6 @@ class DBLockingProvider extends AbstractLockingProvider { * @throws \OCP\Lock\LockedException */ public function acquireLock($path, $type) { - if ($this->connection->inTransaction()) { - $this->logger->warning("Trying to acquire a lock for '$path' while inside a transition"); - } - $expire = $this->getExpireTime(); if ($type === self::LOCK_SHARED) { $result = $this->initLockField($path,1); diff --git a/lib/private/preview.php b/lib/private/preview.php index de964b72df2..1127048b7fd 100644 --- a/lib/private/preview.php +++ b/lib/private/preview.php @@ -837,6 +837,11 @@ class Preview { $askedWidth = $this->getMaxX(); $askedHeight = $this->getMaxY(); + if ($this->mode === self::MODE_COVER) { + list($askedWidth, $askedHeight) = + $this->applyCover($askedWidth, $askedHeight, $previewWidth, $previewHeight); + } + /** * Phase 1: If required, adjust boundaries to keep aspect ratio */ @@ -845,20 +850,12 @@ class Preview { $this->applyAspectRatio($askedWidth, $askedHeight, $previewWidth, $previewHeight); } - if ($this->mode === self::MODE_COVER) { - list($scaleWidth, $scaleHeight) = - $this->applyCover($askedWidth, $askedHeight, $previewWidth, $previewHeight); - } else { - $scaleWidth = $askedWidth; - $scaleHeight = $askedHeight; - } - /** * Phase 2: Resizes preview to try and match requirements. * Takes the scaling ratio into consideration */ list($newPreviewWidth, $newPreviewHeight) = $this->scale( - $image, $scaleWidth, $scaleHeight, $previewWidth, $previewHeight + $image, $askedWidth, $askedHeight, $previewWidth, $previewHeight ); // The preview has been resized and should now have the asked dimensions @@ -890,6 +887,7 @@ class Preview { return; } + // The preview is smaller, but we can't touch it $this->storePreview($fileId, $newPreviewWidth, $newPreviewHeight); } diff --git a/lib/private/preview/image.php b/lib/private/preview/image.php index f9c27e690f6..fd90b15eb0c 100644 --- a/lib/private/preview/image.php +++ b/lib/private/preview/image.php @@ -46,12 +46,16 @@ abstract class Image extends Provider { $image = new \OC_Image(); - if ($fileInfo['encrypted'] === true) { + $useTempFile = $fileInfo->isEncrypted() || !$fileInfo->getStorage()->isLocal(); + if ($useTempFile) { $fileName = $fileview->toTmpFile($path); } else { $fileName = $fileview->getLocalFile($path); } $image->loadFromFile($fileName); + if ($useTempFile) { + unlink($fileName); + } $image->fixOrientation(); if ($image->valid()) { $image->scaleDownToFit($maxX, $maxY); diff --git a/lib/private/response.php b/lib/private/response.php index f1a429463f2..2cd1d990e51 100644 --- a/lib/private/response.php +++ b/lib/private/response.php @@ -247,7 +247,7 @@ class OC_Response { . 'script-src \'self\' \'unsafe-eval\'; ' . 'style-src \'self\' \'unsafe-inline\'; ' . 'frame-src *; ' - . 'img-src *; ' + . 'img-src * data: blob:; ' . 'font-src \'self\' data:; ' . 'media-src *; ' . 'connect-src *'; diff --git a/lib/private/templatelayout.php b/lib/private/templatelayout.php index ae3c1093b20..43c83dea815 100644 --- a/lib/private/templatelayout.php +++ b/lib/private/templatelayout.php @@ -38,8 +38,8 @@ use Assetic\AssetWriter; use Assetic\Filter\CssImportFilter; use Assetic\Filter\CssMinFilter; use Assetic\Filter\CssRewriteFilter; -use Assetic\Filter\JSMinFilter; -use OC\Assetic\SeparatorFilter; // waiting on upstream +use Assetic\Filter\JSqueezeFilter; +use Assetic\Filter\SeparatorFilter; /** * Copyright (c) 2012 Bart Visscher <bartv@thisnet.nl> @@ -225,7 +225,7 @@ class OC_TemplateLayout extends OC_Template { ), $root, $file); } return new FileAsset($root . '/' . $file, array( - new JSMinFilter(), + new JSqueezeFilter(), new SeparatorFilter(';') ), $root, $file); }, $jsFiles); diff --git a/lib/private/updater.php b/lib/private/updater.php index b33180c3425..8aa8b0703d7 100644 --- a/lib/private/updater.php +++ b/lib/private/updater.php @@ -32,6 +32,7 @@ namespace OC; +use OC\Core\Command\Log\Manage; use OC\Hooks\BasicEmitter; use OC_App; use OC_Installer; @@ -69,6 +70,14 @@ class Updater extends BasicEmitter { /** @var bool */ private $skip3rdPartyAppsDisable; + private $logLevelNames = [ + 0 => 'Debug', + 1 => 'Info', + 2 => 'Warning', + 3 => 'Error', + 4 => 'Fatal', + ]; + /** * @param HTTPHelper $httpHelper * @param IConfig $config @@ -177,6 +186,10 @@ class Updater extends BasicEmitter { * @return bool true if the operation succeeded, false otherwise */ public function upgrade() { + $logLevel = $this->config->getSystemValue('loglevel', \OCP\Util::WARN); + $this->emit('\OC\Updater', 'setDebugLogLevel', [ $logLevel, $this->logLevelNames[$logLevel] ]); + $this->config->setSystemValue('loglevel', \OCP\Util::DEBUG); + $wasMaintenanceModeEnabled = $this->config->getSystemValue('maintenance', false); if(!$wasMaintenanceModeEnabled) { @@ -208,6 +221,9 @@ class Updater extends BasicEmitter { $this->emit('\OC\Updater', 'maintenanceActive'); } + $this->emit('\OC\Updater', 'resetLogLevel', [ $logLevel, $this->logLevelNames[$logLevel] ]); + $this->config->setSystemValue('loglevel', $logLevel); + return $success; } diff --git a/lib/public/appframework/http/contentsecuritypolicy.php b/lib/public/appframework/http/contentsecuritypolicy.php index ee36f7aac17..07c76f2969c 100644 --- a/lib/public/appframework/http/contentsecuritypolicy.php +++ b/lib/public/appframework/http/contentsecuritypolicy.php @@ -64,6 +64,7 @@ class ContentSecurityPolicy { private $allowedImageDomains = [ '\'self\'', 'data:', + 'blob:', ]; /** @var array Domains to which connections can be done */ private $allowedConnectDomains = [ diff --git a/lib/public/util.php b/lib/public/util.php index 652df5192cf..1ba091d1952 100644 --- a/lib/public/util.php +++ b/lib/public/util.php @@ -654,6 +654,7 @@ class Util { return \OC_Util::isDefaultExpireDateEnforced(); } + protected static $needUpgradeCache = null; /** * Checks whether the current version needs upgrade. @@ -662,6 +663,9 @@ class Util { * @since 7.0.0 */ public static function needUpgrade() { - return \OC_Util::needUpgrade(\OC::$server->getConfig()); + if (!isset(self::$needUpgradeCache)) { + self::$needUpgradeCache=\OC_Util::needUpgrade(\OC::$server->getConfig()); + } + return self::$needUpgradeCache; } } |