summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
m---------3rdparty0
-rw-r--r--apps/files_external/lib/Lib/Storage/SMB.php2
-rw-r--r--apps/files_sharing/lib/External/Storage.php2
-rw-r--r--apps/theming/lib/ThemingDefaults.php6
-rw-r--r--apps/theming/tests/ThemingDefaultsTest.php2
-rw-r--r--apps/user_ldap/lib/Connection.php2
-rw-r--r--apps/user_ldap/lib/Proxy.php2
-rw-r--r--core/Command/Db/AddMissingIndices.php91
-rw-r--r--core/Command/Maintenance/Repair.php2
-rw-r--r--core/Command/Maintenance/UpdateTheme.php2
-rw-r--r--core/Migrations/Version13000Date20170718121200.php1
-rw-r--r--core/register_command.php1
-rw-r--r--lib/composer/composer/autoload_classmap.php1
-rw-r--r--lib/composer/composer/autoload_static.php1
-rw-r--r--lib/private/App/AppManager.php2
-rw-r--r--lib/private/Collaboration/Collaborators/MailPlugin.php30
-rw-r--r--lib/private/Files/ObjectStore/Swift.php2
-rw-r--r--lib/private/Files/Storage/Common.php3
-rw-r--r--lib/private/IntegrityCheck/Checker.php2
-rw-r--r--lib/private/OCS/DiscoveryService.php2
-rw-r--r--lib/private/Security/RateLimiting/Backend/MemoryCache.php2
-rw-r--r--lib/private/Server.php12
-rw-r--r--lib/private/TemplateLayout.php2
-rw-r--r--lib/private/URLGenerator.php2
-rw-r--r--lib/private/legacy/db.php4
-rw-r--r--lib/private/legacy/helper.php2
-rw-r--r--settings/ajax/uninstallapp.php4
-rw-r--r--tests/Core/Command/Maintenance/UpdateTheme.php2
-rw-r--r--tests/lib/App/AppManagerTest.php2
-rw-r--r--tests/lib/Collaboration/Collaborators/MailPluginTest.php139
-rw-r--r--tests/lib/IntegrityCheck/CheckerTest.php2
-rw-r--r--tests/lib/Security/RateLimiting/Backend/MemoryCacheTest.php2
32 files changed, 293 insertions, 38 deletions
diff --git a/3rdparty b/3rdparty
-Subproject f4e328bc4cc67011d206ca024483531a3b8c544
+Subproject 696f7683651fa2ee1f59cbde08c6f5fefbcaad0
diff --git a/apps/files_external/lib/Lib/Storage/SMB.php b/apps/files_external/lib/Lib/Storage/SMB.php
index 66a03548ea7..d8bbe8c4718 100644
--- a/apps/files_external/lib/Lib/Storage/SMB.php
+++ b/apps/files_external/lib/Lib/Storage/SMB.php
@@ -52,6 +52,7 @@ use OCP\Files\Notify\IChange;
use OCP\Files\Notify\IRenameChange;
use OCP\Files\Storage\INotifyStorage;
use OCP\Files\StorageNotAvailableException;
+use OCP\Util;
class SMB extends Common implements INotifyStorage {
/**
@@ -199,6 +200,7 @@ class SMB extends Common implements INotifyStorage {
$this->remove($target);
$result = $this->share->rename($absoluteSource, $absoluteTarget);
} catch (\Exception $e) {
+ \OC::$server->getLogger()->logException($e, ['level' => Util::WARN]);
return false;
}
unset($this->statCache[$absoluteSource], $this->statCache[$absoluteTarget]);
diff --git a/apps/files_sharing/lib/External/Storage.php b/apps/files_sharing/lib/External/Storage.php
index bae24e89e64..638f82f7027 100644
--- a/apps/files_sharing/lib/External/Storage.php
+++ b/apps/files_sharing/lib/External/Storage.php
@@ -261,7 +261,7 @@ class Storage extends DAV implements ISharedStorage {
* @return bool
*/
private function testRemoteUrl($url) {
- $cache = $this->memcacheFactory->create('files_sharing_remote_url');
+ $cache = $this->memcacheFactory->createDistributed('files_sharing_remote_url');
if($cache->hasKey($url)) {
return (bool)$cache->get($url);
}
diff --git a/apps/theming/lib/ThemingDefaults.php b/apps/theming/lib/ThemingDefaults.php
index fa43dd50ccd..05d387e6273 100644
--- a/apps/theming/lib/ThemingDefaults.php
+++ b/apps/theming/lib/ThemingDefaults.php
@@ -240,7 +240,7 @@ class ThemingDefaults extends \OC_Defaults {
* @return array scss variables to overwrite
*/
public function getScssVariables() {
- $cache = $this->cacheFactory->create('theming');
+ $cache = $this->cacheFactory->createDistributed('theming');
if ($value = $cache->get('getScssVariables')) {
return $value;
}
@@ -307,7 +307,7 @@ class ThemingDefaults extends \OC_Defaults {
* @return bool
*/
public function shouldReplaceIcons() {
- $cache = $this->cacheFactory->create('theming');
+ $cache = $this->cacheFactory->createDistributed('theming');
if($value = $cache->get('shouldReplaceIcons')) {
return (bool)$value;
}
@@ -329,7 +329,7 @@ class ThemingDefaults extends \OC_Defaults {
private function increaseCacheBuster() {
$cacheBusterKey = $this->config->getAppValue('theming', 'cachebuster', '0');
$this->config->setAppValue('theming', 'cachebuster', (int)$cacheBusterKey+1);
- $this->cacheFactory->create('theming')->clear('getScssVariables');
+ $this->cacheFactory->createDistributed('theming')->clear('getScssVariables');
}
/**
diff --git a/apps/theming/tests/ThemingDefaultsTest.php b/apps/theming/tests/ThemingDefaultsTest.php
index 52bf88e51dd..843c1d34f9e 100644
--- a/apps/theming/tests/ThemingDefaultsTest.php
+++ b/apps/theming/tests/ThemingDefaultsTest.php
@@ -78,7 +78,7 @@ class ThemingDefaultsTest extends TestCase {
$this->defaults = new \OC_Defaults();
$this->cacheFactory
->expects($this->any())
- ->method('create')
+ ->method('createDistributed')
->with('theming')
->willReturn($this->cache);
$this->template = new ThemingDefaults(
diff --git a/apps/user_ldap/lib/Connection.php b/apps/user_ldap/lib/Connection.php
index 1dcf9b72d7c..bde489e2710 100644
--- a/apps/user_ldap/lib/Connection.php
+++ b/apps/user_ldap/lib/Connection.php
@@ -100,7 +100,7 @@ class Connection extends LDAPUtility {
!is_null($configID));
$memcache = \OC::$server->getMemCacheFactory();
if($memcache->isAvailable()) {
- $this->cache = $memcache->create();
+ $this->cache = $memcache->createDistributed();
}
$helper = new Helper(\OC::$server->getConfig());
$this->doNotValidate = !in_array($this->configPrefix,
diff --git a/apps/user_ldap/lib/Proxy.php b/apps/user_ldap/lib/Proxy.php
index d372ff9c026..dc8c6fc77cc 100644
--- a/apps/user_ldap/lib/Proxy.php
+++ b/apps/user_ldap/lib/Proxy.php
@@ -50,7 +50,7 @@ abstract class Proxy {
$this->ldap = $ldap;
$memcache = \OC::$server->getMemCacheFactory();
if($memcache->isAvailable()) {
- $this->cache = $memcache->create();
+ $this->cache = $memcache->createDistributed();
}
}
diff --git a/core/Command/Db/AddMissingIndices.php b/core/Command/Db/AddMissingIndices.php
new file mode 100644
index 00000000000..314bed8ccb1
--- /dev/null
+++ b/core/Command/Db/AddMissingIndices.php
@@ -0,0 +1,91 @@
+<?php
+/**
+ * @copyright Copyright (c) 2017 Bjoern Schiessle <bjoern@schiessle.org>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * 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
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+
+namespace OC\Core\Command\Db;
+
+use OC\DB\SchemaWrapper;
+use OCP\IDBConnection;
+use Symfony\Component\Console\Command\Command;
+use Symfony\Component\Console\Input\InputInterface;
+use Symfony\Component\Console\Output\OutputInterface;
+
+/**
+ * Class AddMissingIndices
+ *
+ * if you added any new indices to the database, this is the right place to add
+ * it your update routine for existing instances
+ *
+ * @package OC\Core\Command\Db
+ */
+class AddMissingIndices extends Command {
+
+ /** @var IDBConnection */
+ private $connection;
+
+ /**
+ * @param IDBConnection $connection
+ */
+ public function __construct(IDBConnection $connection) {
+ $this->connection = $connection;
+ parent::__construct();
+ }
+
+ protected function configure() {
+ $this
+ ->setName('db:add-missing-indices')
+ ->setDescription('Add missing indices to the database tables');
+ }
+
+ protected function execute(InputInterface $input, OutputInterface $output) {
+ $this->addShareTableIndicies($output);
+
+ }
+
+ /**
+ * add missing indices to the share table
+ *
+ * @param OutputInterface $output
+ * @throws \Doctrine\DBAL\Schema\SchemaException
+ */
+ private function addShareTableIndicies(OutputInterface $output) {
+
+ $output->writeln('<info>Check indices of the share table.</info>');
+
+ $schema = new SchemaWrapper($this->connection);
+ $updated = false;
+
+ if ($schema->hasTable("share")) {
+ $table = $schema->getTable("share");
+ if (!$table->hasIndex('share_with_index')) {
+ $output->writeln('<info>Adding additional index to the share table, this can take some time...</info>');
+ $table->addIndex(['share_with'], 'share_with_index');
+ $this->connection->migrateToSchema($schema->getWrappedSchema());
+ $updated = true;
+ $output->writeln('<info>Share table updated successfully.</info>');
+ }
+ }
+
+ if (!$updated) {
+ $output->writeln('<info>Done.</info>');
+ }
+ }
+}
diff --git a/core/Command/Maintenance/Repair.php b/core/Command/Maintenance/Repair.php
index 9401dafd26b..71d13cd29f3 100644
--- a/core/Command/Maintenance/Repair.php
+++ b/core/Command/Maintenance/Repair.php
@@ -86,7 +86,7 @@ class Repair extends Command {
$apps = $this->appManager->getInstalledApps();
foreach ($apps as $app) {
- if (!$appManager->isEnabledForUser($app)) {
+ if (!$this->appManager->isEnabledForUser($app)) {
continue;
}
$info = \OC_App::getAppInfo($app);
diff --git a/core/Command/Maintenance/UpdateTheme.php b/core/Command/Maintenance/UpdateTheme.php
index cf015b82635..2ab66a4ce75 100644
--- a/core/Command/Maintenance/UpdateTheme.php
+++ b/core/Command/Maintenance/UpdateTheme.php
@@ -57,7 +57,7 @@ class UpdateTheme extends UpdateJS {
parent::execute($input, $output);
// cleanup image cache
- $c = $this->cacheFactory->create('imagePath');
+ $c = $this->cacheFactory->createDistributed('imagePath');
$c->clear('');
$output->writeln('<info>Image cache cleared');
}
diff --git a/core/Migrations/Version13000Date20170718121200.php b/core/Migrations/Version13000Date20170718121200.php
index 0ab777f6de2..e71debfcb4b 100644
--- a/core/Migrations/Version13000Date20170718121200.php
+++ b/core/Migrations/Version13000Date20170718121200.php
@@ -400,6 +400,7 @@ class Version13000Date20170718121200 extends SimpleMigrationStep {
$table->addIndex(['item_type', 'share_type'], 'item_share_type_index');
$table->addIndex(['file_source'], 'file_source_index');
$table->addIndex(['token'], 'token_index');
+ $table->addIndex(['share_with'], 'share_with_index');
}
if (!$schema->hasTable('jobs')) {
diff --git a/core/register_command.php b/core/register_command.php
index 60e151a5f2c..372d775dc14 100644
--- a/core/register_command.php
+++ b/core/register_command.php
@@ -90,6 +90,7 @@ if (\OC::$server->getConfig()->getSystemValue('installed', false)) {
$application->add(new OC\Core\Command\Db\ConvertType(\OC::$server->getConfig(), new \OC\DB\ConnectionFactory(\OC::$server->getSystemConfig())));
$application->add(new OC\Core\Command\Db\ConvertMysqlToMB4(\OC::$server->getConfig(), \OC::$server->getDatabaseConnection(), \OC::$server->getURLGenerator(), \OC::$server->getLogger()));
$application->add(new OC\Core\Command\Db\ConvertFilecacheBigInt(\OC::$server->getDatabaseConnection()));
+ $application->add(new OC\Core\Command\Db\AddMissingIndices(\OC::$server->getDatabaseConnection()));
$application->add(new OC\Core\Command\Db\Migrations\StatusCommand(\OC::$server->getDatabaseConnection()));
$application->add(new OC\Core\Command\Db\Migrations\MigrateCommand(\OC::$server->getDatabaseConnection()));
$application->add(new OC\Core\Command\Db\Migrations\GenerateCommand(\OC::$server->getDatabaseConnection()));
diff --git a/lib/composer/composer/autoload_classmap.php b/lib/composer/composer/autoload_classmap.php
index a3b85349274..738054cd377 100644
--- a/lib/composer/composer/autoload_classmap.php
+++ b/lib/composer/composer/autoload_classmap.php
@@ -459,6 +459,7 @@ return array(
'OC\\Core\\Command\\Config\\System\\DeleteConfig' => $baseDir . '/core/Command/Config/System/DeleteConfig.php',
'OC\\Core\\Command\\Config\\System\\GetConfig' => $baseDir . '/core/Command/Config/System/GetConfig.php',
'OC\\Core\\Command\\Config\\System\\SetConfig' => $baseDir . '/core/Command/Config/System/SetConfig.php',
+ 'OC\\Core\\Command\\Db\\AddMissingIndices' => $baseDir . '/core/Command/Db/AddMissingIndices.php',
'OC\\Core\\Command\\Db\\ConvertFilecacheBigInt' => $baseDir . '/core/Command/Db/ConvertFilecacheBigInt.php',
'OC\\Core\\Command\\Db\\ConvertMysqlToMB4' => $baseDir . '/core/Command/Db/ConvertMysqlToMB4.php',
'OC\\Core\\Command\\Db\\ConvertType' => $baseDir . '/core/Command/Db/ConvertType.php',
diff --git a/lib/composer/composer/autoload_static.php b/lib/composer/composer/autoload_static.php
index 408a30e2540..7ffbd4c7882 100644
--- a/lib/composer/composer/autoload_static.php
+++ b/lib/composer/composer/autoload_static.php
@@ -489,6 +489,7 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c
'OC\\Core\\Command\\Config\\System\\DeleteConfig' => __DIR__ . '/../../..' . '/core/Command/Config/System/DeleteConfig.php',
'OC\\Core\\Command\\Config\\System\\GetConfig' => __DIR__ . '/../../..' . '/core/Command/Config/System/GetConfig.php',
'OC\\Core\\Command\\Config\\System\\SetConfig' => __DIR__ . '/../../..' . '/core/Command/Config/System/SetConfig.php',
+ 'OC\\Core\\Command\\Db\\AddMissingIndices' => __DIR__ . '/../../..' . '/core/Command/Db/AddMissingIndices.php',
'OC\\Core\\Command\\Db\\ConvertFilecacheBigInt' => __DIR__ . '/../../..' . '/core/Command/Db/ConvertFilecacheBigInt.php',
'OC\\Core\\Command\\Db\\ConvertMysqlToMB4' => __DIR__ . '/../../..' . '/core/Command/Db/ConvertMysqlToMB4.php',
'OC\\Core\\Command\\Db\\ConvertType' => __DIR__ . '/../../..' . '/core/Command/Db/ConvertType.php',
diff --git a/lib/private/App/AppManager.php b/lib/private/App/AppManager.php
index 6be892b7f49..e7d4668931c 100644
--- a/lib/private/App/AppManager.php
+++ b/lib/private/App/AppManager.php
@@ -306,7 +306,7 @@ class AppManager implements IAppManager {
* Clear the cached list of apps when enabling/disabling an app
*/
public function clearAppsCache() {
- $settingsMemCache = $this->memCacheFactory->create('settings');
+ $settingsMemCache = $this->memCacheFactory->createDistributed('settings');
$settingsMemCache->clear('listApps');
}
diff --git a/lib/private/Collaboration/Collaborators/MailPlugin.php b/lib/private/Collaboration/Collaborators/MailPlugin.php
index d28bd3692a4..2e946c4a872 100644
--- a/lib/private/Collaboration/Collaborators/MailPlugin.php
+++ b/lib/private/Collaboration/Collaborators/MailPlugin.php
@@ -30,10 +30,13 @@ use OCP\Collaboration\Collaborators\SearchResultType;
use OCP\Contacts\IManager;
use OCP\Federation\ICloudIdManager;
use OCP\IConfig;
+use OCP\IGroupManager;
+use OCP\IUserSession;
use OCP\Share;
class MailPlugin implements ISearchPlugin {
protected $shareeEnumeration;
+ protected $shareWithGroupOnly;
/** @var IManager */
private $contactsManager;
@@ -42,12 +45,21 @@ class MailPlugin implements ISearchPlugin {
/** @var IConfig */
private $config;
- public function __construct(IManager $contactsManager, ICloudIdManager $cloudIdManager, IConfig $config) {
+ /** @var IGroupManager */
+ private $groupManager;
+
+ /** @var IUserSession */
+ private $userSession;
+
+ public function __construct(IManager $contactsManager, ICloudIdManager $cloudIdManager, IConfig $config, IGroupManager $groupManager, IUserSession $userSession) {
$this->contactsManager = $contactsManager;
$this->cloudIdManager = $cloudIdManager;
$this->config = $config;
+ $this->groupManager = $groupManager;
+ $this->userSession = $userSession;
$this->shareeEnumeration = $this->config->getAppValue('core', 'shareapi_allow_share_dialog_user_enumeration', 'yes') === 'yes';
+ $this->shareWithGroupOnly = $this->config->getAppValue('core', 'shareapi_only_share_with_group_members', 'no') === 'yes';
}
/**
@@ -77,6 +89,22 @@ class MailPlugin implements ISearchPlugin {
$exactEmailMatch = strtolower($emailAddress) === $lowerSearch;
if (isset($contact['isLocalSystemBook'])) {
+ if ($this->shareWithGroupOnly) {
+ /*
+ * Check if the user may share with the user associated with the e-mail of the just found contact
+ */
+ $userGroups = $this->groupManager->getUserGroupIds($this->userSession->getUser());
+ $found = false;
+ foreach ($userGroups as $userGroup) {
+ if ($this->groupManager->isInGroup($contact['UID'], $userGroup)) {
+ $found = true;
+ break;
+ }
+ }
+ if (!$found) {
+ continue;
+ }
+ }
if ($exactEmailMatch) {
try {
$cloud = $this->cloudIdManager->resolveCloudId($contact['CLOUD'][0]);
diff --git a/lib/private/Files/ObjectStore/Swift.php b/lib/private/Files/ObjectStore/Swift.php
index ecfbe136e4c..629fb3ba7ff 100644
--- a/lib/private/Files/ObjectStore/Swift.php
+++ b/lib/private/Files/ObjectStore/Swift.php
@@ -82,7 +82,7 @@ class Swift implements IObjectStore {
}
$cacheFactory = \OC::$server->getMemCacheFactory();
- $this->memcache = $cacheFactory->create('swift::' . $cacheKey);
+ $this->memcache = $cacheFactory->createDistributed('swift::' . $cacheKey);
$this->params = $params;
}
diff --git a/lib/private/Files/Storage/Common.php b/lib/private/Files/Storage/Common.php
index 715b7b18499..56d683ffa25 100644
--- a/lib/private/Files/Storage/Common.php
+++ b/lib/private/Files/Storage/Common.php
@@ -229,6 +229,9 @@ abstract class Common implements Storage, ILockingStorage {
$source = $this->fopen($path1, 'r');
$target = $this->fopen($path2, 'w');
list(, $result) = \OC_Helper::streamCopy($source, $target);
+ if (!$result) {
+ \OC::$server->getLogger()->warning("Failed to write data while copying $path1 to $path2");
+ }
$this->removeCachedFile($path2);
return $result;
}
diff --git a/lib/private/IntegrityCheck/Checker.php b/lib/private/IntegrityCheck/Checker.php
index ee7e35550a6..771ac891ab4 100644
--- a/lib/private/IntegrityCheck/Checker.php
+++ b/lib/private/IntegrityCheck/Checker.php
@@ -87,7 +87,7 @@ class Checker {
$this->fileAccessHelper = $fileAccessHelper;
$this->appLocator = $appLocator;
$this->config = $config;
- $this->cache = $cacheFactory->create(self::CACHE_KEY);
+ $this->cache = $cacheFactory->createDistributed(self::CACHE_KEY);
$this->appManager = $appManager;
$this->tempManager = $tempManager;
}
diff --git a/lib/private/OCS/DiscoveryService.php b/lib/private/OCS/DiscoveryService.php
index e547747da25..4425947c55d 100644
--- a/lib/private/OCS/DiscoveryService.php
+++ b/lib/private/OCS/DiscoveryService.php
@@ -46,7 +46,7 @@ class DiscoveryService implements IDiscoveryService {
public function __construct(ICacheFactory $cacheFactory,
IClientService $clientService
) {
- $this->cache = $cacheFactory->create('ocs-discovery');
+ $this->cache = $cacheFactory->createDistributed('ocs-discovery');
$this->client = $clientService->newClient();
}
diff --git a/lib/private/Security/RateLimiting/Backend/MemoryCache.php b/lib/private/Security/RateLimiting/Backend/MemoryCache.php
index 212df664c17..700fa624ed4 100644
--- a/lib/private/Security/RateLimiting/Backend/MemoryCache.php
+++ b/lib/private/Security/RateLimiting/Backend/MemoryCache.php
@@ -45,7 +45,7 @@ class MemoryCache implements IBackend {
*/
public function __construct(ICacheFactory $cacheFactory,
ITimeFactory $timeFactory) {
- $this->cache = $cacheFactory->create(__CLASS__);
+ $this->cache = $cacheFactory->createDistributed(__CLASS__);
$this->timeFactory = $timeFactory;
}
diff --git a/lib/private/Server.php b/lib/private/Server.php
index 6898e93e3bb..44f5ea80cb7 100644
--- a/lib/private/Server.php
+++ b/lib/private/Server.php
@@ -952,7 +952,7 @@ class Server extends ServerContainer implements IServerContainer {
$c->getConfig(),
$c->getThemingDefaults(),
\OC::$SERVERROOT,
- $cacheFactory->create('SCSS')
+ $cacheFactory->createDistributed('SCSS')
);
});
$this->registerService(EventDispatcher::class, function () {
@@ -1093,16 +1093,6 @@ class Server extends ServerContainer implements IServerContainer {
return new CloudIdManager();
});
- /* To trick DI since we don't extend the DIContainer here */
- $this->registerService(CleanPreviewsBackgroundJob::class, function (Server $c) {
- return new CleanPreviewsBackgroundJob(
- $c->getRootFolder(),
- $c->getLogger(),
- $c->getJobList(),
- new TimeFactory()
- );
- });
-
$this->registerAlias(\OCP\AppFramework\Utility\IControllerMethodReflector::class, \OC\AppFramework\Utility\ControllerMethodReflector::class);
$this->registerAlias('ControllerMethodReflector', \OCP\AppFramework\Utility\IControllerMethodReflector::class);
diff --git a/lib/private/TemplateLayout.php b/lib/private/TemplateLayout.php
index 997980aa5d7..264c10f5f1b 100644
--- a/lib/private/TemplateLayout.php
+++ b/lib/private/TemplateLayout.php
@@ -291,7 +291,7 @@ class TemplateLayout extends \OC_Template {
new JSCombiner(
\OC::$server->getAppDataDir('js'),
\OC::$server->getURLGenerator(),
- \OC::$server->getMemCacheFactory()->create('JS'),
+ \OC::$server->getMemCacheFactory()->createDistributed('JS'),
\OC::$server->getSystemConfig(),
\OC::$server->getLogger()
)
diff --git a/lib/private/URLGenerator.php b/lib/private/URLGenerator.php
index 6fd22b99a6b..f7d80d41b4f 100644
--- a/lib/private/URLGenerator.php
+++ b/lib/private/URLGenerator.php
@@ -151,7 +151,7 @@ class URLGenerator implements IURLGenerator {
* Returns the path to the image.
*/
public function imagePath($app, $image) {
- $cache = $this->cacheFactory->create('imagePath-'.md5($this->getBaseUrl()).'-');
+ $cache = $this->cacheFactory->createDistributed('imagePath-'.md5($this->getBaseUrl()).'-');
$cacheKey = $app.'-'.$image;
if($key = $cache->get($cacheKey)) {
return $key;
diff --git a/lib/private/legacy/db.php b/lib/private/legacy/db.php
index da21729f123..6e487e25ad5 100644
--- a/lib/private/legacy/db.php
+++ b/lib/private/legacy/db.php
@@ -105,11 +105,11 @@ class OC_DB {
* @param mixed $stmt OC_DB_StatementWrapper,
* an array with 'sql' and optionally 'limit' and 'offset' keys
* .. or a simple sql query string
- * @param array|null $parameters
+ * @param array $parameters
* @return OC_DB_StatementWrapper
* @throws \OC\DatabaseException
*/
- static public function executeAudited( $stmt, array $parameters = null) {
+ static public function executeAudited( $stmt, array $parameters = []) {
if (is_string($stmt)) {
// convert to an array with 'sql'
if (stripos($stmt, 'LIMIT') !== false) { //OFFSET requires LIMIT, so we only need to check for LIMIT
diff --git a/lib/private/legacy/helper.php b/lib/private/legacy/helper.php
index e611b4d0732..8bbfb235ee2 100644
--- a/lib/private/legacy/helper.php
+++ b/lib/private/legacy/helper.php
@@ -497,7 +497,7 @@ class OC_Helper {
* @return null|string
*/
public static function findBinaryPath($program) {
- $memcache = \OC::$server->getMemCacheFactory()->create('findBinaryPath');
+ $memcache = \OC::$server->getMemCacheFactory()->createDistributed('findBinaryPath');
if ($memcache->hasKey($program)) {
return $memcache->get($program);
}
diff --git a/settings/ajax/uninstallapp.php b/settings/ajax/uninstallapp.php
index b4a2468bd2a..a932e2d79e9 100644
--- a/settings/ajax/uninstallapp.php
+++ b/settings/ajax/uninstallapp.php
@@ -43,8 +43,8 @@ $appId = OC_App::cleanAppId($appId);
$result = OC_App::removeApp($appId);
if($result !== false) {
// FIXME: Clear the cache - move that into some sane helper method
- \OC::$server->getMemCacheFactory()->create('settings')->remove('listApps-0');
- \OC::$server->getMemCacheFactory()->create('settings')->remove('listApps-1');
+ \OC::$server->getMemCacheFactory()->createDistributed('settings')->remove('listApps-0');
+ \OC::$server->getMemCacheFactory()->createDistributed('settings')->remove('listApps-1');
OC_JSON::success(array('data' => array('appid' => $appId)));
} else {
$l = \OC::$server->getL10N('settings');
diff --git a/tests/Core/Command/Maintenance/UpdateTheme.php b/tests/Core/Command/Maintenance/UpdateTheme.php
index fbdea0b72b4..cbc417dbdba 100644
--- a/tests/Core/Command/Maintenance/UpdateTheme.php
+++ b/tests/Core/Command/Maintenance/UpdateTheme.php
@@ -74,7 +74,7 @@ class UpdateThemeTest extends TestCase {
->method('clear')
->with('');
$this->cacheFactory->expects($this->once())
- ->method('create')
+ ->method('createDistributed')
->with('imagePath')
->willReturn($cache);
self::invokePrivate($this->command, 'execute', [$this->consoleInput, $this->consoleOutput]);
diff --git a/tests/lib/App/AppManagerTest.php b/tests/lib/App/AppManagerTest.php
index c2c0ea55072..c361db7b76b 100644
--- a/tests/lib/App/AppManagerTest.php
+++ b/tests/lib/App/AppManagerTest.php
@@ -100,7 +100,7 @@ class AppManagerTest extends TestCase {
$this->cache = $this->createMock(ICache::class);
$this->eventDispatcher = $this->createMock(EventDispatcherInterface::class);
$this->cacheFactory->expects($this->any())
- ->method('create')
+ ->method('createDistributed')
->with('settings')
->willReturn($this->cache);
$this->manager = new AppManager($this->userSession, $this->appConfig, $this->groupManager, $this->cacheFactory, $this->eventDispatcher);
diff --git a/tests/lib/Collaboration/Collaborators/MailPluginTest.php b/tests/lib/Collaboration/Collaborators/MailPluginTest.php
index 9c9d9cff909..b728ae521e2 100644
--- a/tests/lib/Collaboration/Collaborators/MailPluginTest.php
+++ b/tests/lib/Collaboration/Collaborators/MailPluginTest.php
@@ -31,6 +31,8 @@ use OCP\Collaboration\Collaborators\SearchResultType;
use OCP\Contacts\IManager;
use OCP\Federation\ICloudIdManager;
use OCP\IConfig;
+use OCP\IGroupManager;
+use OCP\IUserSession;
use OCP\Share;
use Test\TestCase;
@@ -50,17 +52,25 @@ class MailPluginTest extends TestCase {
/** @var SearchResult */
protected $searchResult;
+ /** @var IGroupManager|\PHPUnit_Framework_MockObject_MockObject */
+ protected $groupManager;
+
+ /** @var IUserSession|\PHPUnit_Framework_MockObject_MockObject */
+ protected $userSession;
+
public function setUp() {
parent::setUp();
$this->config = $this->createMock(IConfig::class);
$this->contactsManager = $this->createMock(IManager::class);
+ $this->groupManager = $this->createMock(IGroupManager::class);
+ $this->userSession = $this->createMock(IUserSession::class);
$this->cloudIdManager = new CloudIdManager();
$this->searchResult = new SearchResult();
}
public function instantiatePlugin() {
- $this->plugin = new MailPlugin($this->contactsManager, $this->cloudIdManager, $this->config);
+ $this->plugin = new MailPlugin($this->contactsManager, $this->cloudIdManager, $this->config, $this->groupManager, $this->userSession);
}
/**
@@ -333,4 +343,131 @@ class MailPluginTest extends TestCase {
]
];
}
+
+ /**
+ * @dataProvider dataGetEmailGroupsOnly
+ *
+ * @param string $searchTerm
+ * @param array $contacts
+ * @param array $expected
+ * @param bool $exactIdMatch
+ * @param bool $reachedEnd
+ * @param array groups
+ */
+ public function testSearchGroupsOnly($searchTerm, $contacts, $expected, $exactIdMatch, $reachedEnd, $userToGroupMapping) {
+ $this->config->expects($this->any())
+ ->method('getAppValue')
+ ->willReturnCallback(
+ function($appName, $key, $default) {
+ if ($appName === 'core' && $key === 'shareapi_allow_share_dialog_user_enumeration') {
+ return 'yes';
+ } else if ($appName === 'core' && $key === 'shareapi_only_share_with_group_members') {
+ return 'yes';
+ }
+ return $default;
+ }
+ );
+
+ $this->instantiatePlugin();
+
+ /** @var \OCP\IUser | \PHPUnit_Framework_MockObject_MockObject */
+ $currentUser = $this->createMock('\OCP\IUser');
+
+ $currentUser->expects($this->any())
+ ->method('getUID')
+ ->willReturn('currentUser');
+
+ $this->contactsManager->expects($this->any())
+ ->method('search')
+ ->with($searchTerm, ['EMAIL', 'FN'])
+ ->willReturn($contacts);
+
+ $this->userSession->expects($this->any())
+ ->method('getUser')
+ ->willReturn($currentUser);
+
+ $this->groupManager->expects($this->any())
+ ->method('getUserGroupIds')
+ ->willReturnCallback(function(\OCP\IUser $user) use ($userToGroupMapping) {
+ return $userToGroupMapping[$user->getUID()];
+ });
+
+ $this->groupManager->expects($this->any())
+ ->method('isInGroup')
+ ->willReturnCallback(function($userId, $group) use ($userToGroupMapping) {
+ return in_array($group, $userToGroupMapping[$userId]);
+ });
+
+ $moreResults = $this->plugin->search($searchTerm, 0, 0, $this->searchResult);
+ $result = $this->searchResult->asArray();
+
+ $this->assertSame($exactIdMatch, $this->searchResult->hasExactIdMatch(new SearchResultType('emails')));
+ $this->assertEquals($expected, $result);
+ $this->assertSame($reachedEnd, $moreResults);
+ }
+
+ public function dataGetEmailGroupsOnly() {
+ return [
+ // The user `User` can share with the current user
+ [
+ 'test',
+ [
+ [
+ 'FN' => 'User',
+ 'EMAIL' => ['test@example.com'],
+ 'CLOUD' => ['test@localhost'],
+ 'isLocalSystemBook' => true,
+ 'UID' => 'User'
+ ]
+ ],
+ ['users' => [['label' => 'User (test@example.com)','value' => ['shareType' => 0, 'shareWith' => 'test'],]], 'emails' => [], 'exact' => ['emails' => [], 'users' => []]],
+ false,
+ true,
+ [
+ "currentUser" => ["group1"],
+ "User" => ["group1"]
+ ]
+ ],
+ // The user `User` cannot share with the current user
+ [
+ 'test',
+ [
+ [
+ 'FN' => 'User',
+ 'EMAIL' => ['test@example.com'],
+ 'CLOUD' => ['test@localhost'],
+ 'isLocalSystemBook' => true,
+ 'UID' => 'User'
+ ]
+ ],
+ ['emails'=> [], 'exact' => ['emails' => []]],
+ false,
+ true,
+ [
+ "currentUser" => ["group1"],
+ "User" => ["group2"]
+ ]
+ ],
+ // The user `User` cannot share with the current user, but there is an exact match on the e-mail address -> share by e-mail
+ [
+ 'test@example.com',
+ [
+ [
+ 'FN' => 'User',
+ 'EMAIL' => ['test@example.com'],
+ 'CLOUD' => ['test@localhost'],
+ 'isLocalSystemBook' => true,
+ 'UID' => 'User'
+ ]
+ ],
+ ['emails' => [], 'exact' => ['emails' => [['label' => 'test@example.com', 'value' => ['shareType' => 4,'shareWith' => 'test@example.com']]]]],
+ false,
+ true,
+ [
+ "currentUser" => ["group1"],
+ "User" => ["group2"]
+ ]
+ ]
+ ];
+ }
}
diff --git a/tests/lib/IntegrityCheck/CheckerTest.php b/tests/lib/IntegrityCheck/CheckerTest.php
index 049017cb5e8..09e6990a0f3 100644
--- a/tests/lib/IntegrityCheck/CheckerTest.php
+++ b/tests/lib/IntegrityCheck/CheckerTest.php
@@ -60,7 +60,7 @@ class CheckerTest extends TestCase {
$this->cacheFactory
->expects($this->any())
- ->method('create')
+ ->method('createDistributed')
->with('oc.integritycheck.checker')
->will($this->returnValue(new NullCache()));
diff --git a/tests/lib/Security/RateLimiting/Backend/MemoryCacheTest.php b/tests/lib/Security/RateLimiting/Backend/MemoryCacheTest.php
index 34c326e72e1..bacd2b7bf6f 100644
--- a/tests/lib/Security/RateLimiting/Backend/MemoryCacheTest.php
+++ b/tests/lib/Security/RateLimiting/Backend/MemoryCacheTest.php
@@ -46,7 +46,7 @@ class MemoryCacheTest extends TestCase {
$this->cacheFactory
->expects($this->once())
- ->method('create')
+ ->method('createDistributed')
->with('OC\Security\RateLimiting\Backend\MemoryCache')
->willReturn($this->cache);