From bd95d23c8aa4e36cc51bfee51f5c593746d74f4f Mon Sep 17 00:00:00 2001 From: "J. King" Date: Tue, 29 Aug 2017 23:17:57 -0400 Subject: [PATCH] Fix export of nulls in Conf --- README.md | 4 ++-- build.xml | 12 +++++++++--- lib/Conf.php | 4 ++-- tests/Conf/TestConf.php | 4 ++++ 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 2623ff4a..a1bde0c7 100644 --- a/README.md +++ b/README.md @@ -13,12 +13,12 @@ At present the software should be considered in an "alpha" state: though its cor The Arsse has the following requirements: -- A Web server +- A Linux server utilizing systemd and Nginx (tested on Ubuntu 16.04) - PHP 7.0.7 or newer with the following extensions: - [intl](http://php.net/manual/en/book.intl.php), [json](http://php.net/manual/en/book.json.php), [hash](http://php.net/manual/en/book.hash.php), and [pcre](http://php.net/manual/en/book.pcre.php) - [dom](http://php.net/manual/en/book.dom.php), [simplexml](http://php.net/manual/en/book.simplexml.php), and [iconv](http://php.net/manual/en/book.iconv.php) (for picoFeed) - [sqlite3](http://php.net/manual/en/book.sqlite3.php) -- The ability to run daemon processes on the server +- Privileges to create and run daemon processes on the server ## Installation diff --git a/build.xml b/build.xml index 95f25d0c..5524305a 100644 --- a/build.xml +++ b/build.xml @@ -31,10 +31,16 @@ - - + + + + + + - + + + diff --git a/lib/Conf.php b/lib/Conf.php index 7b4ad3c7..a995a949 100644 --- a/lib/Conf.php +++ b/lib/Conf.php @@ -114,11 +114,11 @@ class Conf { $conf = new \ReflectionObject($this); foreach ($conf->getProperties(\ReflectionProperty::IS_PUBLIC) as $prop) { $name = $prop->name; - // add the property to the output if the value is scalar and either: + // add the property to the output if the value is scalar (or null) and either: // 1. full output has been requested // 2. the property is not defined in the class // 3. it differs from the default - if (is_scalar($this->$name) && ($full || !$prop->isDefault() || $this->$name !== $ref->$name)) { + if ((is_scalar($this->$name) || is_null($this->$name)) && ($full || !$prop->isDefault() || $this->$name !== $ref->$name)) { $out[$name] = $this->$name; } } diff --git a/tests/Conf/TestConf.php b/tests/Conf/TestConf.php index 6839b2f6..ad2bb137 100644 --- a/tests/Conf/TestConf.php +++ b/tests/Conf/TestConf.php @@ -95,9 +95,11 @@ class TestConf extends Test\AbstractTest { $conf = new Conf(); $conf->lang = ["en", "fr"]; // should not be exported: not scalar $conf->dbSQLite3File = "test.db"; // should be exported: value changed + $conf->userDriver = null; // should be exported: changed value, even when null $conf->someCustomProperty = "Look at me!"; // should be exported: unknown property $exp = [ 'dbSQLite3File' => "test.db", + 'userDriver' => null, 'someCustomProperty' => "Look at me!", ]; $this->assertSame($exp, $conf->export()); @@ -112,11 +114,13 @@ class TestConf extends Test\AbstractTest { $conf = new Conf(); $conf->lang = ["en", "fr"]; // should not be exported: not scalar $conf->dbSQLite3File = "test.db"; // should be exported: value changed + $conf->userDriver = null; // should be exported: changed value, even when null $conf->someCustomProperty = "Look at me!"; // should be exported: unknown property $conf->exportFile(self::$path."confNotArray"); $arr = (include self::$path."confNotArray"); $exp = [ 'dbSQLite3File' => "test.db", + 'userDriver' => null, 'someCustomProperty' => "Look at me!", ]; $this->assertSame($exp, $arr);