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

github.com/CarnetApp/CarnetNextcloud.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorPhie <phie@phie.ovh>2019-04-30 15:35:16 +0300
committerPhie <phie@phie.ovh>2019-04-30 15:35:16 +0300
commitfce3221fa82595d71da45340be8ef22db3ee7bca (patch)
treec1c76efeb0876f2d1ab833774259d743fcb0ac1f /lib
parenta5286ba8d1b694d177a71f7fa5dd56a678af2d6c (diff)
don't crash when too many notes to request from cache
Diffstat (limited to 'lib')
-rw-r--r--lib/Misc/CacheManager.php48
1 files changed, 26 insertions, 22 deletions
diff --git a/lib/Misc/CacheManager.php b/lib/Misc/CacheManager.php
index d18caa9..c070fcc 100644
--- a/lib/Misc/CacheManager.php
+++ b/lib/Misc/CacheManager.php
@@ -99,30 +99,34 @@ class CacheManager{
}
public function getFromCache($arrayRelativePath){
- $arrayFullPath = array();
- $sql = 'SELECT * FROM `*PREFIX*carnet_metadata` ' .
- 'WHERE ';
- for($i = 0; $i < sizeof($arrayRelativePath); $i++){
- $sql .= "`path` = ? ";
- if($i < sizeof($arrayRelativePath)-1)
- $sql .= "OR ";
- array_push($arrayFullPath, $this->carnetFolder->getFullPath($arrayRelativePath[$i]));
- }
-
- $stmt = $this->db->prepare($sql);
- /* foreach($arrayRelativePath as $relativePath){
- $stmt->bindParam($i+1, $relativePath, \PDO::PARAM_STR);
- $i++;
- }*/
-
- $stmt->execute($arrayFullPath);
+ $total = 0;
$array = array();
- $fetched = $stmt->fetchAll();
- foreach ($fetched as $row){
- $array[substr($row['path'], strlen($this->carnetFolder->getPath())+1)] = json_decode($row['metadata']);
- }
- $stmt->closeCursor();
+ while($total < sizeof($arrayRelativePath)){
+ $arrayFullPath = array();
+ $sql = 'SELECT * FROM `*PREFIX*carnet_metadata` ' .
+ 'WHERE ';
+ for($i = $total; $i < sizeof($arrayRelativePath); $i++){
+ $sql .= "`path` = ? ";
+
+ array_push($arrayFullPath, $this->carnetFolder->getFullPath($arrayRelativePath[$i]));
+ if($i < sizeof($arrayRelativePath)-1 && $i - $total < 100)
+ $sql .= "OR ";
+ if($i - $total == 100)
+ break;
+ }
+ $total = $total + 100;
+
+ $stmt = $this->db->prepare($sql);
+
+ $stmt->execute($arrayFullPath);
+ $fetched = $stmt->fetchAll();
+ foreach ($fetched as $row){
+ $array[substr($row['path'], strlen($this->carnetFolder->getPath())+1)] = json_decode($row['metadata']);
+ }
+
+ $stmt->closeCursor();
+ }
return $array;
}