From a9518580003361a9bcefd0ef47c9babbe299db50 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 23 Mar 2016 10:50:16 +0100 Subject: Grab the values for share propagation manually from the DB --- .../lib/propagation/recipientpropagator.php | 37 ++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) (limited to 'apps') 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,15 +110,47 @@ 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; } } return $dirty; } + /** + * 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 -- cgit v1.2.3