diff options
Diffstat (limited to 'lib')
25 files changed, 132 insertions, 126 deletions
diff --git a/lib/autoloader.php b/lib/autoloader.php index e7262af0ca9..87a07f6da12 100644 --- a/lib/autoloader.php +++ b/lib/autoloader.php @@ -164,6 +164,10 @@ class Autoloader { $pathsToRequire = $this->memoryCache->get($class); } + if(class_exists($class, false)) { + return false; + } + if (!is_array($pathsToRequire)) { // No cache or cache miss $pathsToRequire = array(); diff --git a/lib/base.php b/lib/base.php index 16db8f4dcd2..1a3dbbaa56a 100644 --- a/lib/base.php +++ b/lib/base.php @@ -274,7 +274,7 @@ class OC { $l->t('Cannot write into "config" directory!'), $l->t('This can usually be fixed by ' . '%sgiving the webserver write access to the config directory%s.', - array('<a href="' . $urlGenerator->linkToDocs('admin-dir_permissions') . '" target="_blank">', '</a>')) + array('<a href="' . $urlGenerator->linkToDocs('admin-dir_permissions') . '" target="_blank" rel="noreferrer">', '</a>')) ); } } diff --git a/lib/composer/composer/autoload_psr4.php b/lib/composer/composer/autoload_psr4.php index a4b49f0f55f..4610a912c6d 100644 --- a/lib/composer/composer/autoload_psr4.php +++ b/lib/composer/composer/autoload_psr4.php @@ -7,4 +7,5 @@ $baseDir = dirname(dirname($vendorDir)); return array( 'OC\\' => array($baseDir . '/lib/private'), + 'OCP\\' => array($baseDir . '/lib/public'), ); diff --git a/lib/private/Server.php b/lib/private/Server.php index d68a361955f..48ee4b27d32 100644 --- a/lib/private/Server.php +++ b/lib/private/Server.php @@ -261,7 +261,8 @@ class Server extends ServerContainer implements IServerContainer { return new \OC\L10N\Factory( $c->getConfig(), $c->getRequest(), - $c->getUserSession() + $c->getUserSession(), + \OC::$SERVERROOT ); }); $this->registerService('URLGenerator', function (Server $c) { diff --git a/lib/private/share20/defaultshareprovider.php b/lib/private/Share20/DefaultShareProvider.php index b91ac24d44f..f6171f87992 100644 --- a/lib/private/share20/defaultshareprovider.php +++ b/lib/private/Share20/DefaultShareProvider.php @@ -471,18 +471,7 @@ class DefaultShareProvider implements IShareProvider { * Reshares for this user are shares where they are the owner. */ if ($reshares === false) { - //Special case for old shares created via the web UI - $or1 = $qb->expr()->andX( - $qb->expr()->eq('uid_owner', $qb->createNamedParameter($userId)), - $qb->expr()->isNull('uid_initiator') - ); - - $qb->andWhere( - $qb->expr()->orX( - $qb->expr()->eq('uid_initiator', $qb->createNamedParameter($userId)), - $or1 - ) - ); + $qb->andWhere($qb->expr()->eq('uid_initiator', $qb->createNamedParameter($userId))); } else { $qb->andWhere( $qb->expr()->orX( @@ -765,18 +754,8 @@ class DefaultShareProvider implements IShareProvider { $share->setToken($data['token']); } - if ($data['uid_initiator'] === null) { - //OLD SHARE - $share->setSharedBy($data['uid_owner']); - $path = $this->getNode($share->getSharedBy(), (int)$data['file_source']); - - $owner = $path->getOwner(); - $share->setShareOwner($owner->getUID()); - } else { - //New share! - $share->setSharedBy($data['uid_initiator']); - $share->setShareOwner($data['uid_owner']); - } + $share->setSharedBy($data['uid_initiator']); + $share->setShareOwner($data['uid_owner']); $share->setNodeId((int)$data['file_source']); $share->setNodeType($data['item_type']); @@ -792,30 +771,6 @@ class DefaultShareProvider implements IShareProvider { } /** - * Get the node with file $id for $user - * - * @param string $user The userId - * @param int $id - * @return \OCP\Files\File|\OCP\Files\Folder - * @throws InvalidShare - */ - private function getNode($user, $id) { - try { - $userFolder = $this->rootFolder->getUserFolder($user); - } catch (NotFoundException $e) { - throw new InvalidShare(); - } - - $nodes = $userFolder->getById($id); - - if (empty($nodes)) { - throw new InvalidShare(); - } - - return $nodes[0]; - } - - /** * Resolve a group share to a user specific share * Thus if the user moved their group share make sure this is properly reflected here. * diff --git a/lib/private/share20/exception/backenderror.php b/lib/private/Share20/Exception/BackendError.php index f15dea4a243..f15dea4a243 100644 --- a/lib/private/share20/exception/backenderror.php +++ b/lib/private/Share20/Exception/BackendError.php diff --git a/lib/private/share20/exception/invalidshare.php b/lib/private/Share20/Exception/InvalidShare.php index c176e4424ba..c176e4424ba 100644 --- a/lib/private/share20/exception/invalidshare.php +++ b/lib/private/Share20/Exception/InvalidShare.php diff --git a/lib/private/share20/exception/providerexception.php b/lib/private/Share20/Exception/ProviderException.php index a14d5266581..a14d5266581 100644 --- a/lib/private/share20/exception/providerexception.php +++ b/lib/private/Share20/Exception/ProviderException.php diff --git a/lib/private/share20/manager.php b/lib/private/Share20/Manager.php index 95662dc0b60..4737de002cb 100644 --- a/lib/private/share20/manager.php +++ b/lib/private/Share20/Manager.php @@ -361,6 +361,11 @@ class Manager implements IManager { * @throws \Exception */ protected function groupCreateChecks(\OCP\Share\IShare $share) { + // Verify group shares are allowed + if (!$this->allowGroupSharing()) { + throw new \Exception('Group sharing is now allowed'); + } + // Verify if the user can share with this group if ($this->shareWithGroupMembersOnly()) { $sharedBy = $this->userManager->get($share->getSharedBy()); @@ -1108,6 +1113,13 @@ class Manager implements IManager { return $this->config->getAppValue('core', 'shareapi_only_share_with_group_members', 'no') === 'yes'; } + /** + * Check if users can share with groups + * @return bool + */ + public function allowGroupSharing() { + return $this->config->getAppValue('core', 'shareapi_allow_group_sharing', 'yes') === 'yes'; + } /** * Copied from \OC_Util::isSharingDisabledForUser diff --git a/lib/private/share20/providerfactory.php b/lib/private/Share20/ProviderFactory.php index 4cb1ac71a88..4cb1ac71a88 100644 --- a/lib/private/share20/providerfactory.php +++ b/lib/private/Share20/ProviderFactory.php diff --git a/lib/private/share20/share.php b/lib/private/Share20/Share.php index 6edd0e6886a..6edd0e6886a 100644 --- a/lib/private/share20/share.php +++ b/lib/private/Share20/Share.php diff --git a/lib/private/activitymanager.php b/lib/private/activitymanager.php index 68bb8c13401..9258b7298cc 100644 --- a/lib/private/activitymanager.php +++ b/lib/private/activitymanager.php @@ -256,11 +256,11 @@ class ActivityManager implements IManager { foreach ($this->getExtensions() as $c) { $result = $c->getNotificationTypes($languageCode); if (is_array($result)) { - if (class_exists('\OCA\Files\Activity') && $c instanceof \OCA\Files\Activity) { + if (class_exists('\OCA\Files\Activity', false) && $c instanceof \OCA\Files\Activity) { $filesNotificationTypes = $result; continue; } - if (class_exists('\OCA\Files_Sharing\Activity') && $c instanceof \OCA\Files_Sharing\Activity) { + if (class_exists('\OCA\Files_Sharing\Activity', false) && $c instanceof \OCA\Files_Sharing\Activity) { $sharingNotificationTypes = $result; continue; } diff --git a/lib/private/appframework/http/request.php b/lib/private/appframework/http/request.php index caddb5a235d..2dc636fcff2 100644 --- a/lib/private/appframework/http/request.php +++ b/lib/private/appframework/http/request.php @@ -44,6 +44,13 @@ use OCP\Security\ISecureRandom; /** * Class for accessing variables in the request. * This class provides an immutable object with request variables. + * + * @property mixed[] cookies + * @property mixed[] env + * @property mixed[] files + * @property string method + * @property mixed[] parameters + * @property mixed[] server */ class Request implements \ArrayAccess, \Countable, IRequest { @@ -260,7 +267,7 @@ class Request implements \ArrayAccess, \Countable, IRequest { * @param string $id */ public function __unset($id) { - throw new \RunTimeException('You cannot change the contents of the request object'); + throw new \RuntimeException('You cannot change the contents of the request object'); } /** diff --git a/lib/private/config.php b/lib/private/config.php index 368dafd0460..9bb5c299463 100644 --- a/lib/private/config.php +++ b/lib/private/config.php @@ -239,7 +239,7 @@ class Config { throw new HintException( "Can't write into config directory!", 'This can usually be fixed by ' - .'<a href="' . $url . '" target="_blank">giving the webserver write access to the config directory</a>.'); + .'<a href="' . $url . '" target="_blank" rel="noreferrer">giving the webserver write access to the config directory</a>.'); } // Try to acquire a file lock diff --git a/lib/private/filechunking.php b/lib/private/filechunking.php index d6ff160870d..604a607336c 100644 --- a/lib/private/filechunking.php +++ b/lib/private/filechunking.php @@ -150,59 +150,21 @@ class OC_FileChunking { * Assembles the chunks into the file specified by the path. * Also triggers the relevant hooks and proxies. * - * @param \OC\Files\Storage\Storage $storage + * @param \OC\Files\Storage\Storage $storage storage * @param string $path target path relative to the storage - * @param string $absolutePath - * @return bool assembled file size or false if file could not be created + * @return bool true on success or false if file could not be created * * @throws \OC\ServerNotAvailableException */ - public function file_assemble($storage, $path, $absolutePath) { - $data = ''; + public function file_assemble($storage, $path) { // use file_put_contents as method because that best matches what this function does if (\OC\Files\Filesystem::isValidPath($path)) { - $exists = $storage->file_exists($path); - $run = true; - $hookPath = \OC\Files\Filesystem::getView()->getRelativePath($absolutePath); - if(!$exists) { - OC_Hook::emit( - \OC\Files\Filesystem::CLASSNAME, - \OC\Files\Filesystem::signal_create, - array( - \OC\Files\Filesystem::signal_param_path => $hookPath, - \OC\Files\Filesystem::signal_param_run => &$run - ) - ); - } - OC_Hook::emit( - \OC\Files\Filesystem::CLASSNAME, - \OC\Files\Filesystem::signal_write, - array( - \OC\Files\Filesystem::signal_param_path => $hookPath, - \OC\Files\Filesystem::signal_param_run => &$run - ) - ); - if(!$run) { - return false; - } $target = $storage->fopen($path, 'w'); - if($target) { + if ($target) { $count = $this->assemble($target); fclose($target); - if(!$exists) { - OC_Hook::emit( - \OC\Files\Filesystem::CLASSNAME, - \OC\Files\Filesystem::signal_post_create, - array( \OC\Files\Filesystem::signal_param_path => $hookPath) - ); - } - OC_Hook::emit( - \OC\Files\Filesystem::CLASSNAME, - \OC\Files\Filesystem::signal_post_write, - array( \OC\Files\Filesystem::signal_param_path => $hookPath) - ); return $count > 0; - }else{ + } else { return false; } } diff --git a/lib/private/files/cache/wrapper/cachewrapper.php b/lib/private/files/cache/wrapper/cachewrapper.php index 4080883419e..883f4709358 100644 --- a/lib/private/files/cache/wrapper/cachewrapper.php +++ b/lib/private/files/cache/wrapper/cachewrapper.php @@ -54,7 +54,7 @@ class CacheWrapper extends Cache { /** * get the stored metadata of a file or folder * - * @param string /int $file + * @param string|int $file * @return ICacheEntry|false */ public function get($file) { diff --git a/lib/private/installer.php b/lib/private/installer.php index 36fda28cd27..c026383e26e 100644 --- a/lib/private/installer.php +++ b/lib/private/installer.php @@ -526,8 +526,12 @@ class OC_Installer{ * Installs shipped apps * * This function installs all apps found in the 'apps' directory that should be enabled by default; + * @param bool $softErrors When updating we ignore errors and simply log them, better to have a + * working ownCloud at the end instead of an aborted update. + * @return array Array of error messages (appid => Exception) */ - public static function installShippedApps() { + public static function installShippedApps($softErrors = false) { + $errors = []; foreach(OC::$APPSROOTS as $app_dir) { if($dir = opendir( $app_dir['path'] )) { while( false !== ( $filename = readdir( $dir ))) { @@ -538,7 +542,16 @@ class OC_Installer{ $enabled = isset($info['default_enable']); if (($enabled || in_array($filename, \OC::$server->getAppManager()->getAlwaysEnabledApps())) && \OC::$server->getConfig()->getAppValue($filename, 'enabled') !== 'no') { - OC_Installer::installShippedApp($filename); + if ($softErrors) { + try { + OC_Installer::installShippedApp($filename); + } catch (\Doctrine\DBAL\Exception\TableExistsException $e) { + $errors[$filename] = $e; + continue; + } + } else { + OC_Installer::installShippedApp($filename); + } \OC::$server->getConfig()->setAppValue($filename, 'enabled', 'yes'); } } @@ -548,6 +561,8 @@ class OC_Installer{ closedir( $dir ); } } + + return $errors; } /** diff --git a/lib/private/integritycheck/iterator/excludefoldersbypathfilteriterator.php b/lib/private/integritycheck/iterator/excludefoldersbypathfilteriterator.php index 766897e7517..1082e97c296 100644 --- a/lib/private/integritycheck/iterator/excludefoldersbypathfilteriterator.php +++ b/lib/private/integritycheck/iterator/excludefoldersbypathfilteriterator.php @@ -34,10 +34,11 @@ class ExcludeFoldersByPathFilterIterator extends \RecursiveFilterIterator { $excludedFolders = [ rtrim($root . '/data', '/'), - rtrim($root .'/themes', '/'), + rtrim($root . '/themes', '/'), rtrim($root . '/config', '/'), rtrim($root . '/apps', '/'), rtrim($root . '/assets', '/'), + rtrim($root . '/lost+found', '/'), ]; $customDataDir = \OC::$server->getConfig()->getSystemValue('datadirectory', ''); if($customDataDir !== '') { diff --git a/lib/private/l10n/factory.php b/lib/private/l10n/factory.php index 1440e9510c5..fd093c3601b 100644 --- a/lib/private/l10n/factory.php +++ b/lib/private/l10n/factory.php @@ -64,17 +64,23 @@ class Factory implements IFactory { /** @var IUserSession */ protected $userSession; + /** @var string */ + protected $serverRoot; + /** * @param IConfig $config * @param IRequest $request * @param IUserSession $userSession + * @param string $serverRoot */ public function __construct(IConfig $config, IRequest $request, - IUserSession $userSession) { + IUserSession $userSession, + $serverRoot) { $this->config = $config; $this->request = $request; $this->userSession = $userSession; + $this->serverRoot = $serverRoot; } /** @@ -186,6 +192,23 @@ class Factory implements IFactory { } } + // merge with translations from theme + $theme = $this->config->getSystemValue('theme'); + if (!empty($theme)) { + $themeDir = $this->serverRoot . '/themes/' . $theme . substr($dir, strlen($this->serverRoot)); + + if (is_dir($themeDir)) { + $files = scandir($themeDir); + if ($files !== false) { + foreach ($files as $file) { + if (substr($file, -5) === '.json' && substr($file, 0, 4) !== 'l10n') { + $available[] = substr($file, 0, -5); + } + } + } + } + } + $this->availableLanguages[$key] = $available; return $available; } @@ -263,22 +286,22 @@ class Factory implements IFactory { $i18nDir = $this->findL10nDir($app); $transFile = strip_tags($i18nDir) . strip_tags($lang) . '.json'; - if ((\OC_Helper::isSubDirectory($transFile, \OC::$SERVERROOT . '/core/l10n/') - || \OC_Helper::isSubDirectory($transFile, \OC::$SERVERROOT . '/lib/l10n/') - || \OC_Helper::isSubDirectory($transFile, \OC::$SERVERROOT . '/settings/l10n/') + if ((\OC_Helper::isSubDirectory($transFile, $this->serverRoot . '/core/l10n/') + || \OC_Helper::isSubDirectory($transFile, $this->serverRoot . '/lib/l10n/') + || \OC_Helper::isSubDirectory($transFile, $this->serverRoot . '/settings/l10n/') || \OC_Helper::isSubDirectory($transFile, \OC_App::getAppPath($app) . '/l10n/') ) && file_exists($transFile)) { // load the translations file $languageFiles[] = $transFile; + } - // merge with translations from theme - $theme = $this->config->getSystemValue('theme'); - if (!empty($theme)) { - $transFile = \OC::$SERVERROOT . '/themes/' . $theme . substr($transFile, strlen(\OC::$SERVERROOT)); - if (file_exists($transFile)) { - $languageFiles[] = $transFile; - } + // merge with translations from theme + $theme = $this->config->getSystemValue('theme'); + if (!empty($theme)) { + $transFile = $this->serverRoot . '/themes/' . $theme . substr($transFile, strlen($this->serverRoot)); + if (file_exists($transFile)) { + $languageFiles[] = $transFile; } } @@ -293,14 +316,14 @@ class Factory implements IFactory { */ protected function findL10nDir($app = null) { if (in_array($app, ['core', 'lib', 'settings'])) { - if (file_exists(\OC::$SERVERROOT . '/' . $app . '/l10n/')) { - return \OC::$SERVERROOT . '/' . $app . '/l10n/'; + if (file_exists($this->serverRoot . '/' . $app . '/l10n/')) { + return $this->serverRoot . '/' . $app . '/l10n/'; } } else if ($app && \OC_App::getAppPath($app) !== false) { // Check if the app is in the app folder return \OC_App::getAppPath($app) . '/l10n/'; } - return \OC::$SERVERROOT . '/core/l10n/'; + return $this->serverRoot . '/core/l10n/'; } diff --git a/lib/private/log/owncloud.php b/lib/private/log/owncloud.php index 6399d7ee588..9c106299e4c 100644 --- a/lib/private/log/owncloud.php +++ b/lib/private/log/owncloud.php @@ -88,14 +88,25 @@ class OC_Log_Owncloud { $remoteAddr = $request->getRemoteAddress(); // remove username/passwords from URLs before writing the to the log file $time = $time->format($format); - $minLevel=min($config->getValue( "loglevel", \OCP\Util::WARN ), \OCP\Util::ERROR); - if($minLevel == \OCP\Util::DEBUG) { - $url = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '--'; - $method = isset($_SERVER['REQUEST_METHOD']) ? $_SERVER['REQUEST_METHOD'] : '--'; - $entry = compact('reqId', 'remoteAddr', 'app', 'message', 'level', 'time', 'method', 'url'); + $url = ($request->getRequestUri() !== '') ? $request->getRequestUri() : '--'; + $method = is_string($request->getMethod()) ? $request->getMethod() : '--'; + if(\OC::$server->getConfig()->getSystemValue('installed', false)) { + $userObj = \OC::$server->getUserSession()->getUser(); } else { - $entry = compact('reqId', 'remoteAddr', 'app', 'message', 'level', 'time'); + $userObj = null; } + $user = !is_null($userObj) ? $userObj->getUID() : '--'; + $entry = compact( + 'reqId', + 'remoteAddr', + 'app', + 'message', + 'level', + 'time', + 'method', + 'url', + 'user' + ); $entry = json_encode($entry); $handle = @fopen(self::$logFile, 'a'); @chmod(self::$logFile, 0640); diff --git a/lib/private/systemtag/systemtagobjectmapper.php b/lib/private/systemtag/systemtagobjectmapper.php index 586351cf8c1..412842b69e3 100644 --- a/lib/private/systemtag/systemtagobjectmapper.php +++ b/lib/private/systemtag/systemtagobjectmapper.php @@ -64,6 +64,8 @@ class SystemTagObjectMapper implements ISystemTagObjectMapper { public function getTagIdsForObjects($objIds, $objectType) { if (!is_array($objIds)) { $objIds = [$objIds]; + } else if (empty($objIds)) { + return []; } $query = $this->connection->getQueryBuilder(); diff --git a/lib/private/updater.php b/lib/private/updater.php index 4f74481562b..0d567b8dfb9 100644 --- a/lib/private/updater.php +++ b/lib/private/updater.php @@ -333,7 +333,12 @@ class Updater extends BasicEmitter { // install new shipped apps on upgrade OC_App::loadApps('authentication'); - OC_Installer::installShippedApps(); + $errors = OC_Installer::installShippedApps(true); + foreach ($errors as $appId => $exception) { + /** @var \Exception $exception */ + $this->log->logException($exception, ['app' => $appId]); + $this->emit('\OC\Updater', 'failure', [$appId . ': ' . $exception->getMessage()]); + } // post-upgrade repairs $repair = new Repair(Repair::getRepairSteps()); diff --git a/lib/private/util.php b/lib/private/util.php index 88d78ad83c6..b320394f26d 100644 --- a/lib/private/util.php +++ b/lib/private/util.php @@ -657,7 +657,7 @@ class OC_Util { 'error' => $l->t('Cannot write into "config" directory'), 'hint' => $l->t('This can usually be fixed by ' . '%sgiving the webserver write access to the config directory%s.', - array('<a href="' . $urlGenerator->linkToDocs('admin-dir_permissions') . '" target="_blank">', '</a>')) + array('<a href="' . $urlGenerator->linkToDocs('admin-dir_permissions') . '" target="_blank" rel="noreferrer">', '</a>')) ); } } @@ -673,7 +673,7 @@ class OC_Util { 'hint' => $l->t('This can usually be fixed by ' . '%sgiving the webserver write access to the apps directory%s' . ' or disabling the appstore in the config file.', - array('<a href="' . $urlGenerator->linkToDocs('admin-dir_permissions') . '" target="_blank">', '</a>')) + array('<a href="' . $urlGenerator->linkToDocs('admin-dir_permissions') . '" target="_blank" rel="noreferrer">', '</a>')) ); } } @@ -687,7 +687,7 @@ class OC_Util { $errors[] = array( 'error' => $l->t('Cannot create "data" directory (%s)', array($CONFIG_DATADIRECTORY)), 'hint' => $l->t('This can usually be fixed by ' - . '<a href="%s" target="_blank">giving the webserver write access to the root directory</a>.', + . '<a href="%s" target="_blank" rel="noreferrer">giving the webserver write access to the root directory</a>.', array($urlGenerator->linkToDocs('admin-dir_permissions'))) ); } @@ -695,7 +695,7 @@ class OC_Util { //common hint for all file permissions error messages $permissionsHint = $l->t('Permissions can usually be fixed by ' . '%sgiving the webserver write access to the root directory%s.', - array('<a href="' . $urlGenerator->linkToDocs('admin-dir_permissions') . '" target="_blank">', '</a>')); + array('<a href="' . $urlGenerator->linkToDocs('admin-dir_permissions') . '" target="_blank" rel="noreferrer">', '</a>')); $errors[] = array( 'error' => 'Data directory (' . $CONFIG_DATADIRECTORY . ') not writable by ownCloud', 'hint' => $permissionsHint diff --git a/lib/public/iservercontainer.php b/lib/public/IServerContainer.php index de48daeef88..de48daeef88 100644 --- a/lib/public/iservercontainer.php +++ b/lib/public/IServerContainer.php diff --git a/lib/public/share/imanager.php b/lib/public/share/imanager.php index 86a31e1f06d..64e5b554de9 100644 --- a/lib/public/share/imanager.php +++ b/lib/public/share/imanager.php @@ -222,6 +222,13 @@ interface IManager { public function shareWithGroupMembersOnly(); /** + * Check if users can share with groups + * @return bool + * @since 9.0.1 + */ + public function allowGroupSharing(); + + /** * Check if sharing is disabled for the given user * * @param string $userId |