Explorar el Código

More reset default category name (#2639)

Improve https://github.com/FreshRSS/FreshRSS/pull/2638
Alexandre Alapetite hace 6 años
padre
commit
6d596e9e54
Se han modificado 3 ficheros con 15 adiciones y 5 borrados
  1. 1 1
      CHANGELOG.md
  2. 11 4
      app/Models/CategoryDAO.php
  3. 3 0
      app/Models/DatabaseDAO.php

+ 1 - 1
CHANGELOG.md

@@ -9,7 +9,7 @@
 * Bug fixing (regressions from 1.15.0)
 	* Fix database auto-creation at install [#2635](https://github.com/FreshRSS/FreshRSS/pull/2635)
 	* Fix bug in database size estimation with PostgreSQL for users with uppercase names [#2631](https://github.com/FreshRSS/FreshRSS/pull/2631)
-	* Reset name of default category (which cannot be customised anymore) [#2638](https://github.com/FreshRSS/FreshRSS/pull/2638)
+	* Reset name of default category (which cannot be customised anymore) [#2639](https://github.com/FreshRSS/FreshRSS/pull/2639)
 	* Fix UI style details [#2634](https://github.com/FreshRSS/FreshRSS/pull/2634)
 * Security
 	* Improve cookie security with policy `SameSite=Lax` [#2630](https://github.com/FreshRSS/FreshRSS/pull/2630)

+ 11 - 4
app/Models/CategoryDAO.php

@@ -4,6 +4,16 @@ class FreshRSS_CategoryDAO extends Minz_ModelPdo implements FreshRSS_Searchable
 
 	const DEFAULTCATEGORYID = 1;
 
+	public function resetDefaultCategoryName() {
+		//FreshRSS 1.15.1
+		$stm = $this->pdo->prepare('UPDATE `_category` SET name = :name WHERE id = :id');
+		if ($stm) {
+			$stm->bindValue(':id', self::DEFAULTCATEGORYID, PDO::PARAM_INT);
+			$stm->bindValue(':name', 'Uncategorized');
+		}
+		return $stm && $stm->execute();
+	}
+
 	protected function addColumn($name) {
 		Minz_Log::warning(__method__ . ': ' . $name);
 		try {
@@ -46,10 +56,7 @@ class FreshRSS_CategoryDAO extends Minz_ModelPdo implements FreshRSS_Searchable
 					$this->pdo->exec('DROP INDEX IF EXISTS feed_keep_history_index');	//SQLite at least drop index
 				}
 
-				$stm = $this->pdo->prepare('UPDATE `_category` SET name = :name WHERE id = :id');
-				$stm->bindValue(':id', self::DEFAULTCATEGORYID, PDO::PARAM_INT);
-				$stm->bindValue(':name', 'Uncategorized');
-				$stm->execute();
+				$this->resetDefaultCategoryName();
 
 				return $ok;
 			}

+ 3 - 0
app/Models/DatabaseDAO.php

@@ -178,6 +178,9 @@ class FreshRSS_DatabaseDAO extends Minz_ModelPdo {
 	}
 
 	public function minorDbMaintenance() {
+		$catDAO = FreshRSS_Factory::createCategoryDao();
+		$catDAO->resetDefaultCategoryName();
+
 		$this->ensureCaseInsensitiveGuids();
 	}