From 14951e2e4f35ad2cdfc24fa5bf8218feb06cbf34 Mon Sep 17 00:00:00 2001 From: "J. King" Date: Sun, 20 Aug 2017 15:46:35 -0400 Subject: [PATCH] Chnage "retain" settings to mean "purge; remove unused database settings --- lib/Conf.php | 34 +++++----------------------- lib/Database.php | 12 +++++----- tests/lib/Database/SeriesCleanup.php | 8 +++---- 3 files changed, 16 insertions(+), 38 deletions(-) diff --git a/lib/Conf.php b/lib/Conf.php index bd6a620f..ff176b02 100644 --- a/lib/Conf.php +++ b/lib/Conf.php @@ -21,28 +21,6 @@ class Conf { public $dbSQLite3Key = ""; /** @var integer Number of seconds for SQLite to wait before returning a timeout error when writing to the database */ public $dbSQLite3Timeout = 5; - /** @var string Address of host name for PostgreSQL database server (if using PostgreSQL) */ - public $dbPostgreSQLHost = "localhost"; - /** @var string Log-in user name for PostgreSQL database server (if using PostgreSQL) */ - public $dbPostgreSQLUser = "arsse"; - /** @var string Log-in password for PostgreSQL database server (if using PostgreSQL) */ - public $dbPostgreSQLPass = ""; - /** @var integer Listening port for PostgreSQL database server (if using PostgreSQL) */ - public $dbPostgreSQLPort = 5432; - /** @var string Database name on PostgreSQL database server (if using PostgreSQL) */ - public $dbPostgreSQLDb = "arsse"; - /** @var string Schema name on PostgreSQL database server (if using PostgreSQL) */ - public $dbPostgreSQLSchema = ""; - /** @var string Address of host name for MySQL/MariaDB database server (if using MySQL or MariaDB) */ - public $dbMySQLHost = "localhost"; - /** @var string Log-in user name for MySQL/MariaDB database server (if using MySQL or MariaDB) */ - public $dbMySQLUser = "arsse"; - /** @var string Log-in password for MySQL/MariaDB database server (if using MySQL or MariaDB) */ - public $dbMySQLPass = ""; - /** @var integer Listening port for MySQL/MariaDB database server (if using MySQL or MariaDB) */ - public $dbMySQLPort = 3306; - /** @var string Database name on MySQL/MariaDB database server (if using MySQL or MariaDB) */ - public $dbMySQLDb = "arsse"; /** @var string Class of the user management driver in use (Internal by default) */ public $userDriver = User\Internal\Driver::class; @@ -74,15 +52,15 @@ class Conf { /** @var string|null User-Agent string to use when fetching feeds from foreign servers */ public $fetchUserAgentString; - /** @var string Amount of time to keep a feed's articles in the database after all its subscriptions have been deleted, as an ISO 8601 duration (default: 24 hours; empty string for forever) + /** @var string When to delete a feed from the database after all its subscriptions have been deleted, as an ISO 8601 duration (default: 24 hours; empty string for never) * @see https://en.wikipedia.org/wiki/ISO_8601#Durations */ - public $retainFeeds = "PT24H"; - /** @var string Amount of time to keep an unstarred article in the database after it has been marked read by all users, as an ISO 8601 duration (default: 7 days; empty string for forever) + public $purgeFeeds = "PT24H"; + /** @var string When to delete an unstarred article in the database after it has been marked read by all users, as an ISO 8601 duration (default: 7 days; empty string for never) * @see https://en.wikipedia.org/wiki/ISO_8601#Durations */ - public $retainArticlesRead = "P7D"; - /** @var string Amount of time to keep an unstarred article in the database regardless of its read state, as an ISO 8601 duration (default: 21 days; empty string for forever) + public $purgeArticlesRead = "P7D"; + /** @var string When to delete an unstarred article in the database regardless of its read state, as an ISO 8601 duration (default: 21 days; empty string for never) * @see https://en.wikipedia.org/wiki/ISO_8601#Durations */ - public $retainArticlesUnread = "P21D"; + public $purgeArticlesUnread = "P21D"; /** Creates a new configuration object * @param string $import_file Optional file to read configuration data from diff --git a/lib/Database.php b/lib/Database.php index 71782e80..a3223c3d 100644 --- a/lib/Database.php +++ b/lib/Database.php @@ -633,9 +633,9 @@ class Database { $this->db->query("UPDATE arsse_feeds set orphaned = CURRENT_TIMESTAMP where orphaned is null and not exists(SELECT id from arsse_subscriptions where feed is arsse_feeds.id)"); // finally delete feeds that have been orphaned longer than the retention period $limit = Date::normalize("now"); - if(Arsse::$conf->retainFeeds) { + if(Arsse::$conf->purgeFeeds) { // if there is a retention period specified, compute it; otherwise feed are deleted immediatelty - $limit->sub(new \DateInterval(Arsse::$conf->retainFeeds)); + $limit->sub(new \DateInterval(Arsse::$conf->purgeFeeds)); } $out = (bool) $this->db->prepare("DELETE from arsse_feeds where orphaned <= ?", "datetime")->run($limit); // commit changes and return @@ -913,11 +913,11 @@ class Database { ); $limitRead = null; $limitUnread = null; - if(Arsse::$conf->retainArticlesRead) { - $limitRead = Date::sub(Arsse::$conf->retainArticlesRead); + if(Arsse::$conf->purgeArticlesRead) { + $limitRead = Date::sub(Arsse::$conf->purgeArticlesRead); } - if(Arsse::$conf->retainArticlesUnread) { - $limitUnread = Date::sub(Arsse::$conf->retainArticlesUnread); + if(Arsse::$conf->purgeArticlesUnread) { + $limitUnread = Date::sub(Arsse::$conf->purgeArticlesUnread); } $feeds = $this->db->query("SELECT id, size from arsse_feeds")->getAll(); foreach($feeds as $feed) { diff --git a/tests/lib/Database/SeriesCleanup.php b/tests/lib/Database/SeriesCleanup.php index 9db8b3ef..1c6adf76 100644 --- a/tests/lib/Database/SeriesCleanup.php +++ b/tests/lib/Database/SeriesCleanup.php @@ -133,7 +133,7 @@ trait SeriesCleanup { } function testCleanUpOldArticlesWithUnlimitedReadRetention() { - Arsse::$conf->retainArticlesRead = ""; + Arsse::$conf->purgeArticlesRead = ""; Arsse::$db->articleCleanup(); $state = $this->primeExpectations($this->data, [ 'arsse_articles' => ["id"] @@ -145,7 +145,7 @@ trait SeriesCleanup { } function testCleanUpOldArticlesWithUnlimitedUnreadRetention() { - Arsse::$conf->retainArticlesUnread = ""; + Arsse::$conf->purgeArticlesUnread = ""; Arsse::$db->articleCleanup(); $state = $this->primeExpectations($this->data, [ 'arsse_articles' => ["id"] @@ -157,8 +157,8 @@ trait SeriesCleanup { } function testCleanUpOldArticlesWithUnlimitedRetention() { - Arsse::$conf->retainArticlesRead = ""; - Arsse::$conf->retainArticlesUnread = ""; + Arsse::$conf->purgeArticlesRead = ""; + Arsse::$conf->purgeArticlesUnread = ""; Arsse::$db->articleCleanup(); $state = $this->primeExpectations($this->data, [ 'arsse_articles' => ["id"]