1
1
Fork 0
mirror of https://code.mensbeam.com/MensBeam/Arsse.git synced 2024-12-22 21:22:40 +00:00

More PicoFeed Integration Bug fixes

• Fixed a bug where the feed object’s variable was being reused as the
id for adding feeds to subscriptions
• Modified inline documentation
• Added a TODO for populating the articles table when adding a new feed
This commit is contained in:
Dustin Wilson 2017-02-20 11:58:26 -06:00
parent cb664eab03
commit 26989facfe

View file

@ -266,7 +266,7 @@ class Database {
$this->db->begin(); $this->db->begin();
// If the feed doesn't already exist in the database then add it to the database after determining its validity with picoFeed // If the feed doesn't already exist in the database then add it to the database after determining its validity with PicoFeed.
$qFeed = $this->db->prepare("SELECT id from newssync_feeds where url is ? and username is ? and password is ?", "str", "str", "str"); $qFeed = $this->db->prepare("SELECT id from newssync_feeds where url is ? and username is ? and password is ?", "str", "str", "str");
$feed = $qFeed->run($url, $fetchUser, $fetchPassword)->getSingle(); $feed = $qFeed->run($url, $fetchUser, $fetchPassword)->getSingle();
if ($feed === null) { if ($feed === null) {
@ -282,17 +282,17 @@ class Database {
$feed = $parser->execute(); $feed = $parser->execute();
} catch (PicoFeedException $e) { } catch (PicoFeedException $e) {
// If there's any error while trying to download or parse the feed then return an exception // If there's any error while trying to download or parse the feed then return an exception.
throw new Feed\Exception($url, $e); throw new Feed\Exception($url, $e);
} }
$this->db->prepare("INSERT INTO newssync_feeds(url,title,favicon,source,updated,modified,etag,username,password) values(?,?,?)", "str", "str", "str", "str", "str", "str", "str", "str", "str")->run( $this->db->prepare("INSERT INTO newssync_feeds(url,title,favicon,source,updated,modified,etag,username,password) values(?,?,?)", "str", "str", "str", "str", "str", "str", "str", "str", "str")->run(
$url, $url,
$feed->title, $feed->title,
// Grab the favicon for the feed. Returns an empty string if it cannot find one // Grab the favicon for the Goodfeed; returns an empty string if it cannot find one.
(new PicoFeed\Reader\Favicon)->find($url), (new PicoFeed\Reader\Favicon)->find($url),
$feed->siteUrl, $feed->siteUrl,
// Convert the date formats to ISO 8601 before inserting // Convert the date formats to SQL date format before inserting.
$this->driver::formatDate($feed->date), $this->driver::formatDate($feed->date),
$this->driver::formatDate($resource->getLastModified()), $this->driver::formatDate($resource->getLastModified()),
$resource->getEtag(), $resource->getEtag(),
@ -300,12 +300,15 @@ class Database {
$fetchPassword $fetchPassword
); );
$feed = $qFeed->run($url, $fetchUser, $fetchPassword)->getSingle(); // TODO: Populate newssync_articles with contents of what was obtained from PicoFeed.
// Get the ID for the feed that was just added.
$feedID = $qFeed->run($url, $fetchUser, $fetchPassword)->getSingle();
} }
// Add the feed to a user's subscriptions. // Add the feed to the user's subscriptions.
$this->db->prepare("INSERT INTO newssync_subscriptions(owner,feed) values(?,?)", "str", "int")->run($user,$feed); $this->db->prepare("INSERT INTO newssync_subscriptions(owner,feed) values(?,?)", "str", "int")->run($user, $feedID);
$sub = $this->db->prepare("SELECT id from newssync_subscriptions where owner is ? and feed is ?", "str", "int")->run($user, $feed)->getSingle(); $sub = $this->db->prepare("SELECT id from newssync_subscriptions where owner is ? and feed is ?", "str", "int")->run($user, $feedID)->getSingle();
$this->db->commit(); $this->db->commit();
return $sub; return $sub;
} }