diff options
Diffstat (limited to 'lib/private')
20 files changed, 187 insertions, 64 deletions
diff --git a/lib/private/api.php b/lib/private/api.php index 6c6be233c9d..87f2aa9b118 100644 --- a/lib/private/api.php +++ b/lib/private/api.php @@ -188,7 +188,7 @@ class OC_API { /** * merge the returned result objects into one response * @param array $responses - * @return array|\OC_OCS_Result + * @return OC_OCS_Result */ public static function mergeResponses($responses) { // Sort into shipped and third-party @@ -442,6 +442,7 @@ class OC_API { /** * Based on the requested format the response content type is set + * @param string $format */ public static function setContentType($format = null) { $format = is_null($format) ? self::requestedFormat() : $format; diff --git a/lib/private/avatarmanager.php b/lib/private/avatarmanager.php index b39f5495122..b2d3e6eb3dd 100644 --- a/lib/private/avatarmanager.php +++ b/lib/private/avatarmanager.php @@ -26,6 +26,8 @@ namespace OC; +use OCP\Files\Folder; +use OCP\Files\NotFoundException; use OCP\IAvatarManager; use OCP\IUserManager; use OCP\Files\IRootFolder; @@ -45,6 +47,13 @@ class AvatarManager implements IAvatarManager { /** @var IL10N */ private $l; + /** + * AvatarManager constructor. + * + * @param IUserManager $userManager + * @param IRootFolder $rootFolder + * @param IL10N $l + */ public function __construct( IUserManager $userManager, IRootFolder $rootFolder, @@ -57,15 +66,26 @@ class AvatarManager implements IAvatarManager { /** * return a user specific instance of \OCP\IAvatar * @see \OCP\IAvatar - * @param string $user the ownCloud user id + * @param string $userId the ownCloud user id * @return \OCP\IAvatar * @throws \Exception In case the username is potentially dangerous + * @throws NotFoundException In case there is no user folder yet */ public function getAvatar($userId) { $user = $this->userManager->get($userId); if (is_null($user)) { throw new \Exception('user does not exist'); } - return new Avatar($this->rootFolder->getUserFolder($userId)->getParent(), $this->l, $user); + + /* + * Fix for #22119 + * Basically we do not want to copy the skeleton folder + */ + \OC\Files\Filesystem::initMountPoints($userId); + $dir = '/' . $userId; + /** @var Folder $folder */ + $folder = $this->rootFolder->get($dir); + + return new Avatar($folder, $this->l, $user); } } diff --git a/lib/private/console/application.php b/lib/private/console/application.php index 10ff69b1c80..0895f1788af 100644 --- a/lib/private/console/application.php +++ b/lib/private/console/application.php @@ -31,6 +31,7 @@ use OCP\IRequest; use Symfony\Component\Console\Application as SymfonyApplication; use Symfony\Component\Console\Input\ArgvInput; use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface; @@ -56,12 +57,31 @@ class Application { } /** + * @param InputInterface $input * @param OutputInterface $output * @throws \Exception */ - public function loadCommands(OutputInterface $output) { + public function loadCommands(InputInterface $input, OutputInterface $output) { // $application is required to be defined in the register_command scripts $application = $this->application; + $inputDefinition = $application->getDefinition(); + $inputDefinition->addOption( + new InputOption( + 'no-warnings', + null, + InputOption::VALUE_NONE, + 'Skip global warnings, show command output only', + null + ) + ); + try { + $input->bind($inputDefinition); + } catch (\RuntimeException $e) { + //expected if there are extra options + } + if ($input->getOption('no-warnings')) { + $output->setVerbosity(OutputInterface::VERBOSITY_QUIET); + } require_once __DIR__ . '/../../../core/register_command.php'; if ($this->config->getSystemValue('installed', false)) { if (\OCP\Util::needUpgrade()) { diff --git a/lib/private/db/adaptersqlsrv.php b/lib/private/db/adaptersqlsrv.php deleted file mode 100644 index f208b2ba787..00000000000 --- a/lib/private/db/adaptersqlsrv.php +++ /dev/null @@ -1,37 +0,0 @@ -<?php -/** - * @author Bart Visscher <bartv@thisnet.nl> - * @author Morris Jobke <hey@morrisjobke.de> - * @author Thomas Müller <thomas.mueller@tmit.eu> - * - * @copyright Copyright (c) 2016, 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\DB; - -class AdapterSQLSrv extends Adapter { - public function fixupStatement($statement) { - $statement = str_replace(' ILIKE ', ' COLLATE Latin1_General_CI_AS LIKE ', $statement); - $statement = preg_replace( "/\`(.*?)`/", "[$1]", $statement ); - $statement = str_ireplace( 'NOW()', 'CURRENT_TIMESTAMP', $statement ); - $statement = str_replace( 'LENGTH(', 'LEN(', $statement ); - $statement = str_replace( 'SUBSTR(', 'SUBSTRING(', $statement ); - $statement = str_ireplace( 'UNIX_TIMESTAMP()', 'DATEDIFF(second,{d \'1970-01-01\'},GETDATE())', $statement ); - return $statement; - } -} diff --git a/lib/private/db/querybuilder/expressionbuilder/expressionbuilder.php b/lib/private/db/querybuilder/expressionbuilder/expressionbuilder.php index 7ab4c03d97c..6fb58ac3c9d 100644 --- a/lib/private/db/querybuilder/expressionbuilder/expressionbuilder.php +++ b/lib/private/db/querybuilder/expressionbuilder/expressionbuilder.php @@ -277,6 +277,23 @@ class ExpressionBuilder implements IExpressionBuilder { } /** + * Creates a ILIKE() comparison expression with the given arguments. + * + * @param string $x Field in string format to be inspected by ILIKE() comparison. + * @param mixed $y Argument to be used in ILIKE() comparison. + * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants + * required when comparing text fields for oci compatibility + * + * @return string + * @since 9.0.0 + */ + public function iLike($x, $y, $type = null) { + $x = $this->helper->quoteColumnName($x); + $y = $this->helper->quoteColumnName($y); + return $this->expressionBuilder->comparison("LOWER($x)", 'LIKE', "LOWER($y)"); + } + + /** * Creates a NOT LIKE() comparison expression with the given arguments. * * @param string $x Field in string format to be inspected by NOT LIKE() comparison. diff --git a/lib/private/db/querybuilder/expressionbuilder/mysqlexpressionbuilder.php b/lib/private/db/querybuilder/expressionbuilder/mysqlexpressionbuilder.php new file mode 100644 index 00000000000..8164d9623b8 --- /dev/null +++ b/lib/private/db/querybuilder/expressionbuilder/mysqlexpressionbuilder.php @@ -0,0 +1,39 @@ +<?php +/** + * @author Joas Schilling <nickvergessen@owncloud.com> + * + * @copyright Copyright (c) 2016, 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\DB\QueryBuilder\ExpressionBuilder; + + +use OC\DB\QueryBuilder\QueryFunction; +use OCP\DB\QueryBuilder\IQueryBuilder; + +class MySqlExpressionBuilder extends ExpressionBuilder { + + /** + * @inheritdoc + */ + public function iLike($x, $y, $type = null) { + $x = $this->helper->quoteColumnName($x); + $y = $this->helper->quoteColumnName($y); + return $this->expressionBuilder->comparison($x, ' COLLATE utf8_general_ci LIKE', $y); + } + +} diff --git a/lib/private/db/querybuilder/expressionbuilder/ociexpressionbuilder.php b/lib/private/db/querybuilder/expressionbuilder/ociexpressionbuilder.php index 6a6d0f455f6..bd7daa23911 100644 --- a/lib/private/db/querybuilder/expressionbuilder/ociexpressionbuilder.php +++ b/lib/private/db/querybuilder/expressionbuilder/ociexpressionbuilder.php @@ -149,4 +149,13 @@ class OCIExpressionBuilder extends ExpressionBuilder { return parent::castColumn($column, $type); } + + /** + * @inheritdoc + */ + public function iLike($x, $y, $type = null) { + $x = $this->helper->quoteColumnName($x); + $y = $this->helper->quoteColumnName($y); + return new QueryFunction('REGEXP_LIKE('.$x.', \'^\' || REPLACE('.$y.', \'%\', \'.*\') || \'$\', \'i\')'); + } } diff --git a/lib/private/db/querybuilder/expressionbuilder/pgsqlexpressionbuilder.php b/lib/private/db/querybuilder/expressionbuilder/pgsqlexpressionbuilder.php index 8a0b68db998..ac2d7bf2421 100644 --- a/lib/private/db/querybuilder/expressionbuilder/pgsqlexpressionbuilder.php +++ b/lib/private/db/querybuilder/expressionbuilder/pgsqlexpressionbuilder.php @@ -42,4 +42,14 @@ class PgSqlExpressionBuilder extends ExpressionBuilder { return parent::castColumn($column, $type); } + + /** + * @inheritdoc + */ + public function iLike($x, $y, $type = null) { + $x = $this->helper->quoteColumnName($x); + $y = $this->helper->quoteColumnName($y); + return $this->expressionBuilder->comparison($x, 'ILIKE', $y); + } + } diff --git a/lib/private/db/querybuilder/querybuilder.php b/lib/private/db/querybuilder/querybuilder.php index ff31ffbc043..de803116dc4 100644 --- a/lib/private/db/querybuilder/querybuilder.php +++ b/lib/private/db/querybuilder/querybuilder.php @@ -21,9 +21,11 @@ namespace OC\DB\QueryBuilder; +use Doctrine\DBAL\Platforms\MySqlPlatform; use Doctrine\DBAL\Platforms\PostgreSqlPlatform; use OC\DB\OracleConnection; use OC\DB\QueryBuilder\ExpressionBuilder\ExpressionBuilder; +use OC\DB\QueryBuilder\ExpressionBuilder\MySqlExpressionBuilder; use OC\DB\QueryBuilder\ExpressionBuilder\OCIExpressionBuilder; use OC\DB\QueryBuilder\ExpressionBuilder\PgSqlExpressionBuilder; use OCP\DB\QueryBuilder\IQueryBuilder; @@ -91,6 +93,8 @@ class QueryBuilder implements IQueryBuilder { return new OCIExpressionBuilder($this->connection); } else if ($this->connection->getDatabasePlatform() instanceof PostgreSqlPlatform) { return new PgSqlExpressionBuilder($this->connection); + } else if ($this->connection->getDatabasePlatform() instanceof MySqlPlatform) { + return new MySqlExpressionBuilder($this->connection); } else { return new ExpressionBuilder($this->connection); } diff --git a/lib/private/files/storage/common.php b/lib/private/files/storage/common.php index edc570c967d..1d4801e5b97 100644 --- a/lib/private/files/storage/common.php +++ b/lib/private/files/storage/common.php @@ -613,6 +613,10 @@ abstract class Common implements Storage, ILockingStorage { return $this->rename($sourceInternalPath, $targetInternalPath); } + if (!$sourceStorage->isDeletable($sourceInternalPath)) { + return false; + } + $result = $this->copyFromStorage($sourceStorage, $sourceInternalPath, $targetInternalPath, true); if ($result) { if ($sourceStorage->is_dir($sourceInternalPath)) { diff --git a/lib/private/files/storage/wrapper/encryption.php b/lib/private/files/storage/wrapper/encryption.php index 068a688cb74..1b0f39428a4 100644 --- a/lib/private/files/storage/wrapper/encryption.php +++ b/lib/private/files/storage/wrapper/encryption.php @@ -585,6 +585,10 @@ class Encryption extends Wrapper { // - copy the copyKeys() call from $this->copyBetweenStorage to this method // - remove $this->copyBetweenStorage + if (!$sourceStorage->isDeletable($sourceInternalPath)) { + return false; + } + $result = $this->copyBetweenStorage($sourceStorage, $sourceInternalPath, $targetInternalPath, $preserveMtime, true); if ($result) { if ($sourceStorage->is_dir($sourceInternalPath)) { diff --git a/lib/private/files/stream/encryption.php b/lib/private/files/stream/encryption.php index 63949035b5a..37a1d75519d 100644 --- a/lib/private/files/stream/encryption.php +++ b/lib/private/files/stream/encryption.php @@ -183,7 +183,7 @@ class Encryption extends Wrapper { * * @param resource $source * @param string $mode - * @param array $context + * @param resource $context * @param string $protocol * @param string $class * @return resource diff --git a/lib/private/files/utils/scanner.php b/lib/private/files/utils/scanner.php index 59673a306cb..bc815f5f6da 100644 --- a/lib/private/files/utils/scanner.php +++ b/lib/private/files/utils/scanner.php @@ -119,6 +119,10 @@ class Scanner extends PublicEmitter { if (is_null($mount->getStorage())) { continue; } + // don't scan the root storage + if ($mount->getStorage()->instanceOfStorage('\OC\Files\Storage\Local') && $mount->getMountPoint() === '/') { + continue; + } $scanner = $mount->getStorage()->getScanner(); $this->attachListener($mount); $scanner->backgroundScan(); diff --git a/lib/private/group/dummy.php b/lib/private/group/dummy.php index c0d206a34e1..97f00385954 100644 --- a/lib/private/group/dummy.php +++ b/lib/private/group/dummy.php @@ -114,6 +114,7 @@ class OC_Group_Dummy extends OC_Group_Backend { if(isset($this->groups[$gid])) { if(($index=array_search($uid, $this->groups[$gid]))!==false) { unset($this->groups[$gid][$index]); + return true; }else{ return false; } diff --git a/lib/private/group/manager.php b/lib/private/group/manager.php index 98e5551bcc5..7eca249c701 100644 --- a/lib/private/group/manager.php +++ b/lib/private/group/manager.php @@ -150,6 +150,10 @@ class Manager extends PublicEmitter implements IGroupManager { return $this->getGroupObject($gid); } + /** + * @param string $gid + * @return \OCP\IGroup + */ protected function getGroupObject($gid) { $backends = array(); foreach ($this->backends as $backend) { diff --git a/lib/private/memcache/factory.php b/lib/private/memcache/factory.php index 21149d8b6bf..204ded7d5ab 100644 --- a/lib/private/memcache/factory.php +++ b/lib/private/memcache/factory.php @@ -172,7 +172,7 @@ class Factory implements ICacheFactory { /** * @see \OC\Memcache\Factory::createLocal() * @param string $prefix - * @return \OC\Memcache\Cache|null + * @return Cache */ public function createLowLatency($prefix = '') { return $this->createLocal($prefix); diff --git a/lib/private/preview.php b/lib/private/preview.php index df6eeceddcb..4fca56dd984 100644 --- a/lib/private/preview.php +++ b/lib/private/preview.php @@ -202,7 +202,7 @@ class Preview { /** * returns the max width set in ownCloud's config * - * @return string + * @return integer */ public function getConfigMaxX() { return $this->configMaxWidth; @@ -211,7 +211,7 @@ class Preview { /** * returns the max height set in ownCloud's config * - * @return string + * @return integer */ public function getConfigMaxY() { return $this->configMaxHeight; @@ -546,7 +546,7 @@ class Preview { /** * Determines the size of the preview we should be looking for in the cache * - * @return int[] + * @return integer[] */ private function simulatePreviewDimensions() { $askedWidth = $this->getMaxX(); @@ -570,7 +570,7 @@ class Preview { * * @param int $originalWidth * @param int $originalHeight - * @return \int[] + * @return integer[] */ private function applyAspectRatio($askedWidth, $askedHeight, $originalWidth = 0, $originalHeight = 0) { if(!$originalWidth){ @@ -602,7 +602,7 @@ class Preview { * @param int $askedHeight * @param int $previewWidth * @param int $previewHeight - * @return \int[] + * @return integer[] */ private function applyCover($askedWidth, $askedHeight, $previewWidth, $previewHeight) { $originalRatio = $previewWidth / $previewHeight; @@ -628,7 +628,7 @@ class Preview { * @param int $askedWidth * @param int $askedHeight * - * @return \int[] + * @return integer[] */ private function fixSize($askedWidth, $askedHeight) { if ($this->scalingUp) { @@ -921,7 +921,7 @@ class Preview { * @param int $askedWidth * @param int $askedHeight * @param int $previewWidth - * @param null $previewHeight + * @param int $previewHeight * * @return int[] */ @@ -971,7 +971,7 @@ class Preview { * @param int $askedWidth * @param int $askedHeight * @param int $previewWidth - * @param null $previewHeight + * @param int $previewHeight */ private function crop($image, $askedWidth, $askedHeight, $previewWidth, $previewHeight = null) { $cropX = floor(abs($askedWidth - $previewWidth) * 0.5); @@ -990,7 +990,7 @@ class Preview { * @param int $askedWidth * @param int $askedHeight * @param int $previewWidth - * @param null $previewHeight + * @param int $previewHeight */ private function cropAndFill($image, $askedWidth, $askedHeight, $previewWidth, $previewHeight) { if ($previewWidth > $askedWidth) { @@ -1218,7 +1218,7 @@ class Preview { * @param int $maxDim * @param string $dimName * - * @return mixed + * @return integer */ private function limitMaxDim($dim, $maxDim, $dimName) { if (!is_null($maxDim)) { diff --git a/lib/private/preview/movie.php b/lib/private/preview/movie.php index ee56f017229..43a8d674fc9 100644 --- a/lib/private/preview/movie.php +++ b/lib/private/preview/movie.php @@ -83,9 +83,9 @@ class Movie extends Provider { $tmpPath = \OC::$server->getTempManager()->getTemporaryFile(); if (self::$avconvBinary) { - $cmd = self::$avconvBinary . ' -an -y -ss ' . escapeshellarg($second) . + $cmd = self::$avconvBinary . ' -y -ss ' . escapeshellarg($second) . ' -i ' . escapeshellarg($absPath) . - ' -f mjpeg -vframes 1 -vsync 1 ' . escapeshellarg($tmpPath) . + ' -an -f mjpeg -vframes 1 -vsync 1 ' . escapeshellarg($tmpPath) . ' > /dev/null 2>&1'; } else { $cmd = self::$ffmpegBinary . ' -y -ss ' . escapeshellarg($second) . diff --git a/lib/private/share20/manager.php b/lib/private/share20/manager.php index 4cff3dc818b..9b33e947557 100644 --- a/lib/private/share20/manager.php +++ b/lib/private/share20/manager.php @@ -517,8 +517,20 @@ class Manager implements IManager { // Verify if there are any issues with the path $this->pathCreateChecks($share->getNode()); - // On creation of a share the owner is always the owner of the path - $share->setShareOwner($share->getNode()->getOwner()->getUID()); + /* + * On creation of a share the owner is always the owner of the path + * Except for mounted federated shares. + */ + $storage = $share->getNode()->getStorage(); + if ($storage->instanceOfStorage('OCA\Files_Sharing\External\Storage')) { + $parent = $share->getNode()->getParent(); + while($parent->getStorage()->instanceOfStorage('OCA\Files_Sharing\External\Storage')) { + $parent = $parent->getParent(); + } + $share->setShareOwner($parent->getOwner()->getUID()); + } else { + $share->setShareOwner($share->getNode()->getOwner()->getUID()); + } // Cannot share with the owner if ($share->getShareType() === \OCP\Share::SHARE_TYPE_USER && diff --git a/lib/private/systemtag/systemtagobjectmapper.php b/lib/private/systemtag/systemtagobjectmapper.php index 1efb4f0f6e0..586351cf8c1 100644 --- a/lib/private/systemtag/systemtagobjectmapper.php +++ b/lib/private/systemtag/systemtagobjectmapper.php @@ -95,7 +95,7 @@ class SystemTagObjectMapper implements ISystemTagObjectMapper { /** * {@inheritdoc} */ - public function getObjectIdsForTags($tagIds, $objectType) { + public function getObjectIdsForTags($tagIds, $objectType, $limit = 0, $offset = '') { if (!is_array($tagIds)) { $tagIds = [$tagIds]; } @@ -103,12 +103,23 @@ class SystemTagObjectMapper implements ISystemTagObjectMapper { $this->assertTagsExist($tagIds); $query = $this->connection->getQueryBuilder(); - $query->select($query->createFunction('DISTINCT(`objectid`)')) + $query->selectDistinct('objectid') ->from(self::RELATION_TABLE) - ->where($query->expr()->in('systemtagid', $query->createParameter('tagids'))) - ->andWhere($query->expr()->eq('objecttype', $query->createParameter('objecttype'))) - ->setParameter('tagids', $tagIds, IQueryBuilder::PARAM_INT_ARRAY) - ->setParameter('objecttype', $objectType); + ->where($query->expr()->in('systemtagid', $query->createNamedParameter($tagIds, IQueryBuilder::PARAM_INT_ARRAY))) + ->andWhere($query->expr()->eq('objecttype', $query->createNamedParameter($objectType))); + + if ($limit) { + if (sizeof($tagIds) !== 1) { + throw new \InvalidArgumentException('Limit is only allowed with a single tag'); + } + + $query->setMaxResults($limit) + ->orderBy('objectid', 'ASC'); + + if ($offset !== '') { + $query->andWhere($query->expr()->gt('objectid', $query->createNamedParameter($offset))); + } + } $objectIds = []; @@ -208,7 +219,7 @@ class SystemTagObjectMapper implements ISystemTagObjectMapper { ->where($query->expr()->in('objectid', $query->createParameter('objectids'))) ->andWhere($query->expr()->eq('objecttype', $query->createParameter('objecttype'))) ->andWhere($query->expr()->eq('systemtagid', $query->createParameter('tagid'))) - ->setParameter('objectids', $objIds, IQueryBuilder::PARAM_INT_ARRAY) + ->setParameter('objectids', $objIds, IQueryBuilder::PARAM_STR_ARRAY) ->setParameter('tagid', $tagId) ->setParameter('objecttype', $objectType); |