From 53eccb2ff78f6d94355cfca3cbfefc981e5de03b Mon Sep 17 00:00:00 2001 From: Bernhard Posselt Date: Tue, 14 Apr 2015 10:51:09 +0200 Subject: more phpdoc and remove unused code --- db/itemmapper.php | 16 ++++++++-------- db/mysql/itemmapper.php | 1 + db/newsmapper.php | 1 - db/statusflag.php | 10 +++++++--- 4 files changed, 16 insertions(+), 12 deletions(-) (limited to 'db') diff --git a/db/itemmapper.php b/db/itemmapper.php index 0ea3b77fc..cc12a2bd0 100644 --- a/db/itemmapper.php +++ b/db/itemmapper.php @@ -49,19 +49,18 @@ class ItemMapper extends NewsMapper { // WARNING: Potential SQL injection if you change this carelessly $sql = 'AND ((`items`.`status` & ' . $status . ') = ' . $status . ') '; - - foreach ($search as $_) { - $sql .= 'AND `items`.`search_index` LIKE ? '; - } - + $sql .= str_repeat('AND `items`.`search_index` LIKE ? ', count($search)); $sql .= $prependTo; return $this->makeSelectQuery($sql, $oldestFirst); } - /** - * wrap and escape search parameters in a like statement - */ + /** + * wrap and escape search parameters in a like statement + * + * @param string[] $search an array of strings that should be searched + * @return array with like parameters + */ private function buildLikeParameters($search=[]) { return array_map(function ($param) { $param = addcslashes($param, '\\_%'); @@ -262,6 +261,7 @@ class ItemMapper extends NewsMapper { /** * Delete all items for feeds that have over $threshold unread and not * starred items + * @param int $threshold the number of items that should be deleted */ public function deleteReadOlderThanThreshold($threshold){ $status = StatusFlag::STARRED | StatusFlag::UNREAD; diff --git a/db/mysql/itemmapper.php b/db/mysql/itemmapper.php index 61d32a821..5fb28880b 100644 --- a/db/mysql/itemmapper.php +++ b/db/mysql/itemmapper.php @@ -28,6 +28,7 @@ class ItemMapper extends \OCA\News\Db\ItemMapper { /** * Delete all items for feeds that have over $threshold unread and not * starred items + * @param int $threshold the number of items that should be deleted */ public function deleteReadOlderThanThreshold($threshold){ $status = StatusFlag::STARRED | StatusFlag::UNREAD; diff --git a/db/newsmapper.php b/db/newsmapper.php index 5f857d8ee..eea69df2a 100644 --- a/db/newsmapper.php +++ b/db/newsmapper.php @@ -14,7 +14,6 @@ namespace OCA\News\Db; use OCP\IDBConnection; -use OCP\AppFramework\Db\Entity; use OCP\AppFramework\Db\Mapper; abstract class NewsMapper extends Mapper { diff --git a/db/statusflag.php b/db/statusflag.php index a3bfd4b18..d91fd0280 100644 --- a/db/statusflag.php +++ b/db/statusflag.php @@ -20,9 +20,13 @@ class StatusFlag { const UPDATED = 0x16; - /** - * Get status for query - */ + /** + * Get status for query + * + * @param int $type the type that should be turned into the status + * @param bool $showAll true if it should return all read items + * @return int the status for the database + */ public function typeToStatus($type, $showAll){ if($type === FeedType::STARRED){ return self::STARRED; -- cgit v1.2.3