diff options
Diffstat (limited to 'lib/private')
29 files changed, 80 insertions, 41 deletions
diff --git a/lib/private/Server.php b/lib/private/Server.php index 581a2b44cea..2ce895c6f72 100644 --- a/lib/private/Server.php +++ b/lib/private/Server.php @@ -519,14 +519,17 @@ class Server extends ServerContainer implements IServerContainer { ); }); $this->registerService('LockingProvider', function (Server $c) { - if ($c->getConfig()->getSystemValue('filelocking.enabled', true) or (defined('PHPUNIT_RUN') && PHPUNIT_RUN)) { + $ini = $c->getIniWrapper(); + $config = $c->getConfig(); + $ttl = $config->getSystemValue('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time'))); + if ($config->getSystemValue('filelocking.enabled', true) or (defined('PHPUNIT_RUN') && PHPUNIT_RUN)) { /** @var \OC\Memcache\Factory $memcacheFactory */ $memcacheFactory = $c->getMemCacheFactory(); $memcache = $memcacheFactory->createLocking('lock'); if (!($memcache instanceof \OC\Memcache\NullCache)) { - return new MemcacheLockingProvider($memcache); + return new MemcacheLockingProvider($memcache, $ttl); } - return new DBLockingProvider($c->getDatabaseConnection(), $c->getLogger(), new TimeFactory()); + return new DBLockingProvider($c->getDatabaseConnection(), $c->getLogger(), new TimeFactory(), $ttl); } return new NoopLockingProvider(); }); diff --git a/lib/private/Share20/Manager.php b/lib/private/Share20/Manager.php index 6c665f7e133..be7257de36d 100644 --- a/lib/private/Share20/Manager.php +++ b/lib/private/Share20/Manager.php @@ -976,7 +976,17 @@ class Manager implements IManager { public function getShareByToken($token) { $provider = $this->factory->getProviderForType(\OCP\Share::SHARE_TYPE_LINK); - $share = $provider->getShareByToken($token); + try { + $share = $provider->getShareByToken($token); + } catch (ShareNotFound $e) { + //Ignore + } + + // If it is not a link share try to fetch a federated share by token + if ($share === null) { + $provider = $this->factory->getProviderForType(\OCP\Share::SHARE_TYPE_REMOTE); + $share = $provider->getShareByToken($token); + } if ($share->getExpirationDate() !== null && $share->getExpirationDate() <= new \DateTime()) { @@ -984,6 +994,14 @@ class Manager implements IManager { throw new ShareNotFound(); } + /* + * Reduce the permissions for link shares if public upload is not enabled + */ + if ($share->getShareType() === \OCP\Share::SHARE_TYPE_LINK && + !$this->shareApiLinkAllowPublicUpload()) { + $share->setPermissions($share->getPermissions() & ~(\OCP\Constants::PERMISSION_CREATE | \OCP\Constants::PERMISSION_UPDATE)); + } + return $share; } diff --git a/lib/private/Share20/ProviderFactory.php b/lib/private/Share20/ProviderFactory.php index 96203104f74..fdb2dacb0fc 100644 --- a/lib/private/Share20/ProviderFactory.php +++ b/lib/private/Share20/ProviderFactory.php @@ -100,7 +100,8 @@ class ProviderFactory implements IProviderFactory { $notifications = new Notifications( $addressHandler, $this->serverContainer->getHTTPClientService(), - $discoveryManager + $discoveryManager, + $this->serverContainer->getJobList() ); $tokenHandler = new TokenHandler( $this->serverContainer->getSecureRandom() diff --git a/lib/private/app/dependencyanalyzer.php b/lib/private/app/dependencyanalyzer.php index 0cf4bc72161..6519e15bd8b 100644 --- a/lib/private/app/dependencyanalyzer.php +++ b/lib/private/app/dependencyanalyzer.php @@ -97,7 +97,7 @@ class DependencyAnalyzer { * @return bool result similar to version_compare */ private function compare($first, $second, $operator) { - // we cant normalize versions if one of the given parameters is not a + // we can't normalize versions if one of the given parameters is not a // version string but null. In case one parameter is null normalization // will therefore be skipped if ($first !== null && $second !== null) { diff --git a/lib/private/appframework/http/output.php b/lib/private/appframework/http/output.php index dfb03e6a516..469c809c21c 100644 --- a/lib/private/appframework/http/output.php +++ b/lib/private/appframework/http/output.php @@ -48,7 +48,7 @@ class Output implements IOutput { /** * @param string $path * - * @return bool false if an error occured + * @return bool false if an error occurred */ public function setReadfile($path) { return @readfile($path); diff --git a/lib/private/appframework/middleware/middlewaredispatcher.php b/lib/private/appframework/middleware/middlewaredispatcher.php index e2b2eff42ab..4bd25f79bba 100644 --- a/lib/private/appframework/middleware/middlewaredispatcher.php +++ b/lib/private/appframework/middleware/middlewaredispatcher.php @@ -107,7 +107,7 @@ class MiddlewareDispatcher { * @param \Exception $exception the thrown exception * @return Response a Response object if the middleware can handle the * exception - * @throws \Exception the passed in exception if it cant handle it + * @throws \Exception the passed in exception if it can't handle it */ public function afterException(Controller $controller, $methodName, \Exception $exception){ for($i=$this->middlewareCounter-1; $i>=0; $i--){ diff --git a/lib/private/appframework/middleware/security/corsmiddleware.php b/lib/private/appframework/middleware/security/corsmiddleware.php index e42513b44a2..258119b326a 100644 --- a/lib/private/appframework/middleware/security/corsmiddleware.php +++ b/lib/private/appframework/middleware/security/corsmiddleware.php @@ -36,7 +36,7 @@ use OCP\AppFramework\Middleware; /** * This middleware sets the correct CORS headers on a response if the * controller has the @CORS annotation. This is needed for webapps that want - * to access an API and dont run on the same domain, see + * to access an API and don't run on the same domain, see * https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS */ class CORSMiddleware extends Middleware { @@ -135,7 +135,7 @@ class CORSMiddleware extends Middleware { * @param string $methodName the name of the method that will be called on * the controller * @param \Exception $exception the thrown exception - * @throws \Exception the passed in exception if it cant handle it + * @throws \Exception the passed in exception if it can't handle it * @return Response a Response object or null in case that the exception could not be handled */ public function afterException($controller, $methodName, \Exception $exception){ diff --git a/lib/private/appframework/middleware/security/securitymiddleware.php b/lib/private/appframework/middleware/security/securitymiddleware.php index f3bc06217cd..75bcc29a926 100644 --- a/lib/private/appframework/middleware/security/securitymiddleware.php +++ b/lib/private/appframework/middleware/security/securitymiddleware.php @@ -179,7 +179,7 @@ class SecurityMiddleware extends Middleware { * @param string $methodName the name of the method that will be called on * the controller * @param \Exception $exception the thrown exception - * @throws \Exception the passed in exception if it cant handle it + * @throws \Exception the passed in exception if it can't handle it * @return Response a Response object or null in case that the exception could not be handled */ public function afterException($controller, $methodName, \Exception $exception) { diff --git a/lib/private/archive/zip.php b/lib/private/archive/zip.php index 8962a8e446e..0d8d3b7ce76 100644 --- a/lib/private/archive/zip.php +++ b/lib/private/archive/zip.php @@ -185,7 +185,7 @@ class OC_Archive_ZIP extends OC_Archive{ if($mode=='r' or $mode=='rb') { return $this->zip->getStream($path); } else { - //since we cant directly get a writable stream, + //since we can't directly get a writable stream, //make a temp copy of the file and put it back //in the archive when the stream is closed if(strrpos($path, '.')!==false) { diff --git a/lib/private/backgroundjob/legacy/regularjob.php b/lib/private/backgroundjob/legacy/regularjob.php index 8e8b6634c11..aedd6ef657a 100644 --- a/lib/private/backgroundjob/legacy/regularjob.php +++ b/lib/private/backgroundjob/legacy/regularjob.php @@ -22,10 +22,17 @@ namespace OC\BackgroundJob\Legacy; +use OCP\AutoloadNotAllowedException; + class RegularJob extends \OC\BackgroundJob\Job { public function run($argument) { - if (is_callable($argument)) { - call_user_func($argument); + try { + if (is_callable($argument)) { + call_user_func($argument); + } + } catch (AutoloadNotAllowedException $e) { + // job is from a disabled app, ignore + return null; } } } diff --git a/lib/private/files/cache/wrapper/cachewrapper.php b/lib/private/files/cache/wrapper/cachewrapper.php index 883f4709358..8c77e3c340e 100644 --- a/lib/private/files/cache/wrapper/cachewrapper.php +++ b/lib/private/files/cache/wrapper/cachewrapper.php @@ -72,7 +72,7 @@ class CacheWrapper extends Cache { * @return ICacheEntry[] */ public function getFolderContents($folder) { - // cant do a simple $this->cache->.... call here since getFolderContentsById needs to be called on this + // can't do a simple $this->cache->.... call here since getFolderContentsById needs to be called on this // and not the wrapped cache $fileId = $this->getId($folder); return $this->getFolderContentsById($fileId); diff --git a/lib/private/files/node/root.php b/lib/private/files/node/root.php index 69c98368dfd..04866e60b87 100644 --- a/lib/private/files/node/root.php +++ b/lib/private/files/node/root.php @@ -187,7 +187,7 @@ class Root extends Folder implements IRootFolder { } } - //most operations cant be done on the root + //most operations can't be done on the root /** * @param string $targetPath diff --git a/lib/private/files/storage/common.php b/lib/private/files/storage/common.php index 1d4801e5b97..df0d9695449 100644 --- a/lib/private/files/storage/common.php +++ b/lib/private/files/storage/common.php @@ -634,7 +634,7 @@ abstract class Common implements Storage, ILockingStorage { public function getMetaData($path) { $permissions = $this->getPermissions($path); if (!$permissions & \OCP\Constants::PERMISSION_READ) { - //cant read, nothing we can do + //can't read, nothing we can do return null; } diff --git a/lib/private/files/storage/local.php b/lib/private/files/storage/local.php index b6d0ec3fb34..25b202af5f8 100644 --- a/lib/private/files/storage/local.php +++ b/lib/private/files/storage/local.php @@ -177,9 +177,15 @@ class Local extends \OC\Files\Storage\Common { public function file_get_contents($path) { // file_get_contents() has a memory leak: https://bugs.php.net/bug.php?id=61961 - $filename = $this->getSourcePath($path); - $handle = fopen($filename,'rb'); - $content = fread($handle, filesize($filename)); + $fileName = $this->getSourcePath($path); + + $fileSize = filesize($fileName); + if ($fileSize === 0) { + return ''; + } + + $handle = fopen($fileName,'rb'); + $content = fread($handle, $fileSize); fclose($handle); return $content; } @@ -225,7 +231,7 @@ class Local extends \OC\Files\Storage\Common { } if ($this->is_dir($path1)) { - // we cant move folders across devices, use copy instead + // we can't move folders across devices, use copy instead $stat1 = stat(dirname($this->getSourcePath($path1))); $stat2 = stat(dirname($this->getSourcePath($path2))); if ($stat1['dev'] !== $stat2['dev']) { diff --git a/lib/private/files/storage/polyfill/copydirectory.php b/lib/private/files/storage/polyfill/copydirectory.php index 22bfe369738..d4cac117ade 100644 --- a/lib/private/files/storage/polyfill/copydirectory.php +++ b/lib/private/files/storage/polyfill/copydirectory.php @@ -76,7 +76,7 @@ trait CopyDirectory { } /** - * For adapters that dont support copying folders natively + * For adapters that don't support copying folders natively * * @param $source * @param $target diff --git a/lib/private/files/storage/wrapper/permissionsmask.php b/lib/private/files/storage/wrapper/permissionsmask.php index 7fa64f82ba6..01dd78d418c 100644 --- a/lib/private/files/storage/wrapper/permissionsmask.php +++ b/lib/private/files/storage/wrapper/permissionsmask.php @@ -32,7 +32,7 @@ use OCP\Constants; * * This can be used to restrict update, create, delete and/or share permissions of a storage * - * Note that the read permissions cant be masked + * Note that the read permissions can't be masked */ class PermissionsMask extends Wrapper { /** diff --git a/lib/private/files/view.php b/lib/private/files/view.php index 4421a016356..aac33a4598c 100644 --- a/lib/private/files/view.php +++ b/lib/private/files/view.php @@ -742,7 +742,7 @@ class View { $this->writeUpdate($storage2, $internalPath2); } else if ($result) { - if ($internalPath1 !== '') { // dont do a cache update for moved mounts + if ($internalPath1 !== '') { // don't do a cache update for moved mounts $this->renameUpdate($storage1, $storage2, $internalPath1, $internalPath2); } } diff --git a/lib/private/group.php b/lib/private/group.php index c37b4f63575..f1b84069a38 100644 --- a/lib/private/group.php +++ b/lib/private/group.php @@ -66,7 +66,7 @@ class OC_Group { /** * set the group backend - * @param \OC_Group_Backend $backend The backend to use for user managment + * @param \OC_Group_Backend $backend The backend to use for user management * @return bool */ public static function useBackend($backend) { diff --git a/lib/private/lock/abstractlockingprovider.php b/lib/private/lock/abstractlockingprovider.php index 7dee8c709a0..f96358778c1 100644 --- a/lib/private/lock/abstractlockingprovider.php +++ b/lib/private/lock/abstractlockingprovider.php @@ -28,7 +28,7 @@ use OCP\Lock\ILockingProvider; * to release any left over locks at the end of the request */ abstract class AbstractLockingProvider implements ILockingProvider { - const TTL = 3600; // how long until we clear stray locks in seconds + protected $ttl; // how long until we clear stray locks in seconds protected $acquiredLocks = [ 'shared' => [], diff --git a/lib/private/lock/dblockingprovider.php b/lib/private/lock/dblockingprovider.php index c10cd8636ad..9e97df44d3f 100644 --- a/lib/private/lock/dblockingprovider.php +++ b/lib/private/lock/dblockingprovider.php @@ -93,11 +93,13 @@ class DBLockingProvider extends AbstractLockingProvider { * @param \OCP\IDBConnection $connection * @param \OCP\ILogger $logger * @param \OCP\AppFramework\Utility\ITimeFactory $timeFactory + * @param int $ttl */ - public function __construct(IDBConnection $connection, ILogger $logger, ITimeFactory $timeFactory) { + public function __construct(IDBConnection $connection, ILogger $logger, ITimeFactory $timeFactory, $ttl = 3600) { $this->connection = $connection; $this->logger = $logger; $this->timeFactory = $timeFactory; + $this->ttl = $ttl; } /** @@ -117,7 +119,7 @@ class DBLockingProvider extends AbstractLockingProvider { * @return int */ protected function getExpireTime() { - return $this->timeFactory->getTime() + self::TTL; + return $this->timeFactory->getTime() + $this->ttl; } /** diff --git a/lib/private/lock/memcachelockingprovider.php b/lib/private/lock/memcachelockingprovider.php index 08c92950e49..536b29e2c28 100644 --- a/lib/private/lock/memcachelockingprovider.php +++ b/lib/private/lock/memcachelockingprovider.php @@ -33,14 +33,16 @@ class MemcacheLockingProvider extends AbstractLockingProvider { /** * @param \OCP\IMemcache $memcache + * @param int $ttl */ - public function __construct(IMemcache $memcache) { + public function __construct(IMemcache $memcache, $ttl = 3600) { $this->memcache = $memcache; + $this->ttl = $ttl; } private function setTTL($path) { if ($this->memcache instanceof IMemcacheTTL) { - $this->memcache->setTTL($path, self::TTL); + $this->memcache->setTTL($path, $this->ttl); } } diff --git a/lib/private/memcache/factory.php b/lib/private/memcache/factory.php index 204ded7d5ab..a005f319b3e 100644 --- a/lib/private/memcache/factory.php +++ b/lib/private/memcache/factory.php @@ -112,7 +112,7 @@ class Factory implements ICacheFactory { } } if (!($lockingCacheClass && $lockingCacheClass::isAvailable())) { - // dont fallback since the fallback might not be suitable for storing lock + // don't fallback since the fallback might not be suitable for storing lock $lockingCacheClass = self::NULL_CACHE; } diff --git a/lib/private/memcache/redis.php b/lib/private/memcache/redis.php index db5461db669..b3444a2b4e9 100644 --- a/lib/private/memcache/redis.php +++ b/lib/private/memcache/redis.php @@ -122,7 +122,7 @@ class Redis extends Cache implements IMemcacheTTL { * @return bool */ public function add($key, $value, $ttl = 0) { - // dont encode ints for inc/dec + // don't encode ints for inc/dec if (!is_int($value)) { $value = json_encode($value); } diff --git a/lib/private/preview/image.php b/lib/private/preview/image.php index b377f0e855d..3ea99d6963a 100644 --- a/lib/private/preview/image.php +++ b/lib/private/preview/image.php @@ -53,10 +53,10 @@ abstract class Image extends Provider { $fileName = $fileview->getLocalFile($path); } $image->loadFromFile($fileName); + $image->fixOrientation(); 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 5c7eb9b52d5..51e0ff75e6a 100644 --- a/lib/private/response.php +++ b/lib/private/response.php @@ -40,7 +40,7 @@ class OC_Response { * @param integer $cache_time time to cache the response * >0 cache time in seconds * 0 and <0 enable default browser caching - * null cache indefinitly + * null cache indefinitely */ static public function enableCaching($cache_time = null) { if (is_numeric($cache_time)) { @@ -113,7 +113,7 @@ class OC_Response { } /** - * Set reponse expire time + * Set response expire time * @param string|DateTime $expires date-time when the response expires * string for DateInterval from now * DateTime object when to expire response @@ -152,7 +152,7 @@ class OC_Response { /** * Checks and set Last-Modified header, when the request matches sends a * 'not modified' response - * @param int|DateTime|string $lastModified time when the reponse was last modified + * @param int|DateTime|string $lastModified time when the response was last modified */ static public function setLastModifiedHeader($lastModified) { if (empty($lastModified)) { diff --git a/lib/private/setup/mysql.php b/lib/private/setup/mysql.php index de2466676c1..ba1b2ca854c 100644 --- a/lib/private/setup/mysql.php +++ b/lib/private/setup/mysql.php @@ -55,7 +55,7 @@ class MySQL extends AbstractDatabase { try{ $name = $this->dbName; $user = $this->dbUser; - //we cant use OC_BD functions here because we need to connect as the administrative user. + //we can't use OC_BD functions here because we need to connect as the administrative user. $query = "CREATE DATABASE IF NOT EXISTS `$name` CHARACTER SET utf8 COLLATE utf8_bin;"; $connection->executeUpdate($query); diff --git a/lib/private/setup/postgresql.php b/lib/private/setup/postgresql.php index 4c17de4b84d..893999bb0b9 100644 --- a/lib/private/setup/postgresql.php +++ b/lib/private/setup/postgresql.php @@ -113,7 +113,7 @@ class PostgreSQL extends AbstractDatabase { } private function createDatabase($connection) { - //we cant use OC_BD functions here because we need to connect as the administrative user. + //we can't use OC_BD functions here because we need to connect as the administrative user. $e_name = pg_escape_string($this->dbName); $e_user = pg_escape_string($this->dbUser); $query = "select datname from pg_database where datname = '$e_name'"; diff --git a/lib/private/tempmanager.php b/lib/private/tempmanager.php index b233edd8b35..dd97a36cd7f 100644 --- a/lib/private/tempmanager.php +++ b/lib/private/tempmanager.php @@ -251,8 +251,8 @@ class TempManager implements ITempManager { * @return bool */ private function checkTemporaryDirectory($directory) { - // surpress any possible errors caused by is_writable - // checks missing or invalid path or characters, wrong permissions ect + // suppress any possible errors caused by is_writable + // checks missing or invalid path or characters, wrong permissions etc try { if (is_writeable($directory)) { return true; diff --git a/lib/private/util.php b/lib/private/util.php index b320394f26d..039bc7e9156 100644 --- a/lib/private/util.php +++ b/lib/private/util.php @@ -440,7 +440,7 @@ class OC_Util { * generates a path for JS/CSS files. If no application is provided it will create the path for core. * * @param string $application application to get the files from - * @param string $directory directory withing this application (css, js, vendor, etc) + * @param string $directory directory within this application (css, js, vendor, etc) * @param string $file the file inside of the above folder * @return string the path */ |