diff options
| author | 2016-11-06 14:06:02 +0100 | |
|---|---|---|
| committer | 2016-11-06 14:06:02 +0100 | |
| commit | 6a7b5fea3ec301214527f4d8c888cca11d9125e5 (patch) | |
| tree | 00d7d71d6015e78b036746e65d62eb5fc8755b0f | |
| parent | 60941b9a40731be6f06d9422744cbba27982b6f3 (diff) | |
| parent | 1a4fdfb1be7b638f5bfd1011e0f81f5814591474 (diff) | |
Merge branch 'FreshRSS/dev' into git-update
| -rw-r--r-- | CHANGELOG.md | 2 | ||||
| -rw-r--r-- | app/Models/Factory.php | 1 | ||||
| -rw-r--r-- | app/Models/UserDAO.php | 1 | ||||
| -rw-r--r-- | app/install.php | 4 | ||||
| -rw-r--r-- | cli/README.md | 10 | ||||
| -rwxr-xr-x | cli/create-user.php | 3 | ||||
| -rwxr-xr-x | cli/do-install.php | 12 | ||||
| -rwxr-xr-x[-rw-r--r--] | cli/user-info.php | 10 | ||||
| -rw-r--r-- | data/config.default.php | 2 | ||||
| -rw-r--r-- | lib/lib_install.php | 6 | ||||
| -rw-r--r-- | lib/lib_rss.php | 2 |
11 files changed, 31 insertions, 22 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index e8ad27d9e..1dcb1bfec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,8 @@ * New command `./cli/user-info.php` to get some user information [#1345](https://github.com/FreshRSS/FreshRSS/issues/1345) * Bug fixing * Fix bug in estimating last user activity [#1358](https://github.com/FreshRSS/FreshRSS/issues/1358) + * PostgreSQL: fix bug when updating cached values [#1360](https://github.com/FreshRSS/FreshRSS/issues/1360) + * Fix small bugs in installer [#1363](https://github.com/FreshRSS/FreshRSS/pull/1363) ## 2016-11-02 FreshRSS 1.6.1 diff --git a/app/Models/Factory.php b/app/Models/Factory.php index 764987c46..6502c38b7 100644 --- a/app/Models/Factory.php +++ b/app/Models/Factory.php @@ -6,6 +6,7 @@ class FreshRSS_Factory { $conf = Minz_Configuration::get('system'); switch ($conf->db['type']) { case 'sqlite': + case 'pgsql': return new FreshRSS_FeedDAOSQLite($username); default: return new FreshRSS_FeedDAO($username); diff --git a/app/Models/UserDAO.php b/app/Models/UserDAO.php index 190954b1a..32bc6de2f 100644 --- a/app/Models/UserDAO.php +++ b/app/Models/UserDAO.php @@ -88,7 +88,6 @@ class FreshRSS_UserDAO extends Minz_ModelPdo { if (($username == '') || (!ctype_alnum($username))) { $username = Minz_Session::param('currentUser', '_'); } - Minz_Log::debug('touch ' . $username); return touch(join_path(DATA_PATH , 'users', $username, 'config.php')); } diff --git a/app/install.php b/app/install.php index fcc901713..5c8a6e0e8 100644 --- a/app/install.php +++ b/app/install.php @@ -230,7 +230,7 @@ function saveStep3() { $_SESSION['bd_error'] = ''; header('Location: index.php?step=4'); } else { - $_SESSION['bd_error'] = empty($config_array['db']['bd_error']) ? 'Unknown error!' : $config_array['db']['bd_error']; + $_SESSION['bd_error'] = empty($config_array['db']['error']) ? 'Unknown error!' : $config_array['db']['error']; } } invalidateHttpCache(); @@ -375,7 +375,7 @@ function checkDbUser(&$dbOptions) { } } catch (PDOException $e) { $ok = false; - $dbOptions['bd_error'] = $e->getMessage(); + $dbOptions['error'] = $e->getMessage(); } return $ok; } diff --git a/cli/README.md b/cli/README.md index 09dcbd27e..25b12234c 100644 --- a/cli/README.md +++ b/cli/README.md @@ -32,8 +32,8 @@ Options in parenthesis are optional. ```sh cd /usr/share/FreshRSS -./cli/do-install.php --default_user admin --auth_type form ( --environment production --base_url https://rss.example.net/ --title FreshRSS --allow_anonymous --api_enabled --db-type mysql --db-host localhost:3306 --db-user freshrss --db-password dbPassword123 --db-base freshrss --db-prefix freshrss ) -# --auth_type can be: 'form' (recommended), 'http_auth' (using the Web server access control), 'none' (dangerous) +./cli/do-install.php --default_user admin ( --auth_type form --environment production --base_url https://rss.example.net/ --title FreshRSS --allow_anonymous --api_enabled --db-type mysql --db-host localhost:3306 --db-user freshrss --db-password dbPassword123 --db-base freshrss --db-prefix freshrss ) +# --auth_type can be: 'form' (default), 'http_auth' (using the Web server access control), 'none' (dangerous) # --db-type can be: 'sqlite' (default), 'mysql' (MySQL or MariaDB), 'pgsql' (PostgreSQL) # --environment can be: 'production' (default), 'development' (for additional log messages) # --db-prefix is an optional prefix in front of the names of the tables @@ -72,3 +72,9 @@ Example showing user information for all users which username starts with 'a': ```sh ./cli/list-users.php | grep '^a' | xargs -n1 ./cli/user-info.php -h --user ``` + +Example showing all users ranked by date of last activity: + +```sh +./cli/user-info.php -h --user '*' | sort -k2 -r +``` diff --git a/cli/create-user.php b/cli/create-user.php index 008b82ce3..444264cc7 100755 --- a/cli/create-user.php +++ b/cli/create-user.php @@ -43,6 +43,9 @@ if (!$ok) { invalidateHttpCache(FreshRSS_Context::$system_conf->default_user); +echo '• Remember to refresh the feeds of the user: ', $username , "\n", + "\t", './cli/actualize-user.php --user ', $username, "\n"; + accessRights(); done($ok); diff --git a/cli/do-install.php b/cli/do-install.php index 667191680..b687b86cb 100755 --- a/cli/do-install.php +++ b/cli/do-install.php @@ -26,9 +26,9 @@ $dBparams = array( $options = getopt('', array_merge($params, $dBparams)); -if (empty($options['default_user']) || empty($options['auth_type'])) { - fail('Usage: ' . basename(__FILE__) . " --default_user admin --auth_type form" . - " ( --environment production --base_url https://rss.example.net/" . +if (empty($options['default_user'])) { + fail('Usage: ' . basename(__FILE__) . " --default_user admin ( --auth_type form" . + " --environment production --base_url https://rss.example.net/" . " --title FreshRSS --allow_anonymous --api_enabled" . " --db-type mysql --db-host localhost:3306 --db-user freshrss --db-password dbPassword123" . " --db-base freshrss --db-prefix freshrss )"); @@ -51,7 +51,7 @@ if (!ctype_alnum($options['default_user'])) { fail('FreshRSS invalid default username (must be ASCII alphanumeric): ' . $options['default_user']); } -if (!in_array($options['auth_type'], array('form', 'http_auth', 'none'))) { +if (isset($options['auth_type']) && !in_array($options['auth_type'], array('form', 'http_auth', 'none'))) { fail('FreshRSS invalid authentication method (auth_type must be one of { form, http_auth, none }: ' . $options['auth_type']); } @@ -86,11 +86,11 @@ if (file_put_contents(join_path(DATA_PATH, 'config.php'), "<?php\n return " . va $config['db']['default_user'] = $config['default_user']; if (!checkDb($config['db'])) { @unlink(join_path(DATA_PATH, 'config.php')); - fail('FreshRSS database error: ' . (empty($config['db']['bd_error']) ? 'Unknown error' : $config['db']['bd_error'])); + fail('FreshRSS database error: ' . (empty($config['db']['error']) ? 'Unknown error' : $config['db']['error'])); } echo '• Remember to create the default user: ', $config['default_user'] , "\n", - "\t", './cli/create-user.php --user ', $config['default_user'] , " --password 'password' --more-options\n"; + "\t", './cli/create-user.php --user ', $config['default_user'], " --password 'password' --more-options\n"; accessRights(); diff --git a/cli/user-info.php b/cli/user-info.php index 5b26ecb15..dd38e6c7f 100644..100755 --- a/cli/user-info.php +++ b/cli/user-info.php @@ -2,14 +2,6 @@ <?php require('_cli.php'); -function formatSize($bytes) -{//http://www.php.net/manual/function.disk-free-space.php#103382 - $si_prefix = array('', 'k', 'M', 'G', 'T', 'P'); - $i = min((int)log($bytes, 1024), count($si_prefix) - 1); - return ($i <= 0) ? $bytes.'B' : - round($bytes / pow(1024, $i), 2).' '.$si_prefix[$i].'B'; -} - $options = getopt('h', array( 'user:', )); @@ -31,7 +23,7 @@ foreach ($users as $username) { echo $username, "\t", date('c', FreshRSS_UserDAO::mtime($username)), "\t", - formatSize($entryDAO->size()), "\t", + format_bytes($entryDAO->size()), "\t", "\n"; } else { echo diff --git a/data/config.default.php b/data/config.default.php index d3cd3bf22..8b07b85cd 100644 --- a/data/config.default.php +++ b/data/config.default.php @@ -46,7 +46,7 @@ return array( # `http_auth` is an access controled by the HTTP Web server (e.g. `/FreshRSS/p/i/.htaccess` for Apache) # if you use `http_auth`, remember to protect only `/FreshRSS/p/i/`, # and in particular not protect `/FreshRSS/p/api/` if you would like to use the API (different login system). - 'auth_type' => 'none', + 'auth_type' => 'form', # Allow or not the use of the API, used for mobile apps. # End-point is http://example.net/FreshRSS/p/api/greader.php diff --git a/lib/lib_install.php b/lib/lib_install.php index 0e7b7f036..dd8090bcd 100644 --- a/lib/lib_install.php +++ b/lib/lib_install.php @@ -54,8 +54,8 @@ function generateSalt() { function checkDb(&$dbOptions) { $dsn = ''; + $driver_options = null; try { - $driver_options = null; switch ($dbOptions['type']) { case 'mysql': include_once(APP_PATH . '/SQL/install.sql.mysql.php'); @@ -99,8 +99,12 @@ function checkDb(&$dbOptions) { default: return false; } + + $c = new PDO($dsn, $dbOptions['user'], $dbOptions['password'], $driver_options); + $res = $c->query('SELECT 1'); } catch (PDOException $e) { $dsn = ''; + syslog(LOG_DEBUG, 'FreshRSS SQL warning: ' . $e->getMessage()); $dbOptions['error'] = $e->getMessage(); } $dbOptions['dsn'] = $dsn; diff --git a/lib/lib_rss.php b/lib/lib_rss.php index 143b55bee..fc68a96d3 100644 --- a/lib/lib_rss.php +++ b/lib/lib_rss.php @@ -127,6 +127,8 @@ function format_bytes($bytes, $precision = 2, $system = 'IEC') { } elseif ($system === 'SI') { $base = 1000; $units = array('B', 'KB', 'MB', 'GB', 'TB'); + } else { + return format_number($bytes, $precision); } $bytes = max(intval($bytes), 0); $pow = $bytes === 0 ? 0 : floor(log($bytes) / log($base)); |
