mirror of
https://github.com/FreshRSS/FreshRSS.git
synced 2026-05-24 16:25:00 -04:00
Remove FreshRSS_Searchable for better types (#5212)
* Remove FreshRSS_Searchable for better types The interface was not used, and it was preventing more precise types for the different `searchById()` methods, as they each have different input and output types. * Fix type
This commit is contained in:
committed by
GitHub
parent
247215ffaa
commit
1a0616562d
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
class FreshRSS_CategoryDAO extends Minz_ModelPdo implements FreshRSS_Searchable {
|
||||
class FreshRSS_CategoryDAO extends Minz_ModelPdo {
|
||||
|
||||
const DEFAULTCATEGORYID = 1;
|
||||
|
||||
@@ -224,8 +224,7 @@ SQL;
|
||||
}
|
||||
}
|
||||
|
||||
/** @return FreshRSS_Category|null */
|
||||
public function searchById($id) {
|
||||
public function searchById(int $id): ?FreshRSS_Category {
|
||||
$sql = 'SELECT * FROM `_category` WHERE id=:id';
|
||||
$stm = $this->pdo->prepare($sql);
|
||||
if ($stm &&
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
class FreshRSS_EntryDAO extends Minz_ModelPdo implements FreshRSS_Searchable {
|
||||
class FreshRSS_EntryDAO extends Minz_ModelPdo {
|
||||
|
||||
public static function isCompressed(): bool {
|
||||
return true;
|
||||
@@ -732,8 +732,7 @@ SQL;
|
||||
return isset($res[0]) ? FreshRSS_Entry::fromArray($res[0]) : null;
|
||||
}
|
||||
|
||||
/** @return FreshRSS_Entry|null */
|
||||
public function searchById($id) {
|
||||
public function searchById(string $id): ?FreshRSS_Entry {
|
||||
$sql = 'SELECT id, guid, title, author, '
|
||||
. (static::isCompressed() ? 'UNCOMPRESS(content_bin) AS content' : 'content')
|
||||
. ', link, date, is_read, is_favorite, id_feed, tags, attributes '
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
class FreshRSS_FeedDAO extends Minz_ModelPdo implements FreshRSS_Searchable {
|
||||
class FreshRSS_FeedDAO extends Minz_ModelPdo {
|
||||
|
||||
protected function addColumn(string $name) {
|
||||
if ($this->pdo->inTransaction()) {
|
||||
@@ -284,10 +284,7 @@ SQL;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return FreshRSS_Feed|null
|
||||
*/
|
||||
public function searchById($id) {
|
||||
public function searchById(int $id): ?FreshRSS_Feed {
|
||||
$sql = 'SELECT * FROM `_feed` WHERE id=:id';
|
||||
$stm = $this->pdo->prepare($sql);
|
||||
$stm->bindParam(':id', $id, PDO::PARAM_INT);
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
<?php
|
||||
|
||||
interface FreshRSS_Searchable {
|
||||
|
||||
/**
|
||||
* @param int|string $id
|
||||
* @return Minz_Model
|
||||
*/
|
||||
public function searchById($id);
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
class FreshRSS_TagDAO extends Minz_ModelPdo implements FreshRSS_Searchable {
|
||||
class FreshRSS_TagDAO extends Minz_ModelPdo {
|
||||
|
||||
public function sqlIgnore(): string {
|
||||
return 'IGNORE';
|
||||
@@ -197,10 +197,7 @@ SQL;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return FreshRSS_Tag|null
|
||||
*/
|
||||
public function searchById($id) {
|
||||
public function searchById(int $id): ?FreshRSS_Tag {
|
||||
$sql = 'SELECT * FROM `_tag` WHERE id=?';
|
||||
$stm = $this->pdo->prepare($sql);
|
||||
$values = array($id);
|
||||
|
||||
@@ -474,7 +474,7 @@ final class FeverAPI
|
||||
$group_ids = explode(',', $_REQUEST['group_ids']);
|
||||
$feeds = [];
|
||||
foreach ($group_ids as $id) {
|
||||
$category = $categoryDAO->searchById($id); //TODO: Transform to SQL query without loop! Consider FreshRSS_CategoryDAO::listCategories(true)
|
||||
$category = $categoryDAO->searchById((int)$id); //TODO: Transform to SQL query without loop! Consider FreshRSS_CategoryDAO::listCategories(true)
|
||||
if ($category == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user