mirror of
https://github.com/FreshRSS/FreshRSS.git
synced 2026-10-27 05:28:38 -04:00
SQL allow recreating existing user (#2555)
* SQL allow recreating existing user Taking advantage of https://github.com/FreshRSS/FreshRSS/pull/2554 In a case when FreshRSS data is lost, but database data still intact (in particular MySQL or PostgreSQL), this patch allows recreating previous users without error * Better error retrieval Especially when error occur during the prepare statement
This commit is contained in:
1 parent
1b15e22897
commit
be4c942cb3
9 files changed
+67
-62
No files matched your search
+12
-12
@@ -74,7 +74,7 @@ class FreshRSS_FeedDAO extends Minz_ModelPdo implements FreshRSS_Searchable {
|
||||
if ($stm && $stm->execute($values)) {
|
||||
return $this->pdo->lastInsertId('`_feed_id_seq`');
|
||||
} else {
|
||||
$info = $stm == null ? array(2 => 'syntax error') : $stm->errorInfo();
|
||||
$info = $stm == null ? $this->pdo->errorInfo() : $stm->errorInfo();
|
||||
if ($this->autoUpdateDb($info)) {
|
||||
return $this->addFeed($valuesTmp);
|
||||
}
|
||||
@@ -151,7 +151,7 @@ class FreshRSS_FeedDAO extends Minz_ModelPdo implements FreshRSS_Searchable {
|
||||
if ($stm && $stm->execute($values)) {
|
||||
return $stm->rowCount();
|
||||
} else {
|
||||
$info = $stm == null ? array(2 => 'syntax error') : $stm->errorInfo();
|
||||
$info = $stm == null ? $this->pdo->errorInfo() : $stm->errorInfo();
|
||||
if ($this->autoUpdateDb($info)) {
|
||||
return $this->updateFeed($id, $valuesTmp);
|
||||
}
|
||||
@@ -185,7 +185,7 @@ class FreshRSS_FeedDAO extends Minz_ModelPdo implements FreshRSS_Searchable {
|
||||
if ($stm && $stm->execute($values)) {
|
||||
return $stm->rowCount();
|
||||
} else {
|
||||
$info = $stm == null ? array(2 => 'syntax error') : $stm->errorInfo();
|
||||
$info = $stm == null ? $this->pdo->errorInfo() : $stm->errorInfo();
|
||||
Minz_Log::error('SQL error updateLastUpdate: ' . $info[2]);
|
||||
return false;
|
||||
}
|
||||
@@ -209,7 +209,7 @@ class FreshRSS_FeedDAO extends Minz_ModelPdo implements FreshRSS_Searchable {
|
||||
if ($stm && $stm->execute($values)) {
|
||||
return $stm->rowCount();
|
||||
} else {
|
||||
$info = $stm == null ? array(2 => 'syntax error') : $stm->errorInfo();
|
||||
$info = $stm == null ? $this->pdo->errorInfo() : $stm->errorInfo();
|
||||
Minz_Log::error('SQL error changeCategory: ' . $info[2]);
|
||||
return false;
|
||||
}
|
||||
@@ -224,7 +224,7 @@ class FreshRSS_FeedDAO extends Minz_ModelPdo implements FreshRSS_Searchable {
|
||||
if ($stm && $stm->execute($values)) {
|
||||
return $stm->rowCount();
|
||||
} else {
|
||||
$info = $stm == null ? array(2 => 'syntax error') : $stm->errorInfo();
|
||||
$info = $stm == null ? $this->pdo->errorInfo() : $stm->errorInfo();
|
||||
Minz_Log::error('SQL error deleteFeed: ' . $info[2]);
|
||||
return false;
|
||||
}
|
||||
@@ -238,7 +238,7 @@ class FreshRSS_FeedDAO extends Minz_ModelPdo implements FreshRSS_Searchable {
|
||||
if ($stm && $stm->execute($values)) {
|
||||
return $stm->rowCount();
|
||||
} else {
|
||||
$info = $stm == null ? array(2 => 'syntax error') : $stm->errorInfo();
|
||||
$info = $stm == null ? $this->pdo->errorInfo() : $stm->errorInfo();
|
||||
Minz_Log::error('SQL error deleteFeedByCategory: ' . $info[2]);
|
||||
return false;
|
||||
}
|
||||
@@ -330,7 +330,7 @@ class FreshRSS_FeedDAO extends Minz_ModelPdo implements FreshRSS_Searchable {
|
||||
if ($stm !== false) {
|
||||
return self::daoToFeed($stm->fetchAll(PDO::FETCH_ASSOC));
|
||||
} else {
|
||||
$info = $stm == null ? array(0 => '', 1 => '', 2 => 'syntax error') : $stm->errorInfo();
|
||||
$info = $stm == null ? $this->pdo->errorInfo() : $stm->errorInfo();
|
||||
if ($this->autoUpdateDb($info)) {
|
||||
return $this->listFeedsOrderUpdate($defaultCacheDuration);
|
||||
}
|
||||
@@ -384,7 +384,7 @@ class FreshRSS_FeedDAO extends Minz_ModelPdo implements FreshRSS_Searchable {
|
||||
if ($stm && $stm->execute()) {
|
||||
return $stm->rowCount();
|
||||
} else {
|
||||
$info = $stm == null ? array(2 => 'syntax error') : $stm->errorInfo();
|
||||
$info = $stm == null ? $this->pdo->errorInfo() : $stm->errorInfo();
|
||||
Minz_Log::error('SQL error updateCachedValue: ' . $info[2]);
|
||||
return false;
|
||||
}
|
||||
@@ -396,7 +396,7 @@ class FreshRSS_FeedDAO extends Minz_ModelPdo implements FreshRSS_Searchable {
|
||||
$stm->bindParam(':id', $id, PDO::PARAM_INT);
|
||||
$this->pdo->beginTransaction();
|
||||
if (!($stm && $stm->execute())) {
|
||||
$info = $stm == null ? array(2 => 'syntax error') : $stm->errorInfo();
|
||||
$info = $stm == null ? $this->pdo->errorInfo() : $stm->errorInfo();
|
||||
Minz_Log::error('SQL error truncate: ' . $info[2]);
|
||||
$this->pdo->rollBack();
|
||||
return false;
|
||||
@@ -408,7 +408,7 @@ class FreshRSS_FeedDAO extends Minz_ModelPdo implements FreshRSS_Searchable {
|
||||
$stm = $this->pdo->prepare($sql);
|
||||
$stm->bindParam(':id', $id, PDO::PARAM_INT);
|
||||
if (!($stm && $stm->execute($values))) {
|
||||
$info = $stm == null ? array(2 => 'syntax error') : $stm->errorInfo();
|
||||
$info = $stm == null ? $this->pdo->errorInfo() : $stm->errorInfo();
|
||||
Minz_Log::error('SQL error truncate: ' . $info[2]);
|
||||
$this->pdo->rollBack();
|
||||
return false;
|
||||
@@ -466,13 +466,13 @@ class FreshRSS_FeedDAO extends Minz_ModelPdo implements FreshRSS_Searchable {
|
||||
$sql = 'UPDATE `_feed` SET ttl=:new_value WHERE ttl=:old_value';
|
||||
$stm = $this->pdo->prepare($sql);
|
||||
if (!($stm && $stm->execute(array(':new_value' => FreshRSS_Feed::TTL_DEFAULT, ':old_value' => -2)))) {
|
||||
$info = $stm == null ? array(2 => 'syntax error') : $stm->errorInfo();
|
||||
$info = $stm == null ? $this->pdo->errorInfo() : $stm->errorInfo();
|
||||
Minz_Log::error('SQL warning updateTTL 1: ' . $info[2] . ' ' . $sql);
|
||||
|
||||
$sql2 = 'ALTER TABLE `_feed` ADD COLUMN ttl INT NOT NULL DEFAULT ' . FreshRSS_Feed::TTL_DEFAULT; //v0.7.3
|
||||
$stm = $this->pdo->query($sql2);
|
||||
if ($stm === false) {
|
||||
$info = $stm == null ? array(2 => 'syntax error') : $stm->errorInfo();
|
||||
$info = $stm == null ? $this->pdo->errorInfo() : $stm->errorInfo();
|
||||
Minz_Log::error('SQL error updateTTL 2: ' . $info[2] . ' ' . $sql2);
|
||||
}
|
||||
} else {
|
||||
|
||||
Reference in new issue
Block a user