diff options
author | Bernhard Posselt <nukeawhale@gmail.com> | 2013-04-05 16:06:04 +0200 |
---|---|---|
committer | Bernhard Posselt <nukeawhale@gmail.com> | 2013-04-05 16:06:04 +0200 |
commit | c6a279128ea6483fb06e052d4e85fba75e9e7fe1 (patch) | |
tree | 1700edcad069721f20b263d63d345b7c65b15b67 | |
parent | 685ff350eb6c91fd8f48d31a4ba6a815d5f6e403 (diff) |
fix #37 by fixing multiple, hard to track down typos
-rw-r--r-- | bl/feedbl.php | 8 | ||||
-rw-r--r-- | db/itemmapper.php | 35 | ||||
-rw-r--r-- | tests/unit/db/ItemMapperTest.php | 4 |
3 files changed, 39 insertions, 8 deletions
diff --git a/bl/feedbl.php b/bl/feedbl.php index 53c430336..9dc8cd312 100644 --- a/bl/feedbl.php +++ b/bl/feedbl.php @@ -103,15 +103,15 @@ class FeedBl extends Bl { public function update($feedId, $userId){ - $feed = $this->mapper->find($feedId, $userId); + $existingFeed = $this->mapper->find($feedId, $userId); try { - list($feed, $items) = $this->feedFetcher->fetch($feed->getUrl()); + list($feed, $items) = $this->feedFetcher->fetch($existingFeed->getUrl()); // insert items in reverse order because the first one is usually the // newest item for($i=count($items)-1; $i>=0; $i--){ $item = $items[$i]; - $item->setFeedId($feed->getId()); + $item->setFeedId($existingFeed->getId()); // if a doesnotexist exception is being thrown the entry does not // exist and the item needs to be created, otherwise @@ -142,7 +142,7 @@ class FeedBl extends Bl { } catch(FetcherException $ex){ // failed updating is not really a problem, so only log it - $this->api->log('Can not update feed with url' . $feed->getUrl() . + $this->api->log('Can not update feed with url' . $existingFeed->getUrl() . ': Not found or bad source'); } } diff --git a/db/itemmapper.php b/db/itemmapper.php index af190cd27..76364283d 100644 --- a/db/itemmapper.php +++ b/db/itemmapper.php @@ -37,7 +37,36 @@ class ItemMapper extends Mapper implements IMapper { protected function findAllRows($sql, $params, $limit=null, $offset=null) { + /*echo $sql . '<br>'; + + print_r($params); + echo '<br>';*/ + /* works + $sql = 'SELECT `items`.* + FROM `*PREFIX*news_items` `items` + JOIN `*PREFIX*news_feeds` `feeds` + ON `feeds`.`id` = `items`.`feed_id` + AND `feeds`.`user_id` = \'admin\' + AND ((`items`.`status` & 2) = 2) + AND `items`.`feed_id` = 20 + ORDER BY `items`.`id` DESC'; + $params = array();*/ + + /* works not */ + /*$params = array('admin', 2, 2, 20); + $sql = 'SELECT `items`.* + FROM `*PREFIX*news_items` `items` + JOIN `*PREFIX*news_feeds` `feeds` + ON `feeds`.`id` = `items`.`feed_id` + AND `feeds`.`user_id` = ? + AND ((`items`.`status` & ?) = ?) + AND `items`.`feed_id` = ? + ORDER BY `items`.`id` DESC';*/ + + //$result = \OCP\DB::prepare($sql, $limit, $offset)->execute($params); $result = $this->execute($sql, $params, $limit, $offset); + + $items = array(); while($row = $result->fetchRow()){ @@ -47,6 +76,8 @@ class ItemMapper extends Mapper implements IMapper { array_push($items, $item); } + //print_r($items); + return $items; } @@ -67,7 +98,7 @@ class ItemMapper extends Mapper implements IMapper { public function find($id, $userId){ - $sql = $this->makeSelectQuery('AND `*PREFIX*news_items`.`id` = ? '); + $sql = $this->makeSelectQuery('AND `items`.`id` = ? '); $row = $this->findOneQuery($sql, array($userId, $id)); $item = new Item(); @@ -173,7 +204,7 @@ class ItemMapper extends Mapper implements IMapper { public function findByGuidHash($guidHash, $feedId, $userId){ $sql = $this->makeSelectQuery( 'AND `items`.`guid_hash` = ? ' . - 'AND `feed`.`id = ? '); + 'AND `feeds`.`id` = ? '); $row = $this->findOneQuery($sql, array($userId, $guidHash, $feedId)); $item = new Item(); diff --git a/tests/unit/db/ItemMapperTest.php b/tests/unit/db/ItemMapperTest.php index a4ed6e921..9446f4256 100644 --- a/tests/unit/db/ItemMapperTest.php +++ b/tests/unit/db/ItemMapperTest.php @@ -87,7 +87,7 @@ class ItemMapperTest extends \OCA\AppFramework\Utility\MapperTestUtility { public function testFind(){ - $sql = $this->makeSelectQuery('AND `*PREFIX*news_items`.`id` = ? '); + $sql = $this->makeSelectQuery('AND `items`.`id` = ? '); $this->setMapperResult($sql, array($this->userId, $this->id), $this->row); @@ -260,7 +260,7 @@ class ItemMapperTest extends \OCA\AppFramework\Utility\MapperTestUtility { $feedId = 3; $sql = $this->makeSelectQuery( 'AND `items`.`guid_hash` = ? ' . - 'AND `feed`.`id = ? '); + 'AND `feeds`.`id` = ? '); $this->setMapperResult($sql, array($this->userId, $hash, $feedId), $this->row); |