Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/files_sharing/lib/propagation/recipientpropagator.php37
-rw-r--r--lib/private/appconfig.php12
2 files changed, 47 insertions, 2 deletions
diff --git a/apps/files_sharing/lib/propagation/recipientpropagator.php b/apps/files_sharing/lib/propagation/recipientpropagator.php
index e71208fd6cd..407664f31b7 100644
--- a/apps/files_sharing/lib/propagation/recipientpropagator.php
+++ b/apps/files_sharing/lib/propagation/recipientpropagator.php
@@ -22,6 +22,7 @@
namespace OCA\Files_Sharing\Propagation;
+use Doctrine\DBAL\Connection;
use OC\Files\Cache\ChangePropagator;
use OC\Files\View;
use OC\Share\Share;
@@ -109,9 +110,15 @@ class RecipientPropagator {
protected function getDirtyShares($shares) {
$dirty = [];
$userTime = $this->config->getUserValue($this->userId, 'files_sharing', 'last_propagate', 0);
+ $sharePropagations = [];
foreach ($shares as $share) {
- $updateTime = $this->config->getAppValue('files_sharing', $share['id'], 0);
- if ($updateTime >= $userTime) {
+ $sharePropagations[(int) $share['id']] = 0;
+ }
+
+ $sharePropagations = $this->getPropagationTimestampForShares($sharePropagations);
+
+ foreach ($shares as $share) {
+ if ($sharePropagations[$share['id']] >= $userTime) {
$dirty[] = $share;
}
}
@@ -119,6 +126,32 @@ class RecipientPropagator {
}
/**
+ * Load the last dirty timestamp from the appconfig table
+ *
+ * @param int[] $sharePropagations
+ * @return int[]
+ */
+ protected function getPropagationTimestampForShares(array $sharePropagations) {
+ $sql = \OC::$server->getDatabaseConnection()->getQueryBuilder();
+ $shareIds = array_keys($sharePropagations);
+
+ $sql->select(['configkey', 'configvalue'])
+ ->from('appconfig')
+ ->where($sql->expr()->eq('appid', $sql->createParameter('appid')))
+ ->andWhere($sql->expr()->in('configkey', $sql->createParameter('shareids')))
+ ->setParameter('appid', 'files_sharing', \PDO::PARAM_STR)
+ ->setParameter('shareids', $shareIds, Connection::PARAM_INT_ARRAY);
+ $result = $sql->execute();
+
+ while ($row = $result->fetch()) {
+ $sharePropagations[(int) $row['configkey']] = $row['configvalue'];
+ }
+ $result->closeCursor();
+
+ return $sharePropagations;
+ }
+
+ /**
* @param array $share
* @param float $time
*/
diff --git a/lib/private/appconfig.php b/lib/private/appconfig.php
index d1c1e4bfc45..bfb4758dce9 100644
--- a/lib/private/appconfig.php
+++ b/lib/private/appconfig.php
@@ -29,6 +29,7 @@
namespace OC;
+use Doctrine\DBAL\Connection;
use OCP\IAppConfig;
use OCP\IDBConnection;
@@ -273,6 +274,17 @@ class AppConfig implements IAppConfig {
$sql = $this->conn->getQueryBuilder();
$sql->select('*')
->from('appconfig');
+ // Note: due to performance issues when there are a lot of shares,
+ // we are not loading the propagation timestamps by default anymore.
+ // The code relying on those values has been adjusted to grab the values
+ // manually. In 9.0 the propagation was changed to not be stored in this
+ // table anymore.
+ $sql->where($sql->expr()->orX(
+ $sql->expr()->neq('appid', $sql->createParameter('appid')),
+ $sql->expr()->in('configkey', $sql->createParameter('legit_configs'))
+ ))
+ ->setParameter('appid', 'files_sharing', \PDO::PARAM_STR)
+ ->setParameter('legit_configs', ['enabled', 'installed_version', 'types'], Connection::PARAM_STR_ARRAY);
$result = $sql->execute();
while ($row = $result->fetch()) {