From 115612959302fc51c4720b7a954bf8cbe1b14f3b Mon Sep 17 00:00:00 2001 From: Alexis Degrugillier Date: Sat, 21 Feb 2015 09:08:06 -0500 Subject: Use the search object to get values in the search It is now possible to combine multiple keywords to do a search. The separation of concern is better now since the search extraction is not done in the DAO anymore. At the moment, a multiple keyword search is stored as this. It could be nice to have it rendered differently in the search page to make it more readable. At the moment, there is a problem with search enclosed by ". Same search works well when enclosed by '. --- app/Controllers/indexController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/Controllers/indexController.php') diff --git a/app/Controllers/indexController.php b/app/Controllers/indexController.php index c53d3223e..c1aaca53f 100755 --- a/app/Controllers/indexController.php +++ b/app/Controllers/indexController.php @@ -173,7 +173,7 @@ class FreshRSS_index_Controller extends Minz_ActionController { FreshRSS_Context::$state |= FreshRSS_Entry::STATE_READ; } - FreshRSS_Context::$search = Minz_Request::param('search', ''); + FreshRSS_Context::$search = new FreshRSS_Search(Minz_Request::param('search', '')); FreshRSS_Context::$order = Minz_Request::param( 'order', FreshRSS_Context::$user_conf->sort_order ); -- cgit v1.2.3 From 27d2b88a19345dfc665dc086d3c2b2e4547e1b7f Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sat, 23 May 2015 02:23:38 +0200 Subject: Minz getBaseUrl correction and RSS template bug https://github.com/FreshRSS/FreshRSS/issues/848 Corrections in Minz (HTTP_HOST was not sanitized, getURI() was never used and not working anyway with absolute base_url) $this->url was not defined in rss.phtml --- app/Controllers/indexController.php | 1 + constants.php | 3 ++- lib/Minz/Request.php | 46 +++++++++++-------------------------- lib/Minz/Url.php | 10 +------- 4 files changed, 18 insertions(+), 42 deletions(-) (limited to 'app/Controllers/indexController.php') diff --git a/app/Controllers/indexController.php b/app/Controllers/indexController.php index c1aaca53f..baaf99065 100755 --- a/app/Controllers/indexController.php +++ b/app/Controllers/indexController.php @@ -137,6 +137,7 @@ class FreshRSS_index_Controller extends Minz_ActionController { } // No layout for RSS output. + $this->view->url = empty($_SERVER['QUERY_STRING']) ? '' : '?' . $_SERVER['QUERY_STRING']; $this->view->rss_title = FreshRSS_Context::$name . ' | ' . Minz_View::title(); $this->view->_useLayout(false); header('Content-Type: application/rss+xml; charset=utf-8'); diff --git a/constants.php b/constants.php index b20bf0710..d32fdfa9b 100644 --- a/constants.php +++ b/constants.php @@ -11,7 +11,8 @@ define('PHP_COMPRESSION', false); define('FRESHRSS_PATH', dirname(__FILE__)); define('PUBLIC_PATH', FRESHRSS_PATH . '/p'); - define('INDEX_PATH', PUBLIC_PATH . '/i'); + define('PUBLIC_TO_INDEX_PATH', '/i'); + define('INDEX_PATH', PUBLIC_PATH . PUBLIC_TO_INDEX_PATH); define('PUBLIC_RELATIVE', '..'); define('DATA_PATH', FRESHRSS_PATH . '/data'); diff --git a/lib/Minz/Request.php b/lib/Minz/Request.php index 6db2e9c7a..b9eda82a5 100644 --- a/lib/Minz/Request.php +++ b/lib/Minz/Request.php @@ -84,45 +84,27 @@ class Minz_Request { self::magicQuotesOff(); } - /** - * Retourn le nom de domaine du site - */ - public static function getDomainName() { - return $_SERVER['HTTP_HOST']; - } - /** * Détermine la base de l'url * @return la base de l'url */ - public static function getBaseUrl() { + public static function getBaseUrl($baseUrlSuffix = '') { $conf = Minz_Configuration::get('system'); - $defaultBaseUrl = $conf->base_url; - if (!empty($defaultBaseUrl)) { - return $defaultBaseUrl; - } elseif (isset($_SERVER['REQUEST_URI'])) { - return dirname($_SERVER['REQUEST_URI']) . '/'; - } else { - return '/'; - } - } - - /** - * Récupère l'URI de la requête - * @return l'URI - */ - public static function getURI() { - if (isset($_SERVER['REQUEST_URI'])) { - $base_url = self::getBaseUrl(); - $uri = $_SERVER['REQUEST_URI']; - - $len_base_url = strlen($base_url); - $real_uri = substr($uri, $len_base_url); + $url = $conf->base_url; + if ($url == '' || !preg_match('%^https?://%i', $url)) { + $url = 'http'; + $host = empty($_SERVER['HTTP_HOST']) ? $_SERVER['SERVER_NAME'] : $_SERVER['HTTP_HOST']; + $port = empty($_SERVER['SERVER_PORT']) ? 80 : $_SERVER['SERVER_PORT']; + if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on') { + $url .= 's://' . $host . ($port == 443 ? '' : ':' . $port); + } else { + $url .= '://' . $host . ($port == 80 ? '' : ':' . $port); + } + $url .= isset($_SERVER['REQUEST_URI']) ? dirname($_SERVER['REQUEST_URI']) : ''; } else { - $real_uri = ''; + $url = rtrim($url, '/\\') . $baseUrlSuffix; } - - return $real_uri; + return filter_var($url . '/', FILTER_SANITIZE_URL); } /** diff --git a/lib/Minz/Url.php b/lib/Minz/Url.php index af555a277..a47d8f1a6 100644 --- a/lib/Minz/Url.php +++ b/lib/Minz/Url.php @@ -10,7 +10,6 @@ class Minz_Url { * $url['c'] = controller * $url['a'] = action * $url['params'] = tableau des paramètres supplémentaires - * $url['protocol'] = protocole à utiliser (http par défaut) * ou comme une chaîne de caractère * @param $encodage pour indiquer comment encoder les & (& ou & pour html) * @return l'url formatée @@ -25,14 +24,7 @@ class Minz_Url { $url_string = ''; if ($absolute) { - if ($isArray && isset ($url['protocol'])) { - $protocol = $url['protocol']; - } elseif (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') { - $protocol = 'https:'; - } else { - $protocol = 'http:'; - } - $url_string = $protocol . '//' . Minz_Request::getDomainName () . Minz_Request::getBaseUrl (); + $url_string = Minz_Request::getBaseUrl(PUBLIC_TO_INDEX_PATH); } else { $url_string = $isArray ? '.' : PUBLIC_RELATIVE; } -- cgit v1.2.3 From b042d3a7728037db90a9306c61091be0a8ac42c4 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sat, 23 Apr 2016 19:10:32 +0200 Subject: HTTP2 optimization Fast flush HTTP headers, push promise CSS. Requires PHP 5.3+ due to anonymous function. Do not load syles, scripts, and notifications for Ajax requests. https://github.com/FreshRSS/FreshRSS/issues/1089 --- README.fr.md | 2 +- README.md | 2 +- app/Controllers/indexController.php | 64 +++++++++++++++++++------------------ app/FreshRSS.php | 37 ++++++++++----------- app/Models/Themes.php | 4 --- app/layout/layout.phtml | 40 ++++++++++++----------- lib/Minz/Request.php | 5 ++- lib/Minz/Url.php | 12 ++++--- lib/lib_rss.php | 4 +++ 9 files changed, 89 insertions(+), 81 deletions(-) (limited to 'app/Controllers/indexController.php') diff --git a/README.fr.md b/README.fr.md index 794b1a9e1..a173f0a75 100644 --- a/README.fr.md +++ b/README.fr.md @@ -33,7 +33,7 @@ Nous sommes une communauté amicale. * Serveur modeste, par exemple sous Linux ou Windows * Fonctionne même sur un Raspberry Pi 1 avec des temps de réponse < 1s (testé sur 150 flux, 22k articles) * Serveur Web Apache2 (recommandé), ou nginx, lighttpd (non testé sur les autres) -* PHP 5.2.1+ (PHP 5.3.7+ recommandé, et PHP 5.5+ pour les performances) (support bêta de PHP 7 avec encore meilleures performances) +* PHP 5.3+ (PHP 5.3.7+ recommandé, et PHP 5.5+ pour les performances, et PHP 7+ pour d’encore meilleures performances) * Requis : [PDO_MySQL](http://php.net/pdo-mysql) ou [PDO_SQLite](http://php.net/pdo-sqlite), [cURL](http://php.net/curl), [GMP](http://php.net/gmp) (pour accès API sur plateformes < 64 bits), [IDN](http://php.net/intl.idn) (pour les noms de domaines internationalisés) * Recommandés : [iconv](http://php.net/iconv), [JSON](http://php.net/json), [mbstring](http://php.net/mbstring), [Zip](http://php.net/zip), [zlib](http://php.net/zlib) * Inclus par défaut : [DOM](http://php.net/dom), [XML](http://php.net/xml)… diff --git a/README.md b/README.md index 728204a38..4d3bb5c4c 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ We are a friendly community. * Light server running Linux or Windows * It even works on Raspberry Pi 1 with response time under a second (tested with 150 feeds, 22k articles) * A web server: Apache2 (recommended), nginx, lighttpd (not tested on others) -* PHP 5.2.1+ (PHP 5.3.7+ recommended, and PHP 5.5+ for performance) (beta support for PHP 7 with even higher performance) +* PHP 5.3+ (PHP 5.3.7+ recommended, and PHP 5.5+ for performance, and PHP 7 for even higher performance) * Required extensions: [PDO_MySQL](http://php.net/pdo-mysql) or [PDO_SQLite](http://php.net/pdo-sqlite), [cURL](http://php.net/curl), [GMP](http://php.net/gmp) (for API access on platforms < 64 bits), [IDN](http://php.net/intl.idn) (for Internationalized Domain Names) * Recommended extensions: [iconv](http://php.net/iconv), [JSON](http://php.net/json), [mbstring](http://php.net/mbstring), [Zip](http://php.net/zip), [zlib](http://php.net/zlib) * Enabled by default: [DOM](http://php.net/dom), [XML](http://php.net/xml)… diff --git a/app/Controllers/indexController.php b/app/Controllers/indexController.php index baaf99065..7e626720e 100755 --- a/app/Controllers/indexController.php +++ b/app/Controllers/indexController.php @@ -32,42 +32,44 @@ class FreshRSS_index_Controller extends Minz_ActionController { Minz_Error::error(404); } - try { - $entries = $this->listEntriesByContext(); - - $nb_entries = count($entries); - if ($nb_entries > FreshRSS_Context::$number) { - // We have more elements for pagination - $last_entry = array_pop($entries); - FreshRSS_Context::$next_id = $last_entry->id(); - } + $this->view->callbackBeforeContent = function() { + try { + $entries = $this->listEntriesByContext(); + + $nb_entries = count($entries); + if ($nb_entries > FreshRSS_Context::$number) { + // We have more elements for pagination + $last_entry = array_pop($entries); + FreshRSS_Context::$next_id = $last_entry->id(); + } - $first_entry = $nb_entries > 0 ? $entries[0] : null; - FreshRSS_Context::$id_max = $first_entry === null ? - (time() - 1) . '000000' : - $first_entry->id(); - if (FreshRSS_Context::$order === 'ASC') { - // In this case we do not know but we guess id_max - $id_max = (time() - 1) . '000000'; - if (strcmp($id_max, FreshRSS_Context::$id_max) > 0) { - FreshRSS_Context::$id_max = $id_max; + $first_entry = $nb_entries > 0 ? $entries[0] : null; + FreshRSS_Context::$id_max = $first_entry === null ? + (time() - 1) . '000000' : + $first_entry->id(); + if (FreshRSS_Context::$order === 'ASC') { + // In this case we do not know but we guess id_max + $id_max = (time() - 1) . '000000'; + if (strcmp($id_max, FreshRSS_Context::$id_max) > 0) { + FreshRSS_Context::$id_max = $id_max; + } } - } - $this->view->entries = $entries; - } catch (FreshRSS_EntriesGetter_Exception $e) { - Minz_Log::notice($e->getMessage()); - Minz_Error::error(404); - } + $this->view->entries = $entries; + } catch (FreshRSS_EntriesGetter_Exception $e) { + Minz_Log::notice($e->getMessage()); + Minz_Error::error(404); + } - $this->view->categories = FreshRSS_Context::$categories; + $this->view->categories = FreshRSS_Context::$categories; - $this->view->rss_title = FreshRSS_Context::$name . ' | ' . Minz_View::title(); - $title = FreshRSS_Context::$name; - if (FreshRSS_Context::$get_unread > 0) { - $title = '(' . FreshRSS_Context::$get_unread . ') ' . $title; - } - Minz_View::prependTitle($title . ' · '); + $this->view->rss_title = FreshRSS_Context::$name . ' | ' . Minz_View::title(); + $title = FreshRSS_Context::$name; + if (FreshRSS_Context::$get_unread > 0) { + $title = '(' . FreshRSS_Context::$get_unread . ') ' . $title; + } + Minz_View::prependTitle($title . ' · '); + }; } /** diff --git a/app/FreshRSS.php b/app/FreshRSS.php index bafa970da..562d8e2cd 100644 --- a/app/FreshRSS.php +++ b/app/FreshRSS.php @@ -34,7 +34,7 @@ class FreshRSS extends Minz_FrontController { // Auth has to be initialized before using currentUser session parameter // because it's this part which create this parameter. - $this->initAuth(); + self::initAuth(); // Then, register the user configuration and use the configuration setter // created above. @@ -46,10 +46,7 @@ class FreshRSS extends Minz_FrontController { // Finish to initialize the other FreshRSS / Minz components. FreshRSS_Context::init(); - $this->initI18n(); - FreshRSS_Share::load(join_path(DATA_PATH, 'shares.php')); - $this->loadStylesAndScripts(); - $this->loadNotifications(); + self::initI18n(); // Enable extensions for the current (logged) user. if (FreshRSS_Auth::hasAccess()) { $ext_list = FreshRSS_Context::$user_conf->extensions_enabled; @@ -57,7 +54,7 @@ class FreshRSS extends Minz_FrontController { } } - private function initAuth() { + private static function initAuth() { FreshRSS_Auth::init(); if (Minz_Request::isPost() && !is_referer_from_same_domain()) { // Basic protection against XSRF attacks @@ -74,12 +71,12 @@ class FreshRSS extends Minz_FrontController { } } - private function initI18n() { + private static function initI18n() { Minz_Session::_param('language', FreshRSS_Context::$user_conf->language); Minz_Translate::init(FreshRSS_Context::$user_conf->language); } - private function loadStylesAndScripts() { + private static function loadStylesAndScripts() { $theme = FreshRSS_Themes::load(FreshRSS_Context::$user_conf->theme); if ($theme) { foreach($theme['files'] as $file) { @@ -91,9 +88,9 @@ class FreshRSS extends Minz_FrontController { $filename = $file; } $filetime = @filemtime(PUBLIC_PATH . '/themes/' . $theme_id . '/' . $filename); - Minz_View::appendStyle(Minz_Url::display( - '/themes/' . $theme_id . '/' . $filename . '?' . $filetime - )); + $url = '/themes/' . $theme_id . '/' . $filename . '?' . $filetime; + header('Link: <' . Minz_Url::display($url, '', 'root') . '>;rel=preload', false); //HTTP2 + Minz_View::appendStyle(Minz_Url::display($url)); } } @@ -110,6 +107,14 @@ class FreshRSS extends Minz_FrontController { } } + private static function loadNotifications() { + $notif = Minz_Session::param('notification'); + if ($notif) { + Minz_View::_param('notification', $notif); + Minz_Session::_param('notification'); + } + } + public static function preLayout() { switch (Minz_Request::controllerName()) { case 'index': @@ -123,13 +128,9 @@ class FreshRSS extends Minz_FrontController { break; } header("X-Content-Type-Options: nosniff"); - } - private function loadNotifications() { - $notif = Minz_Session::param('notification'); - if ($notif) { - Minz_View::_param('notification', $notif); - Minz_Session::_param('notification'); - } + FreshRSS_Share::load(join_path(DATA_PATH, 'shares.php')); + self::loadStylesAndScripts(); + self::loadNotifications(); } } diff --git a/app/Models/Themes.php b/app/Models/Themes.php index e3b260261..5a6ec0a05 100644 --- a/app/Models/Themes.php +++ b/app/Models/Themes.php @@ -116,7 +116,3 @@ class FreshRSS_Themes extends Minz_Model { '' . $alts[$name] . ''; } } - -function _i($icon, $url_only = false) { - return FreshRSS_Themes::icon($icon, $url_only); -} diff --git a/app/layout/layout.phtml b/app/layout/layout.phtml index 99a3717bc..6906fa05f 100644 --- a/app/layout/layout.phtml +++ b/app/layout/layout.phtml @@ -1,17 +1,32 @@ - + - + + + + + + + + + + + +callbackBeforeContent)) { + call_user_func($this->callbackBeforeContent); + } +?> + - - - rss_title)) { + } if (isset($this->rss_title)) { $url_rss = $url_base; $url_rss['a'] = 'rss'; ?> - - - - - - - - - - -allow_robots) { ?> +allow_robots) { ?> diff --git a/lib/Minz/Request.php b/lib/Minz/Request.php index 81457df9e..f80b707d6 100644 --- a/lib/Minz/Request.php +++ b/lib/Minz/Request.php @@ -137,12 +137,11 @@ class Minz_Request { /** * Return the base_url from configuration and add a suffix if given. * - * @param $base_url_suffix a string to add at base_url (default: empty string) * @return the base_url with a suffix. */ - public static function getBaseUrl($base_url_suffix = '') { + public static function getBaseUrl() { $conf = Minz_Configuration::get('system'); - $url = rtrim($conf->base_url, '/\\') . $base_url_suffix; + $url = rtrim($conf->base_url, '/\\'); return filter_var($url, FILTER_SANITIZE_URL); } diff --git a/lib/Minz/Url.php b/lib/Minz/Url.php index 382437e9a..c7c67123e 100644 --- a/lib/Minz/Url.php +++ b/lib/Minz/Url.php @@ -24,11 +24,15 @@ class Minz_Url { $url_string = ''; if ($absolute) { - $url_string = Minz_Request::getBaseUrl(PUBLIC_TO_INDEX_PATH); - if ($url_string === PUBLIC_TO_INDEX_PATH) { + $url_string = Minz_Request::getBaseUrl(); + if ($url_string == '') { $url_string = Minz_Request::guessBaseUrl(); - } else { - $url_string .= '/'; + } + if ($isArray) { + $url_string .= PUBLIC_TO_INDEX_PATH; + } + if ($absolute === 'root') { + $url_string = parse_url($url_string, PHP_URL_PATH); } } else { $url_string = $isArray ? '.' : PUBLIC_RELATIVE; diff --git a/lib/lib_rss.php b/lib/lib_rss.php index 135115ea5..f89baf9b1 100644 --- a/lib/lib_rss.php +++ b/lib/lib_rss.php @@ -548,3 +548,7 @@ function base64url_encode($data) { function base64url_decode($data) { return base64_decode(strtr($data, '-_', '+/')); } + +function _i($icon, $url_only = false) { + return FreshRSS_Themes::icon($icon, $url_only); +} -- cgit v1.2.3 From a6071a0d9824908ea48099a66435d70d74b9b1b8 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Fri, 12 Aug 2016 22:56:02 +0200 Subject: PHP 5.3 compatibility for callback https://github.com/FreshRSS/FreshRSS/issues/1208 --- app/Controllers/indexController.php | 10 +++++----- app/layout/layout.phtml | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'app/Controllers/indexController.php') diff --git a/app/Controllers/indexController.php b/app/Controllers/indexController.php index 7e626720e..2333ff69d 100755 --- a/app/Controllers/indexController.php +++ b/app/Controllers/indexController.php @@ -32,9 +32,9 @@ class FreshRSS_index_Controller extends Minz_ActionController { Minz_Error::error(404); } - $this->view->callbackBeforeContent = function() { + $this->view->callbackBeforeContent = function($view) { try { - $entries = $this->listEntriesByContext(); + $entries = FreshRSS_index_Controller::listEntriesByContext(); $nb_entries = count($entries); if ($nb_entries > FreshRSS_Context::$number) { @@ -55,7 +55,7 @@ class FreshRSS_index_Controller extends Minz_ActionController { } } - $this->view->entries = $entries; + $view->entries = $entries; } catch (FreshRSS_EntriesGetter_Exception $e) { Minz_Log::notice($e->getMessage()); Minz_Error::error(404); @@ -132,7 +132,7 @@ class FreshRSS_index_Controller extends Minz_ActionController { } try { - $this->view->entries = $this->listEntriesByContext(); + $this->view->entries = FreshRSS_index_Controller::listEntriesByContext(); } catch (FreshRSS_EntriesGetter_Exception $e) { Minz_Log::notice($e->getMessage()); Minz_Error::error(404); @@ -189,7 +189,7 @@ class FreshRSS_index_Controller extends Minz_ActionController { /** * This method returns a list of entries based on the Context object. */ - private function listEntriesByContext() { + private static function listEntriesByContext() { $entryDAO = FreshRSS_Factory::createEntryDao(); $get = FreshRSS_Context::currentGet(true); diff --git a/app/layout/layout.phtml b/app/layout/layout.phtml index 7fdc01241..2aeba40a9 100644 --- a/app/layout/layout.phtml +++ b/app/layout/layout.phtml @@ -23,7 +23,7 @@ callbackBeforeContent)) { - call_user_func($this->callbackBeforeContent); + call_user_func($this->callbackBeforeContent, $this); } ?> -- cgit v1.2.3 From af31f1b20fa7675a208c7a73933231ac2fb8928a Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sat, 13 Aug 2016 10:35:45 +0200 Subject: PHP 5.3 scope compatibility https://github.com/FreshRSS/FreshRSS/issues/1208 --- app/Controllers/indexController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/Controllers/indexController.php') diff --git a/app/Controllers/indexController.php b/app/Controllers/indexController.php index 2333ff69d..5d7925eed 100755 --- a/app/Controllers/indexController.php +++ b/app/Controllers/indexController.php @@ -189,7 +189,7 @@ class FreshRSS_index_Controller extends Minz_ActionController { /** * This method returns a list of entries based on the Context object. */ - private static function listEntriesByContext() { + public static function listEntriesByContext() { $entryDAO = FreshRSS_Factory::createEntryDao(); $get = FreshRSS_Context::currentGet(true); -- cgit v1.2.3 From 02d1d66235d9ca5dd71929c76a1ecec94cf14f3d Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sat, 13 Aug 2016 15:35:52 +0200 Subject: PHP 5.3 more compatibility https://github.com/FreshRSS/FreshRSS/pull/1209#issuecomment-239617504 https://github.com/FreshRSS/FreshRSS/issues/1208 --- app/Controllers/indexController.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'app/Controllers/indexController.php') diff --git a/app/Controllers/indexController.php b/app/Controllers/indexController.php index 5d7925eed..2332d225d 100755 --- a/app/Controllers/indexController.php +++ b/app/Controllers/indexController.php @@ -61,9 +61,9 @@ class FreshRSS_index_Controller extends Minz_ActionController { Minz_Error::error(404); } - $this->view->categories = FreshRSS_Context::$categories; + $view->categories = FreshRSS_Context::$categories; - $this->view->rss_title = FreshRSS_Context::$name . ' | ' . Minz_View::title(); + $view->rss_title = FreshRSS_Context::$name . ' | ' . Minz_View::title(); $title = FreshRSS_Context::$name; if (FreshRSS_Context::$get_unread > 0) { $title = '(' . FreshRSS_Context::$get_unread . ') ' . $title; -- cgit v1.2.3 From 2a5aa34ad2796df00fa09de41361c20764ccdfa8 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sun, 11 Sep 2016 15:06:33 +0200 Subject: Better control of number of entries per page or RSS feed https://github.com/FreshRSS/FreshRSS/issues/1249 * Since X hours: `https://freshrss.example/i/?a=rss&hours=3` * Explicit number: `https://freshrss.example/i/?a=rss&nb=10` * Limited by `min_posts_per_rss` and `max_posts_per_rss` in user config --- CHANGELOG.md | 4 ++++ app/Controllers/indexController.php | 39 +++++++++++++++++++++++++++++++------ app/Models/Context.php | 1 + app/layout/layout.phtml | 3 +++ app/layout/nav_menu.phtml | 3 +++ app/views/auth/index.phtml | 2 +- data/users/_/config.default.php | 3 +++ 7 files changed, 48 insertions(+), 7 deletions(-) (limited to 'app/Controllers/indexController.php') diff --git a/CHANGELOG.md b/CHANGELOG.md index b3c46bdb6..f82f68fff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,10 @@ ## 2016-XX-XX FreshRSS 1.6.0-dev * Features + * Better control of number of entries per page or RSS feed [#1249](https://github.com/FreshRSS/FreshRSS/issues/1249) + * Since X hours: `https://freshrss.example/i/?a=rss&hours=3` + * Explicit number: `https://freshrss.example/i/?a=rss&nb=10` + * Limited by `min_posts_per_rss` and `max_posts_per_rss` in user config * Support custom ports `localhost:3306` for database servers [#1241](https://github.com/FreshRSS/FreshRSS/issues/1241) * Security * Prevent `` attacks with `window.opener` [#1245](https://github.com/FreshRSS/FreshRSS/issues/1245) diff --git a/app/Controllers/indexController.php b/app/Controllers/indexController.php index 2332d225d..4e2717920 100755 --- a/app/Controllers/indexController.php +++ b/app/Controllers/indexController.php @@ -34,7 +34,9 @@ class FreshRSS_index_Controller extends Minz_ActionController { $this->view->callbackBeforeContent = function($view) { try { + FreshRSS_Context::$number++; //+1 for pagination $entries = FreshRSS_index_Controller::listEntriesByContext(); + FreshRSS_Context::$number--; $nb_entries = count($entries); if ($nb_entries > FreshRSS_Context::$number) { @@ -154,6 +156,7 @@ class FreshRSS_index_Controller extends Minz_ActionController { * - order (default: conf->sort_order) * - nb (default: conf->posts_per_page) * - next (default: empty string) + * - hours (default: 0) */ private function updateContext() { // Update number of read / unread variables. @@ -180,10 +183,14 @@ class FreshRSS_index_Controller extends Minz_ActionController { FreshRSS_Context::$order = Minz_Request::param( 'order', FreshRSS_Context::$user_conf->sort_order ); - FreshRSS_Context::$number = Minz_Request::param( - 'nb', FreshRSS_Context::$user_conf->posts_per_page - ); + FreshRSS_Context::$number = intval(Minz_Request::param('nb', FreshRSS_Context::$user_conf->posts_per_page)); + if (FreshRSS_Context::$number > FreshRSS_Context::$user_conf->max_posts_per_rss) { + FreshRSS_Context::$number = max( + FreshRSS_Context::$user_conf->max_posts_per_rss, + FreshRSS_Context::$user_conf->posts_per_page); + } FreshRSS_Context::$first_id = Minz_Request::param('next', ''); + FreshRSS_Context::$sinceHours = intval(Minz_Request::param('hours', 0)); } /** @@ -201,11 +208,31 @@ class FreshRSS_index_Controller extends Minz_ActionController { $id = ''; } - return $entryDAO->listWhere( + $limit = FreshRSS_Context::$number; + + $date_min = 0; + if (FreshRSS_Context::$sinceHours) { + $date_min = time() - (FreshRSS_Context::$sinceHours * 3600); + $limit = FreshRSS_Context::$user_conf->max_posts_per_rss; + } + + $entries = $entryDAO->listWhere( $type, $id, FreshRSS_Context::$state, FreshRSS_Context::$order, - FreshRSS_Context::$number + 1, FreshRSS_Context::$first_id, - FreshRSS_Context::$search + $limit, FreshRSS_Context::$first_id, + FreshRSS_Context::$search, $date_min ); + + if (FreshRSS_Context::$sinceHours && (count($entries) < FreshRSS_Context::$user_conf->min_posts_per_rss)) { + $date_min = 0; + $limit = FreshRSS_Context::$user_conf->min_posts_per_rss; + $entries = $entryDAO->listWhere( + $type, $id, FreshRSS_Context::$state, FreshRSS_Context::$order, + $limit, FreshRSS_Context::$first_id, + FreshRSS_Context::$search, $date_min + ); + } + + return $entries; } /** diff --git a/app/Models/Context.php b/app/Models/Context.php index 2a58bd4ba..33e65a619 100644 --- a/app/Models/Context.php +++ b/app/Models/Context.php @@ -35,6 +35,7 @@ class FreshRSS_Context { public static $first_id = ''; public static $next_id = ''; public static $id_max = ''; + public static $sinceHours = 0; /** * Initialize the context. diff --git a/app/layout/layout.phtml b/app/layout/layout.phtml index 4d9ad5458..1f11e0af1 100644 --- a/app/layout/layout.phtml +++ b/app/layout/layout.phtml @@ -42,6 +42,9 @@ } if (isset($this->rss_title)) { $url_rss = $url_base; $url_rss['a'] = 'rss'; + if (FreshRSS_Context::$user_conf->since_hours_posts_per_rss) { + $url_rss['params']['hours'] = FreshRSS_Context::$user_conf->since_hours_posts_per_rss; + } ?> allow_robots) { ?> diff --git a/app/layout/nav_menu.phtml b/app/layout/nav_menu.phtml index d77c1abf9..c02232242 100644 --- a/app/layout/nav_menu.phtml +++ b/app/layout/nav_menu.phtml @@ -151,6 +151,9 @@ if (FreshRSS_Context::$user_conf->token) { $url_output['params']['token'] = FreshRSS_Context::$user_conf->token; } + if (FreshRSS_Context::$user_conf->since_hours_posts_per_rss) { + $url_output['params']['hours'] = FreshRSS_Context::$user_conf->since_hours_posts_per_rss; + } ?> diff --git a/app/views/auth/index.phtml b/app/views/auth/index.phtml index 74e692ec5..7195bab5d 100644 --- a/app/views/auth/index.phtml +++ b/app/views/auth/index.phtml @@ -60,7 +60,7 @@ data-leave-validation=""/> - array('output' => 'rss', 'token' => $token)), 'html', true); ?> + array('output' => 'rss', 'token' => $token, 'hours' => FreshRSS_Context::$user_conf->since_hours_posts_per_rss)), 'html', true); ?> diff --git a/data/users/_/config.default.php b/data/users/_/config.default.php index 4a3403453..2c56d5f45 100644 --- a/data/users/_/config.default.php +++ b/data/users/_/config.default.php @@ -9,6 +9,9 @@ return array ( 'passwordHash' => '', 'apiPasswordHash' => '', 'posts_per_page' => 20, + 'since_hours_posts_per_rss' => 168, + 'min_posts_per_rss' => 2, + 'max_posts_per_rss' => 400, 'view_mode' => 'normal', 'default_view' => 'adaptive', 'default_state' => FreshRSS_Entry::STATE_NOT_READ, -- cgit v1.2.3 From 56f66f4b6168276ca449d18a440b6958c6817088 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sat, 15 Oct 2016 14:58:40 +0200 Subject: Remove superflous category request A category request was systematically done, although it is not always needed. --- app/Controllers/indexController.php | 5 +++++ app/Models/Context.php | 15 +++++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-) (limited to 'app/Controllers/indexController.php') diff --git a/app/Controllers/indexController.php b/app/Controllers/indexController.php index 4e2717920..5ca147ff3 100755 --- a/app/Controllers/indexController.php +++ b/app/Controllers/indexController.php @@ -159,6 +159,11 @@ class FreshRSS_index_Controller extends Minz_ActionController { * - hours (default: 0) */ private function updateContext() { + if (empty(FreshRSS_Context::$categories)) { + $catDAO = new FreshRSS_CategoryDAO(); + FreshRSS_Context::$categories = $catDAO->listCategories(); + } + // Update number of read / unread variables. $entryDAO = FreshRSS_Factory::createEntryDao(); FreshRSS_Context::$total_starred = $entryDAO->countUnreadReadFavorites(); diff --git a/app/Models/Context.php b/app/Models/Context.php index 889ddab1e..fe4fa6281 100644 --- a/app/Models/Context.php +++ b/app/Models/Context.php @@ -48,9 +48,6 @@ class FreshRSS_Context { // Init configuration. self::$system_conf = Minz_Configuration::get('system'); self::$user_conf = Minz_Configuration::get('user'); - - $catDAO = new FreshRSS_CategoryDAO(); - self::$categories = $catDAO->listCategories(); } /** @@ -142,6 +139,11 @@ class FreshRSS_Context { $id = substr($get, 2); $nb_unread = 0; + if (empty(self::$categories)) { + $catDAO = new FreshRSS_CategoryDAO(); + self::$categories = $catDAO->listCategories(); + } + switch($type) { case 'a': self::$current_get['all'] = true; @@ -203,11 +205,16 @@ class FreshRSS_Context { /** * Set the value of $next_get attribute. */ - public static function _nextGet() { + private static function _nextGet() { $get = self::currentGet(); // By default, $next_get == $get self::$next_get = $get; + if (empty(self::$categories)) { + $catDAO = new FreshRSS_CategoryDAO(); + self::$categories = $catDAO->listCategories(); + } + if (self::$user_conf->onread_jump_next && strlen($get) > 2) { $another_unread_id = ''; $found_current_get = false; -- cgit v1.2.3 From 4e174ed9dd84ce4f8de410baf6a6e0fde9160055 Mon Sep 17 00:00:00 2001 From: Frans de Jonge Date: Fri, 22 Sep 2017 12:13:46 +0200 Subject: [ci] Add Travis (#1619) * [ci] Add Travis * Exclude some libs * Semi-auto whitespace fixes * line length in SQLite * Exclude tests from line length * Feed.php line length * Feed.php: get rid of unnecessary concat * Feed.php: line length * bootstrap.php: no newline at end of file * Allow concatenating across multiple lines * Add Travis badge * do-install line length * update-or-create-user line length * cli/create-user line length * tests/app/Models/SearchTest.php fix indentation * tests/app/Models/UserQueryTest.php fix indentation * tests/app/Models/CategoryTest.php fix indentation * [fix] PHP 5.3 on precise * cli/do-install no spaces * cli/list-users line length * cli/reconfigure line length * empty catch statements * api/index line length nonsense * spaces before semicolon * app/Models/EntryDAO bunch of indentation * extra blank lines * spaces before comma in function call * testing tabwidth * increase to 10 * comment out tabwidth line * try older phpcs version 3.0.0RC4 * line length exception for app/install.php * proper spaces * stray spaces in i18n * Minz/ModelPdo line length * Minz whitespace * greader line length * greader elseif placement * app/Models/Feed.php spacing in function argument * ignore php 5.3 * app/Models/ConfigurationSetter.php stray whitespace * EntryDAOSQLite line length * I vote for higher max line length =P * ignore SQL * remove classname complaint * line length/more legible SQL * ignore line length nonsense * greader line length * feedController issues * uppercase TRUE, FALSE, NULL * revert * importExportController lowercase null * Share.php default value not necessary because ! is_array () a few lines down * CategoryDAO constants should be UPPERCASE * EntryDAO reduce line length * contentious autofix * Allow failures on all versions of PHP except 7.1 because reasons --- .travis.yml | 34 ++++ README.md | 5 + app/Controllers/categoryController.php | 4 +- app/Controllers/feedController.php | 10 +- app/Controllers/importExportController.php | 10 +- app/Controllers/indexController.php | 4 +- app/Exceptions/ZipException.php | 2 +- app/Models/CategoryDAO.php | 10 +- app/Models/ConfigurationSetter.php | 10 +- app/Models/Context.php | 8 +- app/Models/DatabaseDAO.php | 2 +- app/Models/DatabaseDAOPGSQL.php | 2 +- app/Models/DatabaseDAOSQLite.php | 2 +- app/Models/Entry.php | 1 + app/Models/EntryDAO.php | 100 +++++----- app/Models/EntryDAOPGSQL.php | 2 +- app/Models/EntryDAOSQLite.php | 57 +++++- app/Models/Feed.php | 26 ++- app/Models/FeedDAO.php | 20 +- app/Models/Share.php | 2 +- app/Models/Themes.php | 8 +- app/Models/UserDAO.php | 6 +- app/SQL/install.sql.sqlite.php | 38 +++- app/i18n/cz/conf.php | 2 +- app/i18n/cz/gen.php | 2 +- app/i18n/de/conf.php | 2 +- app/i18n/en/conf.php | 2 +- app/i18n/it/conf.php | 2 +- app/i18n/kr/conf.php | 2 +- app/i18n/nl/conf.php | 2 +- app/i18n/ru/conf.php | 2 +- app/i18n/tr/conf.php | 2 +- app/i18n/zh-cn/conf.php | 2 +- app/install.php | 4 +- cli/_update-or-create-user.php | 3 +- cli/create-user.php | 3 +- cli/do-install.php | 9 +- cli/list-users.php | 3 +- cli/reconfigure.php | 3 +- data/shares.php | 2 +- lib/Minz/ActionController.php | 6 +- lib/Minz/ActionException.php | 2 +- lib/Minz/Configuration.php | 4 +- .../ControllerNotActionControllerException.php | 2 +- lib/Minz/ControllerNotExistException.php | 2 +- lib/Minz/CurrentPagePaginationException.php | 2 +- lib/Minz/Dispatcher.php | 2 +- lib/Minz/FileNotExistException.php | 2 +- lib/Minz/FrontController.php | 4 +- lib/Minz/Helper.php | 4 +- lib/Minz/Model.php | 2 +- lib/Minz/ModelArray.php | 3 +- lib/Minz/ModelPdo.php | 2 +- lib/Minz/PDOConnectionException.php | 2 +- lib/Minz/Paginator.php | 8 +- lib/Minz/Translate.php | 4 +- lib/Minz/View.php | 2 - lib/favicons.php | 1 + lib/lib_date.php | 3 +- lib/lib_install.php | 3 +- lib/lib_rss.php | 2 + p/api/greader.php | 52 +++-- p/api/index.php | 3 +- phpcs.xml | 100 ++++++++++ tests/app/Models/CategoryTest.php | 12 +- tests/app/Models/SearchTest.php | 216 ++++++++++----------- tests/app/Models/UserQueryTest.php | 62 +++--- tests/bootstrap.php | 2 +- 68 files changed, 593 insertions(+), 326 deletions(-) create mode 100644 .travis.yml create mode 100644 phpcs.xml (limited to 'app/Controllers/indexController.php') diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 000000000..5c43e5666 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,34 @@ +language: php +php: + - '5.4' + - '5.5' + - '5.6' + - '7.0' + - '7.1' + - hhvm + - nightly + +install: + # newest version without https://github.com/squizlabs/PHP_CodeSniffer/pull/1404 + - pear install PHP_CodeSniffer-3.0.0RC4 + +script: + - phpenv rehash + - phpcs . --standard=phpcs.xml --warning-severity=0 --extensions=php -p + +env: # important! otherwise no job will be allowed to fail +matrix: + # PHP 5.3 only runs on Ubuntu 12.04 (precise), not 14.04 (trusty) + include: + - php: "5.3" + dist: precise + fast_finish: true + allow_failures: + - php: "5.3" + dist: precise + - php: "5.4" + - php: "5.5" + - php: "5.6" + - php: "7.0" + - php: hhvm + - php: nightly diff --git a/README.md b/README.md index 8595a26ec..016794ffc 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +[![Build Status][travis-badge]][travis-link] + * [Version française](README.fr.md) # FreshRSS @@ -182,3 +184,6 @@ Any client supporting a Google Reader-like API. Selection: * [EasyRSS](https://github.com/Alkarex/EasyRSS) (Open source, F-Droid) * Linux * [FeedReader 2.0+](https://jangernert.github.io/FeedReader/) (Open source) + +[travis-badge]:https://travis-ci.org/FreshRSS/FreshRSS.svg?branch=master +[travis-link]:https://travis-ci.org/FreshRSS/FreshRSS diff --git a/app/Controllers/categoryController.php b/app/Controllers/categoryController.php index 922f92844..f3b35a323 100644 --- a/app/Controllers/categoryController.php +++ b/app/Controllers/categoryController.php @@ -127,11 +127,11 @@ class FreshRSS_category_Controller extends Minz_ActionController { Minz_Request::bad(_t('feedback.sub.category.no_id'), $url_redirect); } - if ($id === FreshRSS_CategoryDAO::defaultCategoryId) { + if ($id === FreshRSS_CategoryDAO::DEFAULTCATEGORYID) { Minz_Request::bad(_t('feedback.sub.category.not_delete_default'), $url_redirect); } - if ($feedDAO->changeCategory($id, FreshRSS_CategoryDAO::defaultCategoryId) === false) { + if ($feedDAO->changeCategory($id, FreshRSS_CategoryDAO::DEFAULTCATEGORYID) === false) { Minz_Request::bad(_t('feedback.sub.category.error'), $url_redirect); } diff --git a/app/Controllers/feedController.php b/app/Controllers/feedController.php index c9b6deaa7..66b1167a8 100755 --- a/app/Controllers/feedController.php +++ b/app/Controllers/feedController.php @@ -42,7 +42,7 @@ class FreshRSS_feed_Controller extends Minz_ActionController { if ($cat == null) { $catDAO->checkDefault(); } - $cat_id = $cat == null ? FreshRSS_CategoryDAO::defaultCategoryId : $cat->id(); + $cat_id = $cat == null ? FreshRSS_CategoryDAO::DEFAULTCATEGORYID : $cat->id(); $feed = new FreshRSS_Feed($url); //Throws FreshRSS_BadUrl_Exception $feed->_httpAuth($http_auth); @@ -420,8 +420,7 @@ class FreshRSS_feed_Controller extends Minz_ActionController { $feedDAO->updateFeed($feed->id(), array('url' => $feed->url())); } } - } - elseif ($feed->url() !== $url) { // HTTP 301 Moved Permanently + } elseif ($feed->url() !== $url) { // HTTP 301 Moved Permanently Minz_Log::notice('Feed ' . $url . ' moved permanently to ' . $feed->url()); $feedDAO->updateFeed($feed->id(), array('url' => $feed->url())); } @@ -537,7 +536,7 @@ class FreshRSS_feed_Controller extends Minz_ActionController { } if ($cat_id <= 1) { $catDAO->checkDefault(); - $cat_id = FreshRSS_CategoryDAO::defaultCategoryId; + $cat_id = FreshRSS_CategoryDAO::DEFAULTCATEGORYID; } $feedDAO = FreshRSS_Factory::createFeedDao(); @@ -566,6 +565,9 @@ class FreshRSS_feed_Controller extends Minz_ActionController { if (self::moveFeed($feed_id, $cat_id)) { // TODO: return something useful + // Log a notice to prevent "Empty IF statement" warning in PHP_CodeSniffer + Minz_Log::notice('Moved feed `' . $feed_id . '` ' . + 'in the category `' . $cat_id . '`');; } else { Minz_Log::warning('Cannot move feed `' . $feed_id . '` ' . 'in the category `' . $cat_id . '`'); diff --git a/app/Controllers/importExportController.php b/app/Controllers/importExportController.php index 2bc68848c..a69490e70 100644 --- a/app/Controllers/importExportController.php +++ b/app/Controllers/importExportController.php @@ -152,8 +152,7 @@ class FreshRSS_importExport_Controller extends Minz_ActionController { // And finally, we get import status and redirect to the home page Minz_Session::_param('actualize_feeds', true); - $content_notif = $error === true ? _t('feedback.import_export.feeds_imported_with_errors') : - _t('feedback.import_export.feeds_imported'); + $content_notif = $error === true ? _t('feedback.import_export.feeds_imported_with_errors') : _t('feedback.import_export.feeds_imported'); Minz_Request::good($content_notif); } @@ -439,8 +438,7 @@ class FreshRSS_importExport_Controller extends Minz_ActionController { $feed_id = $article_to_feed[$item['id']]; $author = isset($item['author']) ? $item['author'] : ''; - $key_content = ($google_compliant && !isset($item['content'])) ? - 'summary' : 'content'; + $key_content = ($google_compliant && !isset($item['content'])) ? 'summary' : 'content'; $tags = $item['categories']; if ($google_compliant) { // Remove tags containing "/state/com.google" which are useless. @@ -501,7 +499,7 @@ class FreshRSS_importExport_Controller extends Minz_ActionController { try { // Create a Feed object and add it in database. $feed = new FreshRSS_Feed($url); - $feed->_category(FreshRSS_CategoryDAO::defaultCategoryId); + $feed->_category(FreshRSS_CategoryDAO::DEFAULTCATEGORYID); $feed->_name($name); $feed->_website($website); @@ -640,7 +638,7 @@ class FreshRSS_importExport_Controller extends Minz_ActionController { * @param FreshRSS_Feed $feed feed of which we want to get entries. * @return string the JSON file content. */ - private function generateEntries($type, $feed = NULL, $maxFeedEntries = 50) { + private function generateEntries($type, $feed = null, $maxFeedEntries = 50) { $this->view->categories = $this->catDAO->listCategories(); if ($type == 'starred') { diff --git a/app/Controllers/indexController.php b/app/Controllers/indexController.php index 5ca147ff3..e8dde36fa 100755 --- a/app/Controllers/indexController.php +++ b/app/Controllers/indexController.php @@ -46,9 +46,7 @@ class FreshRSS_index_Controller extends Minz_ActionController { } $first_entry = $nb_entries > 0 ? $entries[0] : null; - FreshRSS_Context::$id_max = $first_entry === null ? - (time() - 1) . '000000' : - $first_entry->id(); + FreshRSS_Context::$id_max = $first_entry === null ? (time() - 1) . '000000' : $first_entry->id(); if (FreshRSS_Context::$order === 'ASC') { // In this case we do not know but we guess id_max $id_max = (time() - 1) . '000000'; diff --git a/app/Exceptions/ZipException.php b/app/Exceptions/ZipException.php index 8441daedf..ad01b87ea 100644 --- a/app/Exceptions/ZipException.php +++ b/app/Exceptions/ZipException.php @@ -2,7 +2,7 @@ class FreshRSS_Zip_Exception extends Exception { private $zipErrorCode = 0; - + public function __construct($zipErrorCode) { parent::__construct('ZIP error! ' . $url, 2141); $this->zipErrorCode = $zipErrorCode; diff --git a/app/Models/CategoryDAO.php b/app/Models/CategoryDAO.php index c2d57c241..f219c275f 100644 --- a/app/Models/CategoryDAO.php +++ b/app/Models/CategoryDAO.php @@ -2,7 +2,7 @@ class FreshRSS_CategoryDAO extends Minz_ModelPdo implements FreshRSS_Searchable { - const defaultCategoryId = 1; + const DEFAULTCATEGORYID = 1; public function addCategory($valuesTmp) { $sql = 'INSERT INTO `' . $this->prefix . 'category`(name) VALUES(?)'; @@ -53,7 +53,7 @@ class FreshRSS_CategoryDAO extends Minz_ModelPdo implements FreshRSS_Searchable } public function deleteCategory($id) { - if ($id <= self::defaultCategoryId) { + if ($id <= self::DEFAULTCATEGORYID) { return false; } $sql = 'DELETE FROM `' . $this->prefix . 'category` WHERE id=?'; @@ -123,7 +123,7 @@ class FreshRSS_CategoryDAO extends Minz_ModelPdo implements FreshRSS_Searchable } public function getDefault() { - $sql = 'SELECT * FROM `' . $this->prefix . 'category` WHERE id=' . self::defaultCategoryId; + $sql = 'SELECT * FROM `' . $this->prefix . 'category` WHERE id=' . self::DEFAULTCATEGORYID; $stm = $this->bd->prepare($sql); $stm->execute(); @@ -137,11 +137,11 @@ class FreshRSS_CategoryDAO extends Minz_ModelPdo implements FreshRSS_Searchable } } public function checkDefault() { - $def_cat = $this->searchById(self::defaultCategoryId); + $def_cat = $this->searchById(self::DEFAULTCATEGORYID); if ($def_cat == null) { $cat = new FreshRSS_Category(_t('gen.short.default_category')); - $cat->_id(self::defaultCategoryId); + $cat->_id(self::DEFAULTCATEGORYID); $values = array( 'id' => $cat->id(), diff --git a/app/Models/ConfigurationSetter.php b/app/Models/ConfigurationSetter.php index 70e1dea2e..ca4709903 100644 --- a/app/Models/ConfigurationSetter.php +++ b/app/Models/ConfigurationSetter.php @@ -56,8 +56,7 @@ class FreshRSS_ConfigurationSetter { switch ($value) { case 'all': $data['default_view'] = $value; - $data['default_state'] = (FreshRSS_Entry::STATE_READ + - FreshRSS_Entry::STATE_NOT_READ); + $data['default_state'] = (FreshRSS_Entry::STATE_READ + FreshRSS_Entry::STATE_NOT_READ); break; case 'adaptive': case 'unread': @@ -163,7 +162,7 @@ class FreshRSS_ConfigurationSetter { if (!in_array($value, array('global', 'normal', 'reader'))) { $value = 'normal'; } - $data['view_mode'] = $value; + $data['view_mode'] = $value; } /** @@ -326,7 +325,7 @@ class FreshRSS_ConfigurationSetter { if (!in_array($value, array('silent', 'development', 'production'))) { $value = 'production'; } - $data['environment'] = $value; + $data['environment'] = $value; } private function _limits(&$data, $values) { @@ -361,8 +360,7 @@ class FreshRSS_ConfigurationSetter { $value = intval($value); $limits = $limits_keys[$key]; - if ( - (!isset($limits['min']) || $value >= $limits['min']) && + if ((!isset($limits['min']) || $value >= $limits['min']) && (!isset($limits['max']) || $value <= $limits['max']) ) { $data['limits'][$key] = $value; diff --git a/app/Models/Context.php b/app/Models/Context.php index fd0e79fc1..2ca8f80b0 100644 --- a/app/Models/Context.php +++ b/app/Models/Context.php @@ -250,9 +250,7 @@ class FreshRSS_Context { } // If no feed have been found, next_get is the current category. - self::$next_get = empty($another_unread_id) ? - 'c_' . self::$current_get['category'] : - 'f_' . $another_unread_id; + self::$next_get = empty($another_unread_id) ? 'c_' . self::$current_get['category'] : 'f_' . $another_unread_id; break; case 'c': // We search the next category with at least one unread article. @@ -275,9 +273,7 @@ class FreshRSS_Context { } // No unread category? The main stream will be our destination! - self::$next_get = empty($another_unread_id) ? - 'a' : - 'c_' . $another_unread_id; + self::$next_get = empty($another_unread_id) ? 'a' : 'c_' . $another_unread_id; break; } } diff --git a/app/Models/DatabaseDAO.php b/app/Models/DatabaseDAO.php index 0d85718e3..6ba5bca3e 100644 --- a/app/Models/DatabaseDAO.php +++ b/app/Models/DatabaseDAO.php @@ -9,7 +9,7 @@ class FreshRSS_DatabaseDAO extends Minz_ModelPdo { $stm = $this->bd->prepare($sql); $stm->execute(); $res = $stm->fetchAll(PDO::FETCH_ASSOC); - + $tables = array( $this->prefix . 'category' => false, $this->prefix . 'feed' => false, diff --git a/app/Models/DatabaseDAOPGSQL.php b/app/Models/DatabaseDAOPGSQL.php index a4edaa448..2a18db970 100644 --- a/app/Models/DatabaseDAOPGSQL.php +++ b/app/Models/DatabaseDAOPGSQL.php @@ -12,7 +12,7 @@ class FreshRSS_DatabaseDAOPGSQL extends FreshRSS_DatabaseDAO { $values = array($dbowner); $stm->execute($values); $res = $stm->fetchAll(PDO::FETCH_ASSOC); - + $tables = array( $this->prefix . 'category' => false, $this->prefix . 'feed' => false, diff --git a/app/Models/DatabaseDAOSQLite.php b/app/Models/DatabaseDAOSQLite.php index 7f53f967d..2e1df132e 100644 --- a/app/Models/DatabaseDAOSQLite.php +++ b/app/Models/DatabaseDAOSQLite.php @@ -9,7 +9,7 @@ class FreshRSS_DatabaseDAOSQLite extends FreshRSS_DatabaseDAO { $stm = $this->bd->prepare($sql); $stm->execute(); $res = $stm->fetchAll(PDO::FETCH_ASSOC); - + $tables = array( 'category' => false, 'feed' => false, diff --git a/app/Models/Entry.php b/app/Models/Entry.php index 26cd24797..df3d59bea 100644 --- a/app/Models/Entry.php +++ b/app/Models/Entry.php @@ -189,6 +189,7 @@ class FreshRSS_Entry extends Minz_Model { ); } catch (Exception $e) { // rien à faire, on garde l'ancien contenu(requête a échoué) + Minz_Log::warning($e->getMessage()); } } } diff --git a/app/Models/EntryDAO.php b/app/Models/EntryDAO.php index 7e836097a..bebafe500 100644 --- a/app/Models/EntryDAO.php +++ b/app/Models/EntryDAO.php @@ -146,13 +146,13 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo implements FreshRSS_Searchable { public function addEntry($valuesTmp) { if ($this->addEntryPrepared == null) { $sql = 'INSERT INTO `' . $this->prefix . 'entrytmp` (id, guid, title, author, ' - . ($this->isCompressed() ? 'content_bin' : 'content') - . ', link, date, `lastSeen`, hash, is_read, is_favorite, id_feed, tags) ' - . 'VALUES(:id, :guid, :title, :author, ' - . ($this->isCompressed() ? 'COMPRESS(:content)' : ':content') - . ', :link, :date, :last_seen, ' - . $this->sqlHexDecode(':hash') - . ', :is_read, :is_favorite, :id_feed, :tags)'; + . ($this->isCompressed() ? 'content_bin' : 'content') + . ', link, date, `lastSeen`, hash, is_read, is_favorite, id_feed, tags) ' + . 'VALUES(:id, :guid, :title, :author, ' + . ($this->isCompressed() ? 'COMPRESS(:content)' : ':content') + . ', :link, :date, :last_seen, ' + . $this->sqlHexDecode(':hash') + . ', :is_read, :is_favorite, :id_feed, :tags)'; $this->addEntryPrepared = $this->bd->prepare($sql); } if ($this->addEntryPrepared) { @@ -203,8 +203,13 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo implements FreshRSS_Searchable { public function commitNewEntries() { $sql = 'SET @rank=(SELECT MAX(id) - COUNT(*) FROM `' . $this->prefix . 'entrytmp`); ' . //MySQL-specific - 'INSERT IGNORE INTO `' . $this->prefix . 'entry` (id, guid, title, author, content_bin, link, date, `lastSeen`, hash, is_read, is_favorite, id_feed, tags) ' . - 'SELECT @rank:=@rank+1 AS id, guid, title, author, content_bin, link, date, `lastSeen`, hash, is_read, is_favorite, id_feed, tags FROM `' . $this->prefix . 'entrytmp` ORDER BY date; ' . + 'INSERT IGNORE INTO `' . $this->prefix . 'entry` + ( + id, guid, title, author, content_bin, link, date, `lastSeen`, hash, is_read, is_favorite, id_feed, tags + ) ' . + 'SELECT @rank:=@rank+1 AS id, guid, title, author, content_bin, link, date, `lastSeen`, hash, is_read, is_favorite, id_feed, tags + FROM `' . $this->prefix . 'entrytmp` + ORDER BY date; ' . 'DELETE FROM `' . $this->prefix . 'entrytmp` WHERE id <= @rank;'; $hadTransaction = $this->bd->inTransaction(); if (!$hadTransaction) { @@ -226,13 +231,13 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo implements FreshRSS_Searchable { if ($this->updateEntryPrepared === null) { $sql = 'UPDATE `' . $this->prefix . 'entry` ' - . 'SET title=:title, author=:author, ' - . ($this->isCompressed() ? 'content_bin=COMPRESS(:content)' : 'content=:content') - . ', link=:link, date=:date, `lastSeen`=:last_seen, ' - . 'hash=' . $this->sqlHexDecode(':hash') - . ', ' . ($valuesTmp['is_read'] === null ? '' : 'is_read=:is_read, ') - . 'tags=:tags ' - . 'WHERE id_feed=:id_feed AND guid=:guid'; + . 'SET title=:title, author=:author, ' + . ($this->isCompressed() ? 'content_bin=COMPRESS(:content)' : 'content=:content') + . ', link=:link, date=:date, `lastSeen`=:last_seen, ' + . 'hash=' . $this->sqlHexDecode(':hash') + . ', ' . ($valuesTmp['is_read'] === null ? '' : 'is_read=:is_read, ') + . 'tags=:tags ' + . 'WHERE id_feed=:id_feed AND guid=:guid'; $this->updateEntryPrepared = $this->bd->prepare($sql); } @@ -295,8 +300,8 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo implements FreshRSS_Searchable { } FreshRSS_UserDAO::touch(); $sql = 'UPDATE `' . $this->prefix . 'entry` ' - . 'SET is_favorite=? ' - . 'WHERE id IN (' . str_repeat('?,', count($ids) - 1). '?)'; + . 'SET is_favorite=? ' + . 'WHERE id IN (' . str_repeat('?,', count($ids) - 1). '?)'; $values = array($is_favorite ? 1 : 0); $values = array_merge($values, $ids); $stm = $this->bd->prepare($sql); @@ -322,14 +327,14 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo implements FreshRSS_Searchable { */ protected function updateCacheUnreads($catId = false, $feedId = false) { $sql = 'UPDATE `' . $this->prefix . 'feed` f ' - . 'LEFT OUTER JOIN (' - . 'SELECT e.id_feed, ' - . 'COUNT(*) AS nbUnreads ' - . 'FROM `' . $this->prefix . 'entry` e ' - . 'WHERE e.is_read=0 ' - . 'GROUP BY e.id_feed' - . ') x ON x.id_feed=f.id ' - . 'SET f.`cache_nbUnreads`=COALESCE(x.nbUnreads, 0)'; + . 'LEFT OUTER JOIN (' + . 'SELECT e.id_feed, ' + . 'COUNT(*) AS nbUnreads ' + . 'FROM `' . $this->prefix . 'entry` e ' + . 'WHERE e.is_read=0 ' + . 'GROUP BY e.id_feed' + . ') x ON x.id_feed=f.id ' + . 'SET f.`cache_nbUnreads`=COALESCE(x.nbUnreads, 0)'; $hasWhere = false; $values = array(); if ($feedId !== false) { @@ -558,9 +563,9 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo implements FreshRSS_Searchable { public function searchByGuid($id_feed, $guid) { // un guid est unique pour un flux donné $sql = 'SELECT id, guid, title, author, ' - . ($this->isCompressed() ? 'UNCOMPRESS(content_bin) AS content' : 'content') - . ', link, date, is_read, is_favorite, id_feed, tags ' - . 'FROM `' . $this->prefix . 'entry` WHERE id_feed=? AND guid=?'; + . ($this->isCompressed() ? 'UNCOMPRESS(content_bin) AS content' : 'content') + . ', link, date, is_read, is_favorite, id_feed, tags ' + . 'FROM `' . $this->prefix . 'entry` WHERE id_feed=? AND guid=?'; $stm = $this->bd->prepare($sql); $values = array( @@ -576,9 +581,9 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo implements FreshRSS_Searchable { public function searchById($id) { $sql = 'SELECT id, guid, title, author, ' - . ($this->isCompressed() ? 'UNCOMPRESS(content_bin) AS content' : 'content') - . ', link, date, is_read, is_favorite, id_feed, tags ' - . 'FROM `' . $this->prefix . 'entry` WHERE id=?'; + . ($this->isCompressed() ? 'UNCOMPRESS(content_bin) AS content' : 'content') + . ', link, date, is_read, is_favorite, id_feed, tags ' + . 'FROM `' . $this->prefix . 'entry` WHERE id=?'; $stm = $this->bd->prepare($sql); $values = array($id); @@ -600,16 +605,14 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo implements FreshRSS_Searchable { if (!($state & FreshRSS_Entry::STATE_READ)) { $search .= 'AND ' . $alias . 'is_read=0 '; } - } - elseif ($state & FreshRSS_Entry::STATE_READ) { + } elseif ($state & FreshRSS_Entry::STATE_READ) { $search .= 'AND ' . $alias . 'is_read=1 '; } if ($state & FreshRSS_Entry::STATE_FAVORITE) { if (!($state & FreshRSS_Entry::STATE_NOT_FAVORITE)) { $search .= 'AND ' . $alias . 'is_favorite=1 '; } - } - elseif ($state & FreshRSS_Entry::STATE_NOT_FAVORITE) { + } elseif ($state & FreshRSS_Entry::STATE_NOT_FAVORITE) { $search .= 'AND ' . $alias . 'is_favorite=0 '; } @@ -621,7 +624,8 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo implements FreshRSS_Searchable { throw new FreshRSS_EntriesGetter_Exception('Bad order in Entry->listByType: [' . $order . ']!'); } /*if ($firstId === '' && parent::$sharedDbType === 'mysql') { - $firstId = $order === 'DESC' ? '9000000000'. '000000' : '0'; //MySQL optimization. TODO: check if this is needed again, after the filtering for old articles has been removed in 0.9-dev + //MySQL optimization. TODO: check if this is needed again, after the filtering for old articles has been removed in 0.9-dev + $firstId = $order === 'DESC' ? '9000000000'. '000000' : '0'; }*/ if ($firstId !== '') { $search .= 'AND ' . $alias . 'id ' . ($order === 'DESC' ? '<=' : '>=') . $firstId . ' '; @@ -759,13 +763,13 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo implements FreshRSS_Searchable { list($values, $sql) = $this->sqlListWhere($type, $id, $state, $order, $limit, $firstId, $filter, $date_min); $sql = 'SELECT e0.id, e0.guid, e0.title, e0.author, ' - . ($this->isCompressed() ? 'UNCOMPRESS(content_bin) AS content' : 'content') - . ', e0.link, e0.date, e0.is_read, e0.is_favorite, e0.id_feed, e0.tags ' - . 'FROM `' . $this->prefix . 'entry` e0 ' - . 'INNER JOIN (' - . $sql - . ') e2 ON e2.id=e0.id ' - . 'ORDER BY e0.id ' . $order; + . ($this->isCompressed() ? 'UNCOMPRESS(content_bin) AS content' : 'content') + . ', e0.link, e0.date, e0.is_read, e0.is_favorite, e0.id_feed, e0.tags ' + . 'FROM `' . $this->prefix . 'entry` e0 ' + . 'INNER JOIN (' + . $sql + . ') e2 ON e2.id=e0.id ' + . 'ORDER BY e0.id ' . $order; $stm = $this->bd->prepare($sql); $stm->execute($values); @@ -839,7 +843,7 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo implements FreshRSS_Searchable { public function countUnreadRead() { $sql = 'SELECT COUNT(e.id) AS count FROM `' . $this->prefix . 'entry` e INNER JOIN `' . $this->prefix . 'feed` f ON e.id_feed=f.id WHERE priority > 0' - . ' UNION SELECT COUNT(e.id) AS count FROM `' . $this->prefix . 'entry` e INNER JOIN `' . $this->prefix . 'feed` f ON e.id_feed=f.id WHERE priority > 0 AND is_read=0'; + . ' UNION SELECT COUNT(e.id) AS count FROM `' . $this->prefix . 'entry` e INNER JOIN `' . $this->prefix . 'feed` f ON e.id_feed=f.id WHERE priority > 0 AND is_read=0'; $stm = $this->bd->prepare($sql); $stm->execute(); $res = $stm->fetchAll(PDO::FETCH_COLUMN, 0); @@ -870,9 +874,9 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo implements FreshRSS_Searchable { public function countUnreadReadFavorites() { $sql = 'SELECT c FROM (' - . 'SELECT COUNT(id) AS c, 1 as o FROM `' . $this->prefix . 'entry` WHERE is_favorite=1 ' - . 'UNION SELECT COUNT(id) AS c, 2 AS o FROM `' . $this->prefix . 'entry` WHERE is_favorite=1 AND is_read=0' - . ') u ORDER BY o'; + . 'SELECT COUNT(id) AS c, 1 as o FROM `' . $this->prefix . 'entry` WHERE is_favorite=1 ' + . 'UNION SELECT COUNT(id) AS c, 2 AS o FROM `' . $this->prefix . 'entry` WHERE is_favorite=1 AND is_read=0' + . ') u ORDER BY o'; $stm = $this->bd->prepare($sql); $stm->execute(); $res = $stm->fetchAll(PDO::FETCH_COLUMN, 0); diff --git a/app/Models/EntryDAOPGSQL.php b/app/Models/EntryDAOPGSQL.php index 6e6f9e658..405774abf 100644 --- a/app/Models/EntryDAOPGSQL.php +++ b/app/Models/EntryDAOPGSQL.php @@ -11,7 +11,7 @@ class FreshRSS_EntryDAOPGSQL extends FreshRSS_EntryDAOSQLite { } protected function autoUpdateDb($errorInfo) { - if (isset($errorInfo[0])) { + if (isset($errorInfo[0])) { if ($errorInfo[0] === '42P01' && stripos($errorInfo[2], 'entrytmp') !== false) { //undefined_table return $this->createEntryTempTable(); } diff --git a/app/Models/EntryDAOSQLite.php b/app/Models/EntryDAOSQLite.php index ad7bcd865..8dad54322 100644 --- a/app/Models/EntryDAOSQLite.php +++ b/app/Models/EntryDAOSQLite.php @@ -27,11 +27,58 @@ class FreshRSS_EntryDAOSQLite extends FreshRSS_EntryDAO { public function commitNewEntries() { $sql = ' -CREATE TEMP TABLE `tmp` AS SELECT id, guid, title, author, content, link, date, `lastSeen`, hash, is_read, is_favorite, id_feed, tags FROM `' . $this->prefix . 'entrytmp` ORDER BY date; -INSERT OR IGNORE INTO `' . $this->prefix . 'entry` (id, guid, title, author, content, link, date, `lastSeen`, hash, is_read, is_favorite, id_feed, tags) - SELECT rowid + (SELECT MAX(id) - COUNT(*) FROM `tmp`) AS id, guid, title, author, content, link, date, `lastSeen`, hash, is_read, is_favorite, id_feed, tags FROM `tmp` ORDER BY date; -DELETE FROM `' . $this->prefix . 'entrytmp` WHERE id <= (SELECT MAX(id) FROM `tmp`); -DROP TABLE `tmp`;'; + CREATE TEMP TABLE `tmp` AS + SELECT + id, + guid, + title, + author, + content, + link, + date, + `lastSeen`, + hash, is_read, + is_favorite, + id_feed, + tags + FROM `' . $this->prefix . 'entrytmp` + ORDER BY date; + INSERT OR IGNORE INTO `' . $this->prefix . 'entry` + ( + id, + guid, + title, + author, + content, + link, + date, + `lastSeen`, + hash, + is_read, + is_favorite, + id_feed, + tags + ) + SELECT rowid + (SELECT MAX(id) - COUNT(*) FROM `tmp`) AS + id, + guid, + title, + author, + content, + link, + date, + `lastSeen`, + hash, + is_read, + is_favorite, + id_feed, + tags + FROM `tmp` + ORDER BY date; + DELETE FROM `' . $this->prefix . 'entrytmp` + WHERE id <= (SELECT MAX(id) + FROM `tmp`); + DROP TABLE `tmp`;'; $hadTransaction = $this->bd->inTransaction(); if (!$hadTransaction) { $this->bd->beginTransaction(); diff --git a/app/Models/Feed.php b/app/Models/Feed.php index 4f11d32e9..88ff9bf18 100644 --- a/app/Models/Feed.php +++ b/app/Models/Feed.php @@ -22,7 +22,7 @@ class FreshRSS_Feed extends Minz_Model { private $hubUrl = ''; private $selfUrl = ''; - public function __construct($url, $validate=true) { + public function __construct($url, $validate = true) { if ($validate) { $this->_url($url); } else { @@ -165,7 +165,7 @@ class FreshRSS_Feed extends Minz_Model { public function _id($value) { $this->id = $value; } - public function _url($value, $validate=true) { + public function _url($value, $validate = true) { $this->hash = null; if ($validate) { $value = checkUrl($value); @@ -182,7 +182,7 @@ class FreshRSS_Feed extends Minz_Model { public function _name($value) { $this->name = $value === null ? '' : $value; } - public function _website($value, $validate=true) { + public function _website($value, $validate = true) { if ($validate) { $value = checkUrl($value); } @@ -254,7 +254,9 @@ class FreshRSS_Feed extends Minz_Model { if ((!$mtime) || $feed->error()) { $errorMessage = $feed->error(); - throw new FreshRSS_Feed_Exception(($errorMessage == '' ? 'Unknown error for feed' : $errorMessage) . ' [' . $url . ']'); + throw new FreshRSS_Feed_Exception( + ($errorMessage == '' ? 'Unknown error for feed' : $errorMessage) . ' [' . $url . ']' + ); } $links = $feed->get_links('self'); @@ -324,9 +326,11 @@ class FreshRSS_Feed extends Minz_Model { if (strpos($mime, 'image/') === 0) { $content .= '

'; } elseif (strpos($mime, 'audio/') === 0) { - $content .= '

💾

'; + $content .= '

💾

'; } elseif (strpos($mime, 'video/') === 0) { - $content .= '

💾

'; + $content .= '

💾

'; } elseif (strpos($mime, 'application/') === 0 || strpos($mime, 'text/') === 0) { $content .= '

💾

'; } else { @@ -481,10 +485,12 @@ class FreshRSS_Feed extends Minz_Model { CURLOPT_FOLLOWLOCATION => true, CURLOPT_RETURNTRANSFER => true, CURLOPT_USERAGENT => 'FreshRSS/' . FRESHRSS_VERSION . ' (' . PHP_OS . '; ' . FRESHRSS_WEBSITE . ')', - CURLOPT_POSTFIELDS => 'hub.verify=sync' - . '&hub.mode=' . ($state ? 'subscribe' : 'unsubscribe') - . '&hub.topic=' . urlencode($url) - . '&hub.callback=' . urlencode($callbackUrl) + CURLOPT_POSTFIELDS => http_build_query( + 'hub.verify' => 'sync', + 'hub.mode' => ($state ? 'subscribe' : 'unsubscribe'), + 'hub.topic' => urlencode($url), + 'hub.callback' => urlencode($callbackUrl), + ) ) ); $response = curl_exec($ch); diff --git a/app/Models/FeedDAO.php b/app/Models/FeedDAO.php index d278122e3..0de6d98be 100644 --- a/app/Models/FeedDAO.php +++ b/app/Models/FeedDAO.php @@ -2,7 +2,23 @@ class FreshRSS_FeedDAO extends Minz_ModelPdo implements FreshRSS_Searchable { public function addFeed($valuesTmp) { - $sql = 'INSERT INTO `' . $this->prefix . 'feed` (url, category, name, website, description, `lastUpdate`, priority, `httpAuth`, error, keep_history, ttl) VALUES(?, ?, ?, ?, ?, ?, 10, ?, 0, -2, -2)'; + $sql = ' + INSERT INTO `' . $this->prefix . 'feed` + ( + url, + category, + name, + website, + description, + `lastUpdate`, + priority, + `httpAuth`, + error, + keep_history, + ttl + ) + VALUES + (?, ?, ?, ?, ?, ?, 10, ?, 0, -2, -2)'; $stm = $this->bd->prepare($sql); $valuesTmp['url'] = safe_ascii($valuesTmp['url']); @@ -380,7 +396,7 @@ class FreshRSS_FeedDAO extends Minz_ModelPdo implements FreshRSS_Searchable { if ($catID === null) { $category = isset($dao['category']) ? $dao['category'] : 0; } else { - $category = $catID ; + $category = $catID; } $myFeed = new FreshRSS_Feed(isset($dao['url']) ? $dao['url'] : '', false); diff --git a/app/Models/Share.php b/app/Models/Share.php index 1c8a7e767..86b1b9ed9 100644 --- a/app/Models/Share.php +++ b/app/Models/Share.php @@ -87,7 +87,7 @@ class FreshRSS_Share { * decentralized ones. * @param $help_url is an optional url to give help on this option. */ - private function __construct($type, $url_transform, $transform = array(), + private function __construct($type, $url_transform, $transform, $form_type, $help_url = '') { $this->type = $type; $this->name = _t('gen.share.' . $type); diff --git a/app/Models/Themes.php b/app/Models/Themes.php index 5a6ec0a05..8920fbf7e 100644 --- a/app/Models/Themes.php +++ b/app/Models/Themes.php @@ -25,7 +25,7 @@ class FreshRSS_Themes extends Minz_Model { } public static function get_infos($theme_id) { - $theme_dir = PUBLIC_PATH . self::$themesUrl . $theme_id ; + $theme_dir = PUBLIC_PATH . self::$themesUrl . $theme_id; if (is_dir($theme_dir)) { $json_filename = $theme_dir . '/metadata.json'; if (file_exists($json_filename)) { @@ -109,10 +109,8 @@ class FreshRSS_Themes extends Minz_Model { } $url = $name . '.svg'; - $url = isset(self::$themeIcons[$url]) ? (self::$themeIconsUrl . $url) : - (self::$defaultIconsUrl . $url); + $url = isset(self::$themeIcons[$url]) ? (self::$themeIconsUrl . $url) : (self::$defaultIconsUrl . $url); - return $urlOnly ? Minz_Url::display($url) : - '' . $alts[$name] . ''; + return $urlOnly ? Minz_Url::display($url) : '' . $alts[$name] . ''; } } diff --git a/app/Models/UserDAO.php b/app/Models/UserDAO.php index 310c7c096..c921d54c9 100644 --- a/app/Models/UserDAO.php +++ b/app/Models/UserDAO.php @@ -83,17 +83,17 @@ class FreshRSS_UserDAO extends Minz_ModelPdo { } public static function exist($username) { - return is_dir(join_path(DATA_PATH , 'users', $username)); + return is_dir(join_path(DATA_PATH, 'users', $username)); } public static function touch($username = '') { if (!FreshRSS_user_Controller::checkUsername($username)) { $username = Minz_Session::param('currentUser', '_'); } - return touch(join_path(DATA_PATH , 'users', $username, 'config.php')); + return touch(join_path(DATA_PATH, 'users', $username, 'config.php')); } public static function mtime($username) { - return @filemtime(join_path(DATA_PATH , 'users', $username, 'config.php')); + return @filemtime(join_path(DATA_PATH, 'users', $username, 'config.php')); } } diff --git a/app/SQL/install.sql.sqlite.php b/app/SQL/install.sql.sqlite.php index c4e4af006..d485e2120 100644 --- a/app/SQL/install.sql.sqlite.php +++ b/app/SQL/install.sql.sqlite.php @@ -82,8 +82,42 @@ $SQL_CREATE_TABLE_ENTRYTMP = array( global $SQL_INSERT_FEEDS; $SQL_INSERT_FEEDS = array( -'INSERT OR IGNORE INTO `feed` (url, category, name, website, description, ttl) VALUES("http://freshrss.org/feeds/all.atom.xml", 1, "FreshRSS.org", "http://freshrss.org/", "FreshRSS, a free, self-hostable aggregator…", 86400);', -'INSERT OR IGNORE INTO `feed` (url, category, name, website, description, ttl) VALUES("https://github.com/FreshRSS/FreshRSS/releases.atom", 1, "FreshRSS releases", "https://github.com/FreshRSS/FreshRSS/", "FreshRSS releases @ GitHub", 86400);', +'INSERT OR IGNORE INTO `feed` + ( + url, + category, + name, + website, + description, + ttl + ) + VALUES + ( + "http://freshrss.org/feeds/all.atom.xml", + 1, + "FreshRSS.org", + "http://freshrss.org/", + "FreshRSS, a free, self-hostable aggregator…", + 86400 + );', +'INSERT OR IGNORE INTO `feed` + ( + url, + category, + name, + website, + description, + ttl + ) + VALUES + ( + "https://github.com/FreshRSS/FreshRSS/releases.atom", + 1, + "FreshRSS releases", + "https://github.com/FreshRSS/FreshRSS/", + "FreshRSS releases @ GitHub", + 86400 + );', ); define('SQL_DROP_TABLES', 'DROP TABLE IF EXISTS `entrytmp`, `entry`, `feed`, `category`'); diff --git a/app/i18n/cz/conf.php b/app/i18n/cz/conf.php index fd414e246..9a4410679 100644 --- a/app/i18n/cz/conf.php +++ b/app/i18n/cz/conf.php @@ -104,7 +104,7 @@ return array( 'when' => 'Označit článek jako přečtený…', ), 'show' => array( - '_' => 'Počet zobrazených článků', + '_' => 'Počet zobrazených článků', 'adaptive' => 'Vyberte zobrazení', 'all_articles' => 'Zobrazit všechny články', 'unread' => 'Zobrazit jen nepřečtené', diff --git a/app/i18n/cz/gen.php b/app/i18n/cz/gen.php index f891f3f1d..405c05de9 100644 --- a/app/i18n/cz/gen.php +++ b/app/i18n/cz/gen.php @@ -25,7 +25,7 @@ return array( 'keep_logged_in' => 'Zapamatovat přihlášení (%s dny)', 'login' => 'Login', 'logout' => 'Odhlášení', - 'password' => array( + 'password' => array( '_' => 'Heslo', 'format' => 'Alespoň 7 znaků', ), diff --git a/app/i18n/de/conf.php b/app/i18n/de/conf.php index bfc24d2d2..ac7c08e98 100644 --- a/app/i18n/de/conf.php +++ b/app/i18n/de/conf.php @@ -104,7 +104,7 @@ return array( 'when' => 'Artikel als gelesen markieren…', ), 'show' => array( - '_' => 'Artikel zum Anzeigen', + '_' => 'Artikel zum Anzeigen', 'adaptive' => 'Anzeige anpassen', 'all_articles' => 'Alle Artikel zeigen', 'unread' => 'Nur ungelesene zeigen', diff --git a/app/i18n/en/conf.php b/app/i18n/en/conf.php index f4618a1ff..e4eeb74b7 100644 --- a/app/i18n/en/conf.php +++ b/app/i18n/en/conf.php @@ -104,7 +104,7 @@ return array( 'when' => 'Mark article as read…', ), 'show' => array( - '_' => 'Articles to display', + '_' => 'Articles to display', 'adaptive' => 'Adjust showing', 'all_articles' => 'Show all articles', 'unread' => 'Show only unread', diff --git a/app/i18n/it/conf.php b/app/i18n/it/conf.php index e6ce86ef9..15837ae8a 100644 --- a/app/i18n/it/conf.php +++ b/app/i18n/it/conf.php @@ -104,7 +104,7 @@ return array( 'when' => 'Segna articoli come letti…', ), 'show' => array( - '_' => 'Articoli da visualizzare', + '_' => 'Articoli da visualizzare', 'adaptive' => 'Adatta visualizzazione', 'all_articles' => 'Mostra tutti gli articoli', 'unread' => 'Mostra solo non letti', diff --git a/app/i18n/kr/conf.php b/app/i18n/kr/conf.php index e116a6456..35d412078 100644 --- a/app/i18n/kr/conf.php +++ b/app/i18n/kr/conf.php @@ -104,7 +104,7 @@ return array( 'when' => '읽음으로 표시…', ), 'show' => array( - '_' => '글 표시 방식', + '_' => '글 표시 방식', 'adaptive' => '읽지 않은 글이 없으면 모든 글 표시', 'all_articles' => '모든 글 표시', 'unread' => '읽지 않은 글만 표시', diff --git a/app/i18n/nl/conf.php b/app/i18n/nl/conf.php index 77f6307ed..e4db5ec3d 100644 --- a/app/i18n/nl/conf.php +++ b/app/i18n/nl/conf.php @@ -104,7 +104,7 @@ return array( 'when' => 'Markeer artikel als gelezen…', ), 'show' => array( - '_' => 'Artikelen om te tonen', + '_' => 'Artikelen om te tonen', 'adaptive' => 'Pas weergave aan', 'all_articles' => 'Bekijk alle artikelen', 'unread' => 'Bekijk alleen ongelezen', diff --git a/app/i18n/ru/conf.php b/app/i18n/ru/conf.php index 3cf0a5ea9..9c61754ae 100644 --- a/app/i18n/ru/conf.php +++ b/app/i18n/ru/conf.php @@ -104,7 +104,7 @@ return array( 'when' => 'Mark article as read…', ), 'show' => array( - '_' => 'Articles to display', + '_' => 'Articles to display', 'adaptive' => 'Adjust showing', 'all_articles' => 'Show all articles', 'unread' => 'Show only unread', diff --git a/app/i18n/tr/conf.php b/app/i18n/tr/conf.php index 9930c3637..e4c094be2 100644 --- a/app/i18n/tr/conf.php +++ b/app/i18n/tr/conf.php @@ -104,7 +104,7 @@ return array( 'when' => 'Makaleyi okundu olarak işaretle…', ), 'show' => array( - '_' => 'Gösterilecek makaleler', + '_' => 'Gösterilecek makaleler', 'adaptive' => 'Ayarlanmış gösterim', 'all_articles' => 'Tüm makaleleri göster', 'unread' => 'Sadece okunmamış makaleleri göster', diff --git a/app/i18n/zh-cn/conf.php b/app/i18n/zh-cn/conf.php index 6ac0bb5e7..fb62c48ef 100644 --- a/app/i18n/zh-cn/conf.php +++ b/app/i18n/zh-cn/conf.php @@ -104,7 +104,7 @@ return array( 'when' => '将文章设为已读…', ), 'show' => array( - '_' => '文章显示', + '_' => '文章显示', 'adaptive' => '智能显示', 'all_articles' => '显示所有文章', 'unread' => '只显示未读', diff --git a/app/install.php b/app/install.php index e77eaa6a5..870c93908 100644 --- a/app/install.php +++ b/app/install.php @@ -11,7 +11,7 @@ session_set_cookie_params(0, dirname(empty($_SERVER['REQUEST_URI']) ? '/' : dirn session_start(); if (isset($_GET['step'])) { - define('STEP',(int)$_GET['step']); + define('STEP', (int)$_GET['step']); } else { define('STEP', 0); } @@ -652,7 +652,7 @@ function printStep3() {
- +
diff --git a/cli/_update-or-create-user.php b/cli/_update-or-create-user.php index c7f1008cd..15397f1f6 100644 --- a/cli/_update-or-create-user.php +++ b/cli/_update-or-create-user.php @@ -23,7 +23,8 @@ if (!$isUpdate) { $options = getopt('', $params); if (empty($options['user'])) { - fail('Usage: ' . basename($_SERVER['SCRIPT_FILENAME']) . " --user username ( --password 'password' --api_password 'api_password'" . + fail('Usage: ' . basename($_SERVER['SCRIPT_FILENAME']) . + " --user username ( --password 'password' --api_password 'api_password'" . " --language en --email user@example.net --token 'longRandomString'" . ($isUpdate ? '' : '--no_default_feeds') . " --purge_after_months 3 --feed_min_articles_default 50 --feed_ttl_default 3600" . diff --git a/cli/create-user.php b/cli/create-user.php index add9c1b13..1b6be3153 100755 --- a/cli/create-user.php +++ b/cli/create-user.php @@ -5,7 +5,8 @@ require('_update-or-create-user.php'); $username = $options['user']; if (!FreshRSS_user_Controller::checkUsername($username)) { - fail('FreshRSS error: invalid username “' . $username . '”! Must be matching ' . FreshRSS_user_Controller::USERNAME_PATTERN); + fail('FreshRSS error: invalid username “' . $username . + '”! Must be matching ' . FreshRSS_user_Controller::USERNAME_PATTERN); } $usernames = listUsers(); diff --git a/cli/do-install.php b/cli/do-install.php index 54e3c3d4f..74bbdfcd4 100755 --- a/cli/do-install.php +++ b/cli/do-install.php @@ -81,14 +81,17 @@ if ($requirements['all'] !== 'ok') { } if (!FreshRSS_user_Controller::checkUsername($options['default_user'])) { - fail('FreshRSS error: invalid default username “' . $options['default_user'] . '”! Must be matching ' . FreshRSS_user_Controller::USERNAME_PATTERN); + fail('FreshRSS error: invalid default username “' . $options['default_user'] + . '”! Must be matching ' . FreshRSS_user_Controller::USERNAME_PATTERN); } 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']); + fail('FreshRSS invalid authentication method (auth_type must be one of { form, http_auth, none }): ' + . $options['auth_type']); } -if (file_put_contents(join_path(DATA_PATH, 'config.php'), "default_user !== '' && in_array(FreshRSS_Context::$system_conf->default_user, $users, true)) { +if (FreshRSS_Context::$system_conf->default_user !== '' + && in_array(FreshRSS_Context::$system_conf->default_user, $users, true)) { array_unshift($users, FreshRSS_Context::$system_conf->default_user); $users = array_unique($users); } diff --git a/cli/reconfigure.php b/cli/reconfigure.php index c6902da67..466d35373 100755 --- a/cli/reconfigure.php +++ b/cli/reconfigure.php @@ -51,7 +51,8 @@ if (!FreshRSS_user_Controller::checkUsername($config->default_user)) { } if (isset($config->auth_type) && !in_array($config->auth_type, array('form', 'http_auth', 'none'))) { - fail('FreshRSS invalid authentication method (auth_type must be one of { form, http_auth, none }: ' . $config->auth_type); + fail('FreshRSS invalid authentication method (auth_type must be one of { form, http_auth, none }: ' + . $config->auth_type); } $config->save(); diff --git a/data/shares.php b/data/shares.php index 16e528d14..d73ae3826 100644 --- a/data/shares.php +++ b/data/shares.php @@ -4,7 +4,7 @@ * This is a configuration file. You shouldn't modify it unless you know what * you are doing. If you want to add a share type, this is where you need to do * it. - * + * * For each share there is different configuration options. Here is the description * of those options: * - url is a mandatory option. It is a string representing the share URL. It diff --git a/lib/Minz/ActionController.php b/lib/Minz/ActionController.php index b47c54554..232a4ef9b 100644 --- a/lib/Minz/ActionController.php +++ b/lib/Minz/ActionController.php @@ -1,5 +1,5 @@ */ @@ -24,7 +24,7 @@ class Minz_ActionController { public function view () { return $this->view; } - + /** * Méthodes à redéfinir (ou non) par héritage * firstAction est la première méthode exécutée par le Dispatcher @@ -34,5 +34,3 @@ class Minz_ActionController { public function firstAction () { } public function lastAction () { } } - - diff --git a/lib/Minz/ActionException.php b/lib/Minz/ActionException.php index c566a076f..f1f70c1bc 100644 --- a/lib/Minz/ActionException.php +++ b/lib/Minz/ActionException.php @@ -3,7 +3,7 @@ class Minz_ActionException extends Minz_Exception { public function __construct ($controller_name, $action_name, $code = self::ERROR) { $message = '`' . $action_name . '` cannot be invoked on `' . $controller_name . '`'; - + parent::__construct ($message, $code); } } diff --git a/lib/Minz/Configuration.php b/lib/Minz/Configuration.php index d695d4a53..5470dc85f 100644 --- a/lib/Minz/Configuration.php +++ b/lib/Minz/Configuration.php @@ -104,7 +104,7 @@ class Minz_Configuration { /** * Create a new Minz_Configuration object. - * + * * @param $namespace the name of the current configuration. * @param $config_filename the file containing configuration values. * @param $default_filename the file containing default values, null by default. @@ -145,7 +145,7 @@ class Minz_Configuration { /** * Return the value of the given param. - * + * * @param $key the name of the param. * @param $default default value to return if key does not exist. * @return the value corresponding to the key. diff --git a/lib/Minz/ControllerNotActionControllerException.php b/lib/Minz/ControllerNotActionControllerException.php index 535a1377e..1a8e0729c 100644 --- a/lib/Minz/ControllerNotActionControllerException.php +++ b/lib/Minz/ControllerNotActionControllerException.php @@ -3,7 +3,7 @@ class Minz_ControllerNotActionControllerException extends Minz_Exception { public function __construct ($controller_name, $code = self::ERROR) { $message = 'Controller `' . $controller_name . '` isn\'t instance of ActionController'; - + parent::__construct ($message, $code); } } diff --git a/lib/Minz/ControllerNotExistException.php b/lib/Minz/ControllerNotExistException.php index 523867d11..24a09a635 100644 --- a/lib/Minz/ControllerNotExistException.php +++ b/lib/Minz/ControllerNotExistException.php @@ -3,7 +3,7 @@ class Minz_ControllerNotExistException extends Minz_Exception { public function __construct ($controller_name, $code = self::ERROR) { $message = 'Controller `' . $controller_name . '` doesn\'t exist'; - + parent::__construct ($message, $code); } } diff --git a/lib/Minz/CurrentPagePaginationException.php b/lib/Minz/CurrentPagePaginationException.php index 74214d879..3e3d9d1b4 100644 --- a/lib/Minz/CurrentPagePaginationException.php +++ b/lib/Minz/CurrentPagePaginationException.php @@ -2,7 +2,7 @@ class Minz_CurrentPagePaginationException extends Minz_Exception { public function __construct ($page) { $message = 'Page number `' . $page . '` doesn\'t exist'; - + parent::__construct ($message, self::ERROR); } } diff --git a/lib/Minz/Dispatcher.php b/lib/Minz/Dispatcher.php index 125ce5757..bdb1c76f6 100644 --- a/lib/Minz/Dispatcher.php +++ b/lib/Minz/Dispatcher.php @@ -1,5 +1,5 @@ */ diff --git a/lib/Minz/FileNotExistException.php b/lib/Minz/FileNotExistException.php index f8dfbdf66..f97f161af 100644 --- a/lib/Minz/FileNotExistException.php +++ b/lib/Minz/FileNotExistException.php @@ -2,7 +2,7 @@ class Minz_FileNotExistException extends Minz_Exception { public function __construct ($file_name, $code = self::ERROR) { $message = 'File not found: `' . $file_name.'`'; - + parent::__construct ($message, $code); } } diff --git a/lib/Minz/FrontController.php b/lib/Minz/FrontController.php index 952d983c9..066278b7c 100644 --- a/lib/Minz/FrontController.php +++ b/lib/Minz/FrontController.php @@ -119,12 +119,12 @@ class Minz_FrontController { switch($conf->environment) { case 'production': error_reporting(E_ALL); - ini_set('display_errors','Off'); + ini_set('display_errors', 'Off'); ini_set('log_errors', 'On'); break; case 'development': error_reporting(E_ALL); - ini_set('display_errors','On'); + ini_set('display_errors', 'On'); ini_set('log_errors', 'On'); break; case 'silent': diff --git a/lib/Minz/Helper.php b/lib/Minz/Helper.php index f4a547c4e..c328d9e6b 100644 --- a/lib/Minz/Helper.php +++ b/lib/Minz/Helper.php @@ -1,5 +1,5 @@ */ @@ -13,7 +13,7 @@ class Minz_Helper { * @param $var variable à traiter (tableau ou simple variable) */ public static function stripslashes_r($var) { - if (is_array($var)){ + if (is_array($var)) { return array_map(array('Minz_Helper', 'stripslashes_r'), $var); } else { return stripslashes($var); diff --git a/lib/Minz/Model.php b/lib/Minz/Model.php index adbaba942..1310888cf 100644 --- a/lib/Minz/Model.php +++ b/lib/Minz/Model.php @@ -1,5 +1,5 @@ */ diff --git a/lib/Minz/ModelArray.php b/lib/Minz/ModelArray.php index ff23dbc83..1ac2b313d 100644 --- a/lib/Minz/ModelArray.php +++ b/lib/Minz/ModelArray.php @@ -25,8 +25,7 @@ class Minz_ModelArray { protected function loadArray() { if (!file_exists($this->filename)) { throw new Minz_FileNotExistException($this->filename, Minz_Exception::WARNING); - } - elseif (($handle = $this->getLock()) === false) { + } elseif (($handle = $this->getLock()) === false) { throw new Minz_PermissionDeniedException($this->filename); } else { $data = include($this->filename); diff --git a/lib/Minz/ModelPdo.php b/lib/Minz/ModelPdo.php index caab1d114..d769e0ff4 100644 --- a/lib/Minz/ModelPdo.php +++ b/lib/Minz/ModelPdo.php @@ -39,7 +39,7 @@ class Minz_ModelPdo { if ($currentUser === null) { $currentUser = Minz_Session::param('currentUser'); } - if (self::$useSharedBd && self::$sharedBd != null && + if (self::$useSharedBd && self::$sharedBd != null && ($currentUser == null || $currentUser === self::$sharedCurrentUser)) { $this->bd = self::$sharedBd; $this->prefix = self::$sharedPrefix; diff --git a/lib/Minz/PDOConnectionException.php b/lib/Minz/PDOConnectionException.php index faf2e0fe9..064748708 100644 --- a/lib/Minz/PDOConnectionException.php +++ b/lib/Minz/PDOConnectionException.php @@ -3,7 +3,7 @@ class Minz_PDOConnectionException extends Minz_Exception { public function __construct ($string_connection, $user, $code = self::ERROR) { $message = 'Access to database is denied for `' . $user . '`' . ' (`' . $string_connection . '`)'; - + parent::__construct ($message, $code); } } diff --git a/lib/Minz/Paginator.php b/lib/Minz/Paginator.php index 5858e76a5..795085a30 100644 --- a/lib/Minz/Paginator.php +++ b/lib/Minz/Paginator.php @@ -1,5 +1,5 @@ */ @@ -51,7 +51,7 @@ class Minz_Paginator { */ public function render ($view, $getteur) { $view = APP_PATH . '/views/helpers/'.$view; - + if (file_exists ($view)) { include ($view); } @@ -129,7 +129,7 @@ class Minz_Paginator { $begin = ($this->currentPage - 1) * $this->nbItemsPerPage; $counter = 0; $i = 0; - + foreach ($this->items as $key => $item) { if ($i >= $begin) { $array[$key] = $item; @@ -164,7 +164,7 @@ class Minz_Paginator { if (is_array ($items)) { $this->items = $items; } - + $this->_nbPage (); } public function _nbItemsPerPage ($nbItemsPerPage) { diff --git a/lib/Minz/Translate.php b/lib/Minz/Translate.php index baddcb424..d9cd59f7e 100644 --- a/lib/Minz/Translate.php +++ b/lib/Minz/Translate.php @@ -1,5 +1,5 @@ */ @@ -153,7 +153,7 @@ class Minz_Translate { * @param additional parameters for variable keys. * @return the value corresponding to the key. * If no value is found, return the key itself. - */ + */ public static function t($key) { $group = explode('.', $key); diff --git a/lib/Minz/View.php b/lib/Minz/View.php index 8c5230ab6..d6bf6ea2c 100644 --- a/lib/Minz/View.php +++ b/lib/Minz/View.php @@ -262,5 +262,3 @@ class Minz_View { } } } - - diff --git a/lib/favicons.php b/lib/favicons.php index 48f7c9fda..a7ed966a1 100644 --- a/lib/favicons.php +++ b/lib/favicons.php @@ -16,6 +16,7 @@ function isImgMime($content) { $isImage = strpos(finfo_buffer($fInfo, $content), 'image') !== false; finfo_close($fInfo); } catch (Exception $e) { + echo 'Caught exception: ', $e->getMessage(), "\n"; } return $isImage; } diff --git a/lib/lib_date.php b/lib/lib_date.php index 9533711e3..a3f7efb46 100644 --- a/lib/lib_date.php +++ b/lib/lib_date.php @@ -63,8 +63,7 @@ function _dateCeiling($isoDate) { } function _noDelimit($isoDate) { - return $isoDate === null || $isoDate === '' ? null : - str_replace(array('-', ':'), '', $isoDate); //FIXME: Bug with negative time zone + return $isoDate === null || $isoDate === '' ? null : str_replace(array('-', ':'), '', $isoDate); //FIXME: Bug with negative time zone } function _dateRelative($d1, $d2) { diff --git a/lib/lib_install.php b/lib/lib_install.php index cc0dc3128..7305d8e28 100644 --- a/lib/lib_install.php +++ b/lib/lib_install.php @@ -68,8 +68,7 @@ function checkRequirements($dbType = '') { 'http_referer' => $http_referer ? 'ok' : 'ko', 'message' => $message ?: 'ok', 'all' => $php && $minz && $curl && $pdo && $pcre && $ctype && $dom && $xml && - $data && $cache && $users && $favicons && $http_referer && $message == '' ? - 'ok' : 'ko' + $data && $cache && $users && $favicons && $http_referer && $message == '' ? 'ok' : 'ko' ); } diff --git a/lib/lib_rss.php b/lib/lib_rss.php index dcce8a02c..959cb064c 100644 --- a/lib/lib_rss.php +++ b/lib/lib_rss.php @@ -348,6 +348,7 @@ function get_user_configuration($username) { join_path(FRESHRSS_PATH, 'config-user.default.php')); } catch (Minz_ConfigurationNamespaceException $e) { // namespace already exists, do nothing. + Minz_Log::warning($e->getMessage()); } catch (Minz_FileNotExistException $e) { Minz_Log::warning($e->getMessage()); return null; @@ -366,6 +367,7 @@ function cryptAvailable() { $hash = '$2y$04$usesomesillystringfore7hnbRJHxXVLeakoG8K30oukPsA.ztMG'; return $hash === @crypt('password', $hash); } catch (Exception $e) { + Minz_Log::warning($e->getMessage()); } return false; } diff --git a/p/api/greader.php b/p/api/greader.php index 7f6f0b04f..e5275b3a3 100644 --- a/p/api/greader.php +++ b/p/api/greader.php @@ -94,7 +94,16 @@ function debugInfo() { } } global $ORIGINAL_INPUT; - return print_r(array('date' => date('c'), 'headers' => $ALL_HEADERS, '_SERVER' => $_SERVER, '_GET' => $_GET, '_POST' => $_POST, '_COOKIE' => $_COOKIE, 'INPUT' => $ORIGINAL_INPUT), true); + return print_r( + array( + 'date' => date('c'), + 'headers' => $ALL_HEADERS, + '_SERVER' => $_SERVER, + '_GET' => $_GET, + '_POST' => $_POST, + '_COOKIE' => $_COOKIE, + 'INPUT' => $ORIGINAL_INPUT + ), true); } function badRequest() { @@ -694,8 +703,8 @@ $pathInfo = empty($_SERVER['PATH_INFO']) ? '/Error' : urldecode($_SERVER['PATH_I $pathInfos = explode('/', $pathInfo); Minz_Configuration::register('system', - DATA_PATH . '/config.php', - FRESHRSS_PATH . '/config.default.php'); + DATA_PATH . '/config.php', + FRESHRSS_PATH . '/config.default.php'); FreshRSS_Context::$system_conf = Minz_Configuration::get('system'); if (!FreshRSS_Context::$system_conf->api_enabled) { serviceUnavailable(); @@ -715,24 +724,34 @@ Minz_Session::_param('currentUser', $user); if (count($pathInfos) < 3) { badRequest(); -} -elseif ($pathInfos[1] === 'accounts') { +} elseif ($pathInfos[1] === 'accounts') { if (($pathInfos[2] === 'ClientLogin') && isset($_REQUEST['Email']) && isset($_REQUEST['Passwd'])) { clientLogin($_REQUEST['Email'], $_REQUEST['Passwd']); } -} -elseif ($pathInfos[1] === 'reader' && $pathInfos[2] === 'api' && isset($pathInfos[3]) && $pathInfos[3] === '0' && isset($pathInfos[4])) { +} elseif ($pathInfos[1] === 'reader' && $pathInfos[2] === 'api' && isset($pathInfos[3]) && $pathInfos[3] === '0' && isset($pathInfos[4])) { if ($user == '') { unauthorized(); } $timestamp = isset($_GET['ck']) ? intval($_GET['ck']) : 0; //ck=[unix timestamp] : Use the current Unix time here, helps Google with caching. switch ($pathInfos[4]) { case 'stream': - $exclude_target = isset($_GET['xt']) ? $_GET['xt'] : ''; //xt=[exclude target] : Used to exclude certain items from the feed. For example, using xt=user/-/state/com.google/read will exclude items that the current user has marked as read, or xt=feed/[feedurl] will exclude items from a particular feed (obviously not useful in this request, but xt appears in other listing requests). + /* xt=[exclude target] : Used to exclude certain items from the feed. + * For example, using xt=user/-/state/com.google/read will exclude items + * that the current user has marked as read, or xt=feed/[feedurl] will + * exclude items from a particular feed (obviously not useful in this + * request, but xt appears in other listing requests). */ + $exclude_target = isset($_GET['xt']) ? $_GET['xt'] : ''; $count = isset($_GET['n']) ? intval($_GET['n']) : 20; //n=[integer] : The maximum number of results to return. $order = isset($_GET['r']) ? $_GET['r'] : 'd'; //r=[d|n|o] : Sort order of item results. d or n gives items in descending date order, o in ascending order. - $start_time = isset($_GET['ot']) ? intval($_GET['ot']) : 0; //ot=[unix timestamp] : The time from which you want to retrieve items. Only items that have been crawled by Google Reader after this time will be returned. - $continuation = isset($_GET['c']) ? $_GET['c'] : ''; //Continuation token. If a StreamContents response does not represent all items in a timestamp range, it will have a continuation attribute. The same request can be re-issued with the value of that attribute put in this parameter to get more items + /* ot=[unix timestamp] : The time from which you want to retrieve + * items. Only items that have been crawled by Google Reader after + * this time will be returned. */ + $start_time = isset($_GET['ot']) ? intval($_GET['ot']) : 0; + /* Continuation token. If a StreamContents response does not represent + * all items in a timestamp range, it will have a continuation attribute. + * The same request can be re-issued with the value of that attribute put + * in this parameter to get more items */ + $continuation = isset($_GET['c']) ? $_GET['c'] : ''; if (isset($pathInfos[5]) && $pathInfos[5] === 'contents' && isset($pathInfos[6])) { if (isset($pathInfos[7])) { if ($pathInfos[6] === 'feed') { @@ -757,7 +776,10 @@ elseif ($pathInfos[1] === 'reader' && $pathInfos[2] === 'api' && isset($pathInfo } } elseif ($pathInfos[5] === 'items') { if ($pathInfos[6] === 'ids' && isset($_GET['s'])) { - $streamId = $_GET['s']; //StreamId for which to fetch the item IDs. The parameter may be repeated to fetch the item IDs from multiple streams at once (more efficient from a backend perspective than multiple requests). + /* StreamId for which to fetch the item IDs. The parameter may + * be repeated to fetch the item IDs from multiple streams at once + * (more efficient from a backend perspective than multiple requests). */ + $streamId = $_GET['s']; streamContentsItemsIds($streamId, $start_time, $count, $order, $exclude_target); } } @@ -779,8 +801,12 @@ elseif ($pathInfos[1] === 'reader' && $pathInfos[2] === 'api' && isset($pathInfo break; case 'edit': if (isset($_POST['s']) && isset($_POST['ac'])) { - $streamNames = multiplePosts('s'); //StreamId to operate on. The parameter may be repeated to edit multiple subscriptions at once - $titles = multiplePosts('t'); //Title to use for the subscription. For the `subscribe` action, if not specified then the feed's current title will be used. Can be used with the `edit` action to rename a subscription + //StreamId to operate on. The parameter may be repeated to edit multiple subscriptions at once + $streamNames = multiplePosts('s'); + /* Title to use for the subscription. For the `subscribe` action, + * if not specified then the feed's current title will be used. Can + * be used with the `edit` action to rename a subscription */ + $titles = multiplePosts('t'); $action = $_POST['ac']; //Action to perform on the given StreamId. Possible values are `subscribe`, `unsubscribe` and `edit` $add = isset($_POST['a']) ? $_POST['a'] : ''; //StreamId to add the subscription to (generally a user label) $remove = isset($_POST['r']) ? $_POST['r'] : ''; //StreamId to remove the subscription from (generally a user label) diff --git a/p/api/index.php b/p/api/index.php index 580c90255..08f7b6b7b 100644 --- a/p/api/index.php +++ b/p/api/index.php @@ -22,7 +22,8 @@ echo Minz_Url::display('/api/greader.php', 'html', true); diff --git a/phpcs.xml b/phpcs.xml new file mode 100644 index 000000000..5743466ec --- /dev/null +++ b/phpcs.xml @@ -0,0 +1,100 @@ + + + Created with the PHP Coding Standard Generator. http://edorian.github.com/php-coding-standard-generator/ + + + ./static + ./vendor + ./lib/SimplePie/ + ./lib/http-conditional.php + ./lib/JSON.php + ./lib/lib_phpQuery.php + ./lib/password_compat.php + + + + + + + + + + + + + + + ./app/i18n/ + + ./app/install.php + + ./tests/app/ + + ./app/SQL/install.sql.mysql.php + ./app/SQL/install.sql.pgsql.php + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/app/Models/CategoryTest.php b/tests/app/Models/CategoryTest.php index 2fd153aee..a1edb17b6 100644 --- a/tests/app/Models/CategoryTest.php +++ b/tests/app/Models/CategoryTest.php @@ -20,12 +20,12 @@ class FreshRSS_CategoryTest extends PHPUnit\Framework\TestCase { public function provideValidNames() { return array( - array('', ''), - array('this string does not need trimming', 'this string does not need trimming'), - array(' this string needs trimming on left', 'this string needs trimming on left'), - array('this string needs trimming on right ', 'this string needs trimming on right'), - array(' this string needs trimming on both ends ', 'this string needs trimming on both ends'), - array(str_repeat('This string needs to be shortened because its length is way too long. ', 4), str_repeat('This string needs to be shortened because its length is way too long. ', 3) . 'This string needs to be shortened because its'), + array('', ''), + array('this string does not need trimming', 'this string does not need trimming'), + array(' this string needs trimming on left', 'this string needs trimming on left'), + array('this string needs trimming on right ', 'this string needs trimming on right'), + array(' this string needs trimming on both ends ', 'this string needs trimming on both ends'), + array(str_repeat('This string needs to be shortened because its length is way too long. ', 4), str_repeat('This string needs to be shortened because its length is way too long. ', 3) . 'This string needs to be shortened because its'), ); } diff --git a/tests/app/Models/SearchTest.php b/tests/app/Models/SearchTest.php index 4a7afc6f9..5c0469a48 100644 --- a/tests/app/Models/SearchTest.php +++ b/tests/app/Models/SearchTest.php @@ -28,8 +28,8 @@ class SearchTest extends PHPUnit\Framework\TestCase { */ public function provideEmptyInput() { return array( - array(''), - array(null), + array(''), + array(null), ); } @@ -50,22 +50,22 @@ class SearchTest extends PHPUnit\Framework\TestCase { */ public function provideIntitleSearch() { return array( - array('intitle:word1', array('word1'), null), - array('intitle:word1 word2', array('word1'), array('word2')), - array('intitle:"word1 word2"', array('word1 word2'), null), - array("intitle:'word1 word2'", array('word1 word2'), null), - array('word1 intitle:word2', array('word2'), array('word1')), - array('word1 intitle:word2 word3', array('word2'), array('word1', 'word3')), - array('word1 intitle:"word2 word3"', array('word2 word3'), array('word1')), - array("word1 intitle:'word2 word3'", array('word2 word3'), array('word1')), - array('intitle:word1 intitle:word2', array('word1', 'word2'), null), - array('intitle: word1 word2', array(), array('word1', 'word2')), - array('intitle:123', array('123'), null), - array('intitle:"word1 word2" word3"', array('word1 word2'), array('word3"')), - array("intitle:'word1 word2' word3'", array('word1 word2'), array("word3'")), - array('intitle:"word1 word2\' word3"', array("word1 word2' word3"), null), - array("intitle:'word1 word2\" word3'", array('word1 word2" word3'), null), - array("intitle:word1 'word2 word3' word4", array('word1'), array('word2 word3', 'word4')), + array('intitle:word1', array('word1'), null), + array('intitle:word1 word2', array('word1'), array('word2')), + array('intitle:"word1 word2"', array('word1 word2'), null), + array("intitle:'word1 word2'", array('word1 word2'), null), + array('word1 intitle:word2', array('word2'), array('word1')), + array('word1 intitle:word2 word3', array('word2'), array('word1', 'word3')), + array('word1 intitle:"word2 word3"', array('word2 word3'), array('word1')), + array("word1 intitle:'word2 word3'", array('word2 word3'), array('word1')), + array('intitle:word1 intitle:word2', array('word1', 'word2'), null), + array('intitle: word1 word2', array(), array('word1', 'word2')), + array('intitle:123', array('123'), null), + array('intitle:"word1 word2" word3"', array('word1 word2'), array('word3"')), + array("intitle:'word1 word2' word3'", array('word1 word2'), array("word3'")), + array('intitle:"word1 word2\' word3"', array("word1 word2' word3"), null), + array("intitle:'word1 word2\" word3'", array('word1 word2" word3'), null), + array("intitle:word1 'word2 word3' word4", array('word1'), array('word2 word3', 'word4')), ); } @@ -86,22 +86,22 @@ class SearchTest extends PHPUnit\Framework\TestCase { */ public function provideAuthorSearch() { return array( - array('author:word1', array('word1'), null), - array('author:word1 word2', array('word1'), array('word2')), - array('author:"word1 word2"', array('word1 word2'), null), - array("author:'word1 word2'", array('word1 word2'), null), - array('word1 author:word2', array('word2'), array('word1')), - array('word1 author:word2 word3', array('word2'), array('word1', 'word3')), - array('word1 author:"word2 word3"', array('word2 word3'), array('word1')), - array("word1 author:'word2 word3'", array('word2 word3'), array('word1')), - array('author:word1 author:word2', array('word1', 'word2'), null), - array('author: word1 word2', array(), array('word1', 'word2')), - array('author:123', array('123'), null), - array('author:"word1 word2" word3"', array('word1 word2'), array('word3"')), - array("author:'word1 word2' word3'", array('word1 word2'), array("word3'")), - array('author:"word1 word2\' word3"', array("word1 word2' word3"), null), - array("author:'word1 word2\" word3'", array('word1 word2" word3'), null), - array("author:word1 'word2 word3' word4", array('word1'), array('word2 word3', 'word4')), + array('author:word1', array('word1'), null), + array('author:word1 word2', array('word1'), array('word2')), + array('author:"word1 word2"', array('word1 word2'), null), + array("author:'word1 word2'", array('word1 word2'), null), + array('word1 author:word2', array('word2'), array('word1')), + array('word1 author:word2 word3', array('word2'), array('word1', 'word3')), + array('word1 author:"word2 word3"', array('word2 word3'), array('word1')), + array("word1 author:'word2 word3'", array('word2 word3'), array('word1')), + array('author:word1 author:word2', array('word1', 'word2'), null), + array('author: word1 word2', array(), array('word1', 'word2')), + array('author:123', array('123'), null), + array('author:"word1 word2" word3"', array('word1 word2'), array('word3"')), + array("author:'word1 word2' word3'", array('word1 word2'), array("word3'")), + array('author:"word1 word2\' word3"', array("word1 word2' word3"), null), + array("author:'word1 word2\" word3'", array('word1 word2" word3'), null), + array("author:word1 'word2 word3' word4", array('word1'), array('word2 word3', 'word4')), ); } @@ -122,13 +122,13 @@ class SearchTest extends PHPUnit\Framework\TestCase { */ public function provideInurlSearch() { return array( - array('inurl:word1', array('word1'), null), - array('inurl: word1', array(), array('word1')), - array('inurl:123', array('123'), null), - array('inurl:word1 word2', array('word1'), array('word2')), - array('inurl:"word1 word2"', array('"word1'), array('word2"')), - array('inurl:word1 word2 inurl:word3', array('word1', 'word3'), array('word2')), - array("inurl:word1 'word2 word3' word4", array('word1'), array('word2 word3', 'word4')), + array('inurl:word1', array('word1'), null), + array('inurl: word1', array(), array('word1')), + array('inurl:123', array('123'), null), + array('inurl:word1 word2', array('word1'), array('word2')), + array('inurl:"word1 word2"', array('"word1'), array('word2"')), + array('inurl:word1 word2 inurl:word3', array('word1', 'word3'), array('word2')), + array("inurl:word1 'word2 word3' word4", array('word1'), array('word2 word3', 'word4')), ); } @@ -149,12 +149,12 @@ class SearchTest extends PHPUnit\Framework\TestCase { */ public function provideDateSearch() { return array( - array('date:2007-03-01T13:00:00Z/2008-05-11T15:30:00Z', '1172754000', '1210519800'), - array('date:2007-03-01T13:00:00Z/P1Y2M10DT2H30M', '1172754000', '1210516199'), - array('date:P1Y2M10DT2H30M/2008-05-11T15:30:00Z', '1172757601', '1210519800'), - array('date:2007-03-01/2008-05-11', strtotime('2007-03-01'), strtotime('2008-05-12') - 1), - array('date:2007-03-01/', strtotime('2007-03-01'), ''), - array('date:/2008-05-11', '', strtotime('2008-05-12') - 1), + array('date:2007-03-01T13:00:00Z/2008-05-11T15:30:00Z', '1172754000', '1210519800'), + array('date:2007-03-01T13:00:00Z/P1Y2M10DT2H30M', '1172754000', '1210516199'), + array('date:P1Y2M10DT2H30M/2008-05-11T15:30:00Z', '1172757601', '1210519800'), + array('date:2007-03-01/2008-05-11', strtotime('2007-03-01'), strtotime('2008-05-12') - 1), + array('date:2007-03-01/', strtotime('2007-03-01'), ''), + array('date:/2008-05-11', '', strtotime('2008-05-12') - 1), ); } @@ -175,12 +175,12 @@ class SearchTest extends PHPUnit\Framework\TestCase { */ public function providePubdateSearch() { return array( - array('pubdate:2007-03-01T13:00:00Z/2008-05-11T15:30:00Z', '1172754000', '1210519800'), - array('pubdate:2007-03-01T13:00:00Z/P1Y2M10DT2H30M', '1172754000', '1210516199'), - array('pubdate:P1Y2M10DT2H30M/2008-05-11T15:30:00Z', '1172757601', '1210519800'), - array('pubdate:2007-03-01/2008-05-11', strtotime('2007-03-01'), strtotime('2008-05-12') - 1), - array('pubdate:2007-03-01/', strtotime('2007-03-01'), ''), - array('pubdate:/2008-05-11', '', strtotime('2008-05-12') - 1), + array('pubdate:2007-03-01T13:00:00Z/2008-05-11T15:30:00Z', '1172754000', '1210519800'), + array('pubdate:2007-03-01T13:00:00Z/P1Y2M10DT2H30M', '1172754000', '1210516199'), + array('pubdate:P1Y2M10DT2H30M/2008-05-11T15:30:00Z', '1172757601', '1210519800'), + array('pubdate:2007-03-01/2008-05-11', strtotime('2007-03-01'), strtotime('2008-05-12') - 1), + array('pubdate:2007-03-01/', strtotime('2007-03-01'), ''), + array('pubdate:/2008-05-11', '', strtotime('2008-05-12') - 1), ); } @@ -201,13 +201,13 @@ class SearchTest extends PHPUnit\Framework\TestCase { */ public function provideTagsSearch() { return array( - array('#word1', array('word1'), null), - array('# word1', array(), array('#', 'word1')), - array('#123', array('123'), null), - array('#word1 word2', array('word1'), array('word2')), - array('#"word1 word2"', array('"word1'), array('word2"')), - array('#word1 #word2', array('word1', 'word2'), null), - array("#word1 'word2 word3' word4", array('word1'), array('word2 word3', 'word4')), + array('#word1', array('word1'), null), + array('# word1', array(), array('#', 'word1')), + array('#123', array('123'), null), + array('#word1 word2', array('word1'), array('word2')), + array('#"word1 word2"', array('"word1'), array('word2"')), + array('#word1 #word2', array('word1', 'word2'), null), + array("#word1 'word2 word3' word4", array('word1'), array('word2 word3', 'word4')), ); } @@ -240,54 +240,54 @@ class SearchTest extends PHPUnit\Framework\TestCase { public function provideMultipleSearch() { return array( - array( - 'author:word1 date:2007-03-01/2008-05-11 intitle:word2 inurl:word3 pubdate:2007-03-01/2008-05-11 #word4 #word5', - array('word1'), - strtotime('2007-03-01'), - strtotime('2008-05-12') - 1, - array('word2'), - array('word3'), - strtotime('2007-03-01'), - strtotime('2008-05-12') - 1, - array('word4', 'word5'), - null, - ), - array( - 'word6 intitle:word2 inurl:word3 pubdate:2007-03-01/2008-05-11 #word4 author:word1 #word5 date:2007-03-01/2008-05-11', - array('word1'), - strtotime('2007-03-01'), - strtotime('2008-05-12') - 1, - array('word2'), - array('word3'), - strtotime('2007-03-01'), - strtotime('2008-05-12') - 1, - array('word4', 'word5'), - array('word6'), - ), - array( - 'word6 intitle:word2 inurl:word3 pubdate:2007-03-01/2008-05-11 #word4 author:word1 #word5 word7 date:2007-03-01/2008-05-11', - array('word1'), - strtotime('2007-03-01'), - strtotime('2008-05-12') - 1, - array('word2'), - array('word3'), - strtotime('2007-03-01'), - strtotime('2008-05-12') - 1, - array('word4', 'word5'), - array('word6', 'word7'), - ), - array( - 'word6 intitle:word2 inurl:word3 pubdate:2007-03-01/2008-05-11 #word4 author:word1 #word5 "word7 word8" date:2007-03-01/2008-05-11', - array('word1'), - strtotime('2007-03-01'), - strtotime('2008-05-12') - 1, - array('word2'), - array('word3'), - strtotime('2007-03-01'), - strtotime('2008-05-12') - 1, - array('word4', 'word5'), - array('word7 word8', 'word6'), - ), + array( + 'author:word1 date:2007-03-01/2008-05-11 intitle:word2 inurl:word3 pubdate:2007-03-01/2008-05-11 #word4 #word5', + array('word1'), + strtotime('2007-03-01'), + strtotime('2008-05-12') - 1, + array('word2'), + array('word3'), + strtotime('2007-03-01'), + strtotime('2008-05-12') - 1, + array('word4', 'word5'), + null, + ), + array( + 'word6 intitle:word2 inurl:word3 pubdate:2007-03-01/2008-05-11 #word4 author:word1 #word5 date:2007-03-01/2008-05-11', + array('word1'), + strtotime('2007-03-01'), + strtotime('2008-05-12') - 1, + array('word2'), + array('word3'), + strtotime('2007-03-01'), + strtotime('2008-05-12') - 1, + array('word4', 'word5'), + array('word6'), + ), + array( + 'word6 intitle:word2 inurl:word3 pubdate:2007-03-01/2008-05-11 #word4 author:word1 #word5 word7 date:2007-03-01/2008-05-11', + array('word1'), + strtotime('2007-03-01'), + strtotime('2008-05-12') - 1, + array('word2'), + array('word3'), + strtotime('2007-03-01'), + strtotime('2008-05-12') - 1, + array('word4', 'word5'), + array('word6', 'word7'), + ), + array( + 'word6 intitle:word2 inurl:word3 pubdate:2007-03-01/2008-05-11 #word4 author:word1 #word5 "word7 word8" date:2007-03-01/2008-05-11', + array('word1'), + strtotime('2007-03-01'), + strtotime('2008-05-12') - 1, + array('word2'), + array('word3'), + strtotime('2007-03-01'), + strtotime('2008-05-12') - 1, + array('word4', 'word5'), + array('word7 word8', 'word6'), + ), ); } diff --git a/tests/app/Models/UserQueryTest.php b/tests/app/Models/UserQueryTest.php index 5c12a12fc..1959fd492 100644 --- a/tests/app/Models/UserQueryTest.php +++ b/tests/app/Models/UserQueryTest.php @@ -33,14 +33,14 @@ class UserQueryTest extends PHPUnit\Framework\TestCase { $category_name = 'some category name'; $cat = $this->getMock('FreshRSS_Category'); $cat->expects($this->atLeastOnce()) - ->method('name') - ->withAnyParameters() - ->willReturn($category_name); + ->method('name') + ->withAnyParameters() + ->willReturn($category_name); $cat_dao = $this->getMock('FreshRSS_Searchable'); $cat_dao->expects($this->atLeastOnce()) - ->method('searchById') - ->withAnyParameters() - ->willReturn($cat); + ->method('searchById') + ->withAnyParameters() + ->willReturn($cat); $query = array('get' => 'c_1'); $user_query = new FreshRSS_UserQuery($query, null, $cat_dao); $this->assertEquals($category_name, $user_query->getGetName()); @@ -61,14 +61,14 @@ class UserQueryTest extends PHPUnit\Framework\TestCase { $feed_name = 'some feed name'; $feed = $this->getMock('FreshRSS_Feed', array(), array('', false)); $feed->expects($this->atLeastOnce()) - ->method('name') - ->withAnyParameters() - ->willReturn($feed_name); + ->method('name') + ->withAnyParameters() + ->willReturn($feed_name); $feed_dao = $this->getMock('FreshRSS_Searchable'); $feed_dao->expects($this->atLeastOnce()) - ->method('searchById') - ->withAnyParameters() - ->willReturn($feed); + ->method('searchById') + ->withAnyParameters() + ->willReturn($feed); $query = array('get' => 'f_1'); $user_query = new FreshRSS_UserQuery($query, $feed_dao, null); $this->assertEquals($feed_name, $user_query->getGetName()); @@ -118,12 +118,12 @@ class UserQueryTest extends PHPUnit\Framework\TestCase { public function testToArray_whenData_returnsArray() { $query = array( - 'get' => 's', - 'name' => 'some name', - 'order' => 'some order', - 'search' => 'some search', - 'state' => 'some state', - 'url' => 'some url', + 'get' => 's', + 'name' => 'some name', + 'order' => 'some order', + 'search' => 'some search', + 'state' => 'some state', + 'url' => 'some url', ); $user_query = new FreshRSS_UserQuery($query); $this->assertInternalType('array', $user_query->toArray()); @@ -133,7 +133,7 @@ class UserQueryTest extends PHPUnit\Framework\TestCase { public function testHasSearch_whenSearch_returnsTrue() { $query = array( - 'search' => 'some search', + 'search' => 'some search', ); $user_query = new FreshRSS_UserQuery($query); $this->assertTrue($user_query->hasSearch()); @@ -166,9 +166,9 @@ class UserQueryTest extends PHPUnit\Framework\TestCase { $cat = $this->getMock('FreshRSS_Category'); $cat_dao = $this->getMock('FreshRSS_Searchable'); $cat_dao->expects($this->atLeastOnce()) - ->method('searchById') - ->withAnyParameters() - ->willReturn($cat); + ->method('searchById') + ->withAnyParameters() + ->willReturn($cat); $query = array('get' => 'c_1'); $user_query = new FreshRSS_UserQuery($query, null, $cat_dao); $this->assertFalse($user_query->isDeprecated()); @@ -177,9 +177,9 @@ class UserQueryTest extends PHPUnit\Framework\TestCase { public function testIsDeprecated_whenCategoryDoesNotExist_returnTrue() { $cat_dao = $this->getMock('FreshRSS_Searchable'); $cat_dao->expects($this->atLeastOnce()) - ->method('searchById') - ->withAnyParameters() - ->willReturn(null); + ->method('searchById') + ->withAnyParameters() + ->willReturn(null); $query = array('get' => 'c_1'); $user_query = new FreshRSS_UserQuery($query, null, $cat_dao); $this->assertTrue($user_query->isDeprecated()); @@ -189,9 +189,9 @@ class UserQueryTest extends PHPUnit\Framework\TestCase { $feed = $this->getMock('FreshRSS_Feed', array(), array('', false)); $feed_dao = $this->getMock('FreshRSS_Searchable'); $feed_dao->expects($this->atLeastOnce()) - ->method('searchById') - ->withAnyParameters() - ->willReturn($feed); + ->method('searchById') + ->withAnyParameters() + ->willReturn($feed); $query = array('get' => 'f_1'); $user_query = new FreshRSS_UserQuery($query, $feed_dao, null); $this->assertFalse($user_query->isDeprecated()); @@ -200,9 +200,9 @@ class UserQueryTest extends PHPUnit\Framework\TestCase { public function testIsDeprecated_whenFeedDoesNotExist_returnTrue() { $feed_dao = $this->getMock('FreshRSS_Searchable'); $feed_dao->expects($this->atLeastOnce()) - ->method('searchById') - ->withAnyParameters() - ->willReturn(null); + ->method('searchById') + ->withAnyParameters() + ->willReturn(null); $query = array('get' => 'f_1'); $user_query = new FreshRSS_UserQuery($query, $feed_dao, null); $this->assertTrue($user_query->isDeprecated()); diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 24340b15c..896929649 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -4,4 +4,4 @@ error_reporting(E_ALL); ini_set('display_errors', 1); require('../constants.php'); -require(LIB_PATH . '/lib_rss.php'); //Includes class autoloader \ No newline at end of file +require(LIB_PATH . '/lib_rss.php'); //Includes class autoloader -- cgit v1.2.3