mirror of
https://code.mensbeam.com/MensBeam/Arsse.git
synced 2024-12-22 21:22:40 +00:00
Chnage "retain" settings to mean "purge; remove unused database settings
This commit is contained in:
parent
7e76402029
commit
14951e2e4f
3 changed files with 16 additions and 38 deletions
34
lib/Conf.php
34
lib/Conf.php
|
@ -21,28 +21,6 @@ class Conf {
|
||||||
public $dbSQLite3Key = "";
|
public $dbSQLite3Key = "";
|
||||||
/** @var integer Number of seconds for SQLite to wait before returning a timeout error when writing to the database */
|
/** @var integer Number of seconds for SQLite to wait before returning a timeout error when writing to the database */
|
||||||
public $dbSQLite3Timeout = 5;
|
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) */
|
/** @var string Class of the user management driver in use (Internal by default) */
|
||||||
public $userDriver = User\Internal\Driver::class;
|
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 */
|
/** @var string|null User-Agent string to use when fetching feeds from foreign servers */
|
||||||
public $fetchUserAgentString;
|
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 */
|
* @see https://en.wikipedia.org/wiki/ISO_8601#Durations */
|
||||||
public $retainFeeds = "PT24H";
|
public $purgeFeeds = "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)
|
/** @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 */
|
* @see https://en.wikipedia.org/wiki/ISO_8601#Durations */
|
||||||
public $retainArticlesRead = "P7D";
|
public $purgeArticlesRead = "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)
|
/** @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 */
|
* @see https://en.wikipedia.org/wiki/ISO_8601#Durations */
|
||||||
public $retainArticlesUnread = "P21D";
|
public $purgeArticlesUnread = "P21D";
|
||||||
|
|
||||||
/** Creates a new configuration object
|
/** Creates a new configuration object
|
||||||
* @param string $import_file Optional file to read configuration data from
|
* @param string $import_file Optional file to read configuration data from
|
||||||
|
|
|
@ -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)");
|
$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
|
// finally delete feeds that have been orphaned longer than the retention period
|
||||||
$limit = Date::normalize("now");
|
$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
|
// 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);
|
$out = (bool) $this->db->prepare("DELETE from arsse_feeds where orphaned <= ?", "datetime")->run($limit);
|
||||||
// commit changes and return
|
// commit changes and return
|
||||||
|
@ -913,11 +913,11 @@ class Database {
|
||||||
);
|
);
|
||||||
$limitRead = null;
|
$limitRead = null;
|
||||||
$limitUnread = null;
|
$limitUnread = null;
|
||||||
if(Arsse::$conf->retainArticlesRead) {
|
if(Arsse::$conf->purgeArticlesRead) {
|
||||||
$limitRead = Date::sub(Arsse::$conf->retainArticlesRead);
|
$limitRead = Date::sub(Arsse::$conf->purgeArticlesRead);
|
||||||
}
|
}
|
||||||
if(Arsse::$conf->retainArticlesUnread) {
|
if(Arsse::$conf->purgeArticlesUnread) {
|
||||||
$limitUnread = Date::sub(Arsse::$conf->retainArticlesUnread);
|
$limitUnread = Date::sub(Arsse::$conf->purgeArticlesUnread);
|
||||||
}
|
}
|
||||||
$feeds = $this->db->query("SELECT id, size from arsse_feeds")->getAll();
|
$feeds = $this->db->query("SELECT id, size from arsse_feeds")->getAll();
|
||||||
foreach($feeds as $feed) {
|
foreach($feeds as $feed) {
|
||||||
|
|
|
@ -133,7 +133,7 @@ trait SeriesCleanup {
|
||||||
}
|
}
|
||||||
|
|
||||||
function testCleanUpOldArticlesWithUnlimitedReadRetention() {
|
function testCleanUpOldArticlesWithUnlimitedReadRetention() {
|
||||||
Arsse::$conf->retainArticlesRead = "";
|
Arsse::$conf->purgeArticlesRead = "";
|
||||||
Arsse::$db->articleCleanup();
|
Arsse::$db->articleCleanup();
|
||||||
$state = $this->primeExpectations($this->data, [
|
$state = $this->primeExpectations($this->data, [
|
||||||
'arsse_articles' => ["id"]
|
'arsse_articles' => ["id"]
|
||||||
|
@ -145,7 +145,7 @@ trait SeriesCleanup {
|
||||||
}
|
}
|
||||||
|
|
||||||
function testCleanUpOldArticlesWithUnlimitedUnreadRetention() {
|
function testCleanUpOldArticlesWithUnlimitedUnreadRetention() {
|
||||||
Arsse::$conf->retainArticlesUnread = "";
|
Arsse::$conf->purgeArticlesUnread = "";
|
||||||
Arsse::$db->articleCleanup();
|
Arsse::$db->articleCleanup();
|
||||||
$state = $this->primeExpectations($this->data, [
|
$state = $this->primeExpectations($this->data, [
|
||||||
'arsse_articles' => ["id"]
|
'arsse_articles' => ["id"]
|
||||||
|
@ -157,8 +157,8 @@ trait SeriesCleanup {
|
||||||
}
|
}
|
||||||
|
|
||||||
function testCleanUpOldArticlesWithUnlimitedRetention() {
|
function testCleanUpOldArticlesWithUnlimitedRetention() {
|
||||||
Arsse::$conf->retainArticlesRead = "";
|
Arsse::$conf->purgeArticlesRead = "";
|
||||||
Arsse::$conf->retainArticlesUnread = "";
|
Arsse::$conf->purgeArticlesUnread = "";
|
||||||
Arsse::$db->articleCleanup();
|
Arsse::$db->articleCleanup();
|
||||||
$state = $this->primeExpectations($this->data, [
|
$state = $this->primeExpectations($this->data, [
|
||||||
'arsse_articles' => ["id"]
|
'arsse_articles' => ["id"]
|
||||||
|
|
Loading…
Reference in a new issue