diff options
author | Daniel Opitz <danopz@users.noreply.github.com> | 2017-08-14 10:34:53 +0200 |
---|---|---|
committer | Bernhard Posselt <BernhardPosselt@users.noreply.github.com> | 2017-08-14 10:34:53 +0200 |
commit | a97dd58e3b499b60ac8b37786d402d7f2e371a88 (patch) | |
tree | 98bb8a6c750fb33fbef38d22407fa29fbf6c7b1e /lib/Db/FeedMapper.php | |
parent | 7d8a85c82c4c13a71b70ddb4ecb8c40ede4c9b70 (diff) |
Split binary to booleans (#203)
* replaced old status with 2 flags for unread and starred
* add fields to db, replace int(1,0) with booleans in sql queries, removed StatusFlags class + refactor code relying to it
* add repair step for migration
* again use integer(1,0) instead of bool in sql queries, because of sqlite doesn't support true/false
* add/fix unit tests for new boolean status
* set unread/starred flags as statements in sql
* fixed mysql unknown column items.unread, fixed marking of read items on repair step
* remove unnecessary bool casts
* add empty checks to Items::is* methods
* update migration to use native sql instead of the querybuilder
* don't cast the flags manually, let the api do the work
Diffstat (limited to 'lib/Db/FeedMapper.php')
-rw-r--r-- | lib/Db/FeedMapper.php | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/lib/Db/FeedMapper.php b/lib/Db/FeedMapper.php index 056296e49..ad54ffc37 100644 --- a/lib/Db/FeedMapper.php +++ b/lib/Db/FeedMapper.php @@ -35,12 +35,11 @@ class FeedMapper extends NewsMapper { // work because prepared statements dont work. This is a // POSSIBLE SQL INJECTION RISK WHEN MODIFIED WITHOUT THOUGHT. // think twice when changing this - 'AND (`items`.`status` & ' . StatusFlag::UNREAD . ') = ' . - StatusFlag::UNREAD . ' ' . + 'AND unread = ? ' . 'WHERE `feeds`.`id` = ? ' . 'AND `feeds`.`user_id` = ? ' . 'GROUP BY `feeds`.`id`'; - $params = [$id, $userId]; + $params = [true, $id, $userId]; return $this->findEntity($sql, $params); } @@ -57,15 +56,14 @@ class FeedMapper extends NewsMapper { // work because prepared statements dont work. This is a // POSSIBLE SQL INJECTION RISK WHEN MODIFIED WITHOUT THOUGHT. // think twice when changing this - 'AND (`items`.`status` & ' . StatusFlag::UNREAD . ') = ' . - StatusFlag::UNREAD . ' ' . + 'AND unread = ? ' . 'WHERE `feeds`.`user_id` = ? ' . 'AND (`feeds`.`folder_id` = 0 ' . 'OR `folders`.`deleted_at` = 0' . ')' . 'AND `feeds`.`deleted_at` = 0 ' . 'GROUP BY `feeds`.`id`'; - $params = [$userId]; + $params = [true, $userId]; return $this->findEntities($sql, $params); } @@ -82,15 +80,14 @@ class FeedMapper extends NewsMapper { // work because prepared statements dont work. This is a // POSSIBLE SQL INJECTION RISK WHEN MODIFIED WITHOUT THOUGHT. // think twice when changing this - 'AND (`items`.`status` & ' . StatusFlag::UNREAD . ') = ' . - StatusFlag::UNREAD . ' ' . + 'AND unread = ? ' . 'WHERE (`feeds`.`folder_id` = 0 ' . 'OR `folders`.`deleted_at` = 0' . ')' . 'AND `feeds`.`deleted_at` = 0 ' . 'GROUP BY `feeds`.`id`'; - return $this->findEntities($sql); + return $this->findEntities($sql, [true]); } @@ -103,12 +100,11 @@ class FeedMapper extends NewsMapper { // work because prepared statements dont work. This is a // POSSIBLE SQL INJECTION RISK WHEN MODIFIED WITHOUT THOUGHT. // think twice when changing this - 'AND (`items`.`status` & ' . StatusFlag::UNREAD . ') = ' . - StatusFlag::UNREAD . ' ' . + 'AND unread = ? ' . 'WHERE `feeds`.`url_hash` = ? ' . 'AND `feeds`.`user_id` = ? ' . 'GROUP BY `feeds`.`id`'; - $params = [$hash, $userId]; + $params = [true, $hash, $userId]; return $this->findEntity($sql, $params); } |