From ac73ed0e7f829f3c87562175760d2f86aaca32c2 Mon Sep 17 00:00:00 2001 From: "J. King" Date: Tue, 11 Jul 2017 20:27:37 -0400 Subject: [PATCH] More tweaks - Changed Data::$l to Data::$lang; it's not used enough to justify the possibly confusing shortening - Made database auto-update a general rather than per-driver setting - Added settings for forthcoming feed fetching service --- lib/AbstractException.php | 2 +- lib/Conf.php | 10 +++++++--- lib/Data.php | 6 +++--- lib/Db/SQLite3/Driver.php | 6 +++--- lib/User/Internal/Driver.php | 2 +- tests/Exception/TestException.php | 8 ++++---- tests/lib/AbstractTest.php | 2 +- tests/lib/Lang/Setup.php | 8 ++++---- 8 files changed, 24 insertions(+), 20 deletions(-) diff --git a/lib/AbstractException.php b/lib/AbstractException.php index 83d2d3db..4bffebe5 100644 --- a/lib/AbstractException.php +++ b/lib/AbstractException.php @@ -83,7 +83,7 @@ abstract class AbstractException extends \Exception { $code = self::CODES[$codeID]; $msg = "Exception.".str_replace("\\", "/", $class).".$msgID"; } - $msg = Data::$l->msg($msg, $vars); + $msg = Data::$lang->msg($msg, $vars); } parent::__construct($msg, $code, $e); } diff --git a/lib/Conf.php b/lib/Conf.php index 451bc926..55024669 100644 --- a/lib/Conf.php +++ b/lib/Conf.php @@ -7,27 +7,31 @@ class Conf { public $dbDriver = Db\SQLite3\Driver::class; public $dbSchemaBase = BASE.'sql'; + public $dbAutoUpdate = true; public $dbSQLite3File = BASE."arsse.db"; public $dbSQLite3Key = ""; - public $dbSQLite3AutoUpd = true; public $dbPostgreSQLHost = "localhost"; public $dbPostgreSQLUser = "arsse"; public $dbPostgreSQLPass = ""; public $dbPostgreSQLPort = 5432; public $dbPostgreSQLDb = "arsse"; public $dbPostgreSQLSchema = ""; - public $dbPostgreSQLAutoUpd = true; public $dbMySQLHost = "localhost"; public $dbMySQLUser = "arsse"; public $dbMySQLPass = ""; public $dbMySQLPort = 3306; public $dbMySQLDb = "arsse"; - public $dbMySQLAutoUpd = true; public $userDriver = User\Internal\Driver::class; public $userComposeNames = true; public $userTempPasswordLength = 20; + public $serviceDriver = Service\Curl\Driver::class; + public $serviceFrequency = "PT2M"; + public $serviceCurlBase = "http://localhost/"; + public $serviceCurlUser = null; + public $serviceCurlPassword = null; + public $fetchTimeout = 10; public $fetchSizeLimit = 2 * 1024 * 1024; public $fetchUserAgentString; diff --git a/lib/Data.php b/lib/Data.php index 30b981b9..290f5d38 100644 --- a/lib/Data.php +++ b/lib/Data.php @@ -3,15 +3,15 @@ declare(strict_types=1); namespace JKingWeb\Arsse; class Data { - public static $l; + public static $lang; public static $conf; public static $db; public static $user; static function load(Conf $conf) { - static::$l = new Lang(); + static::$lang = new Lang(); static::$conf = $conf; - static::$l->set($conf->lang); + static::$lang->set($conf->lang); static::$db = new Database(); static::$user = new User(); } diff --git a/lib/Db/SQLite3/Driver.php b/lib/Db/SQLite3/Driver.php index 342569bd..cffc00a6 100644 --- a/lib/Db/SQLite3/Driver.php +++ b/lib/Db/SQLite3/Driver.php @@ -46,7 +46,7 @@ class Driver extends \JKingWeb\Arsse\Db\AbstractDriver { } } - protected function makeConnection(string $file, int $opts, string $key): \SQLite3 { + protected function makeConnection(string $file, int $opts, string $key) { return new \SQLite3($file, $opts, $key); } @@ -57,7 +57,7 @@ class Driver extends \JKingWeb\Arsse\Db\AbstractDriver { static public function driverName(): string { - return Data::$l->msg("Driver.Db.SQLite3.Name"); + return Data::$lang->msg("Driver.Db.SQLite3.Name"); } public function schemaVersion(): int { @@ -66,7 +66,7 @@ class Driver extends \JKingWeb\Arsse\Db\AbstractDriver { public function schemaUpdate(int $to): bool { $ver = $this->schemaVersion(); - if(!Data::$conf->dbSQLite3AutoUpd) throw new Exception("updateManual", ['version' => $ver, 'driver_name' => $this->driverName()]); + if(!Data::$conf->dbAutoUpdate) throw new Exception("updateManual", ['version' => $ver, 'driver_name' => $this->driverName()]); if($ver >= $to) throw new Exception("updateTooNew", ['difference' => ($ver - $to), 'current' => $ver, 'target' => $to, 'driver_name' => $this->driverName()]); $sep = \DIRECTORY_SEPARATOR; $path = Data::$conf->dbSchemaBase.$sep."SQLite3".$sep; diff --git a/lib/User/Internal/Driver.php b/lib/User/Internal/Driver.php index 62b4f764..d6b3167a 100644 --- a/lib/User/Internal/Driver.php +++ b/lib/User/Internal/Driver.php @@ -21,7 +21,7 @@ final class Driver implements Iface { ]; static public function driverName(): string { - return Data::$l->msg("Driver.User.Internal.Name"); + return Data::$lang->msg("Driver.User.Internal.Name"); } public function driverFunctions(string $function = null) { diff --git a/tests/Exception/TestException.php b/tests/Exception/TestException.php index 4a453b2a..6910fc94 100644 --- a/tests/Exception/TestException.php +++ b/tests/Exception/TestException.php @@ -8,14 +8,14 @@ class TestException extends Test\AbstractTest { function setUp() { $this->clearData(false); // create a mock Lang object so as not to create a dependency loop - Data::$l = Phake::mock(Lang::class); - Phake::when(Data::$l)->msg->thenReturn(""); + Data::$lang = Phake::mock(Lang::class); + Phake::when(Data::$lang)->msg->thenReturn(""); } function tearDown() { // verify calls to the mock Lang object - Phake::verify(Data::$l, Phake::atLeast(0))->msg($this->isType("string"), $this->anything()); - Phake::verifyNoOtherInteractions(Data::$l); + Phake::verify(Data::$lang, Phake::atLeast(0))->msg($this->isType("string"), $this->anything()); + Phake::verifyNoOtherInteractions(Data::$lang); // clean up $this->clearData(true); } diff --git a/tests/lib/AbstractTest.php b/tests/lib/AbstractTest.php index efae8e2d..ed37c3f5 100644 --- a/tests/lib/AbstractTest.php +++ b/tests/lib/AbstractTest.php @@ -37,7 +37,7 @@ abstract class AbstractTest extends \PHPUnit\Framework\TestCase { Data::$$prop = null; } if($loadLang) { - Data::$l = new \JKingWeb\Arsse\Lang(); + Data::$lang = new \JKingWeb\Arsse\Lang(); } return true; } diff --git a/tests/lib/Lang/Setup.php b/tests/lib/Lang/Setup.php index 45ee5509..571d8987 100644 --- a/tests/lib/Lang/Setup.php +++ b/tests/lib/Lang/Setup.php @@ -37,16 +37,16 @@ trait Setup { $this->l = new TestLang($this->path); // create a mock Lang object so as not to create a dependency loop $this->clearData(false); - Data::$l = Phake::mock(Lang::class); - Phake::when(Data::$l)->msg->thenReturn(""); + Data::$lang = Phake::mock(Lang::class); + Phake::when(Data::$lang)->msg->thenReturn(""); // call the additional setup method if it exists if(method_exists($this, "setUpSeries")) $this->setUpSeries(); } function tearDown() { // verify calls to the mock Lang object - Phake::verify(Data::$l, Phake::atLeast(0))->msg($this->isType("string"), $this->anything()); - Phake::verifyNoOtherInteractions(Data::$l); + Phake::verify(Data::$lang, Phake::atLeast(0))->msg($this->isType("string"), $this->anything()); + Phake::verifyNoOtherInteractions(Data::$lang); // clean up $this->clearData(true); // call the additional teardiwn method if it exists