summaryrefslogtreecommitdiff
path: root/app/Models
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2019-11-11 19:48:23 +0100
committerGravatar GitHub <noreply@github.com> 2019-11-11 19:48:23 +0100
commit6fb60d470aaa3c1e62dc1a61f786abdd6e428106 (patch)
tree94fcfc624d980c6a59538130fed7a0e71339cdf1 /app/Models
parent6a643d180ec7e05deb4d86a4a8d128dda0360345 (diff)
Fix DB optimize for MySQL (#2647)
`pdo->exec()` is not appropriate for MySQL `OPTIMIZE` because `OPTIMIZE` returns some data and not only a code and then fails.
Diffstat (limited to 'app/Models')
-rw-r--r--app/Models/DatabaseDAO.php7
-rw-r--r--app/Models/DatabaseDAOPGSQL.php6
-rw-r--r--app/Models/DatabaseDAOSQLite.php7
3 files changed, 17 insertions, 3 deletions
diff --git a/app/Models/DatabaseDAO.php b/app/Models/DatabaseDAO.php
index 13330db23..cfb150ab1 100644
--- a/app/Models/DatabaseDAO.php
+++ b/app/Models/DatabaseDAO.php
@@ -156,7 +156,12 @@ class FreshRSS_DatabaseDAO extends Minz_ModelPdo {
foreach ($tables as $table) {
$sql = 'OPTIMIZE TABLE `_' . $table . '`'; //MySQL
- $ok &= ($this->pdo->exec($sql) !== false);
+ $stm = $this->pdo->query($sql);
+ if ($stm == false || $stm->fetchAll(PDO::FETCH_ASSOC) === false) {
+ $ok = false;
+ $info = $stm == null ? $this->pdo->errorInfo() : $stm->errorInfo();
+ Minz_Log::warning(__METHOD__ . ' error: ' . $sql . ' : ' . json_encode($info));
+ }
}
return $ok;
}
diff --git a/app/Models/DatabaseDAOPGSQL.php b/app/Models/DatabaseDAOPGSQL.php
index 7ca7799ae..75ff8be7b 100644
--- a/app/Models/DatabaseDAOPGSQL.php
+++ b/app/Models/DatabaseDAOPGSQL.php
@@ -79,7 +79,11 @@ class FreshRSS_DatabaseDAOPGSQL extends FreshRSS_DatabaseDAOSQLite {
foreach ($tables as $table) {
$sql = 'VACUUM `_' . $table . '`';
- $ok &= ($this->pdo->exec($sql) !== false);
+ if ($this->pdo->exec($sql) === false) {
+ $ok = false;
+ $info = $this->pdo->errorInfo();
+ Minz_Log::warning(__METHOD__ . ' error: ' . $sql . ' : ' . json_encode($info));
+ }
}
return $ok;
}
diff --git a/app/Models/DatabaseDAOSQLite.php b/app/Models/DatabaseDAOSQLite.php
index 413e7ee09..eaa2d37a7 100644
--- a/app/Models/DatabaseDAOSQLite.php
+++ b/app/Models/DatabaseDAOSQLite.php
@@ -66,6 +66,11 @@ class FreshRSS_DatabaseDAOSQLite extends FreshRSS_DatabaseDAO {
}
public function optimize() {
- return $this->pdo->exec('VACUUM') !== false;
+ $ok = $this->pdo->exec('VACUUM') !== false;
+ if (!$ok) {
+ $info = $this->pdo->errorInfo();
+ Minz_Log::warning(__METHOD__ . ' error: ' . $sql . ' : ' . json_encode($info));
+ }
+ return $ok;
}
}