From afad1d11af812538fe01d274ac3b9311e033e5a6 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Tue, 5 Jun 2018 13:48:34 +0200 Subject: Fix type exception in loadCompleteContent (#1918) * Fix type exception in loadCompleteContent https://github.com/FreshRSS/FreshRSS/issues/1917 With some refactoring * Changelog 1917 https://github.com/FreshRSS/FreshRSS/issues/1917 https://github.com/FreshRSS/FreshRSS/pull/1918 --- lib/lib_rss.php | 62 --------------------------------------------------------- 1 file changed, 62 deletions(-) (limited to 'lib') diff --git a/lib/lib_rss.php b/lib/lib_rss.php index abb20f16a..04bbb2515 100644 --- a/lib/lib_rss.php +++ b/lib/lib_rss.php @@ -253,68 +253,6 @@ function sanitizeHTML($data, $base = '') { return html_only_entity_decode($simplePie->sanitize->sanitize($data, SIMPLEPIE_CONSTRUCT_HTML, $base)); } -/* permet de récupérer le contenu d'un article pour un flux qui n'est pas complet */ -function get_content_by_parsing($url, $path, $attributes = array()) { - require_once(LIB_PATH . '/lib_phpQuery.php'); - $system_conf = Minz_Configuration::get('system'); - $limits = $system_conf->limits; - $feed_timeout = empty($attributes['timeout']) ? 0 : intval($attributes['timeout']); - - if ($system_conf->simplepie_syslog_enabled) { - syslog(LOG_INFO, 'FreshRSS GET ' . SimplePie_Misc::url_remove_credentials($url)); - } - - $ch = curl_init(); - curl_setopt_array($ch, array( - CURLOPT_URL => $url, - CURLOPT_REFERER => SimplePie_Misc::url_remove_credentials($url), - CURLOPT_HTTPHEADER => array('Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'), - CURLOPT_USERAGENT => FRESHRSS_USERAGENT, - CURLOPT_CONNECTTIMEOUT => $feed_timeout > 0 ? $feed_timeout : $limits['timeout'], - CURLOPT_TIMEOUT => $feed_timeout > 0 ? $feed_timeout : $limits['timeout'], - //CURLOPT_FAILONERROR => true; - CURLOPT_MAXREDIRS => 4, - CURLOPT_RETURNTRANSFER => true, - )); - if (version_compare(PHP_VERSION, '5.6.0') >= 0 || ini_get('open_basedir') == '') { - curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); //Keep option separated for open_basedir PHP bug 65646 - } - if (defined('CURLOPT_ENCODING')) { - curl_setopt($ch, CURLOPT_ENCODING, ''); //Enable all encodings - } - curl_setopt_array($ch, $system_conf->curl_options); - if (isset($attributes['ssl_verify'])) { - curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, $attributes['ssl_verify'] ? 2 : 0); - curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, $attributes['ssl_verify'] ? true : false); - } - $html = curl_exec($ch); - $c_status = curl_getinfo($ch, CURLINFO_HTTP_CODE); - $c_error = curl_error($ch); - curl_close($ch); - - if ($c_status != 200 || $c_error != '') { - Minz_Log::warning('Error fetching content: HTTP code ' . $c_status . ': ' . $c_error . ' ' . $url); - } - - if ($html) { - $doc = phpQuery::newDocument($html); - $content = $doc->find($path); - - foreach (pq('img[data-src]') as $img) { - $imgP = pq($img); - $dataSrc = $imgP->attr('data-src'); - if (strlen($dataSrc) > 4) { - $imgP->attr('src', $dataSrc); - $imgP->removeAttr('data-src'); - } - } - - return sanitizeHTML($content->__toString(), $url); - } else { - throw new Exception(); - } -} - /** * Add support of image lazy loading * Move content from src attribute to data-original -- cgit v1.2.3 From 7ab4a2609a4db8babb968f79cc2832ec0a02ce09 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Wed, 6 Jun 2018 21:29:22 +0200 Subject: Support for media: tags (#1920) * Support for media: tags https://github.com/FreshRSS/FreshRSS/issues/944 E.g. YouTube * Fix for medium attribute * Changelog 944 https://github.com/FreshRSS/FreshRSS/issues/944 https://github.com/FreshRSS/FreshRSS/pull/1920 * enclosure styling * Compatibility old enclosure content --- CHANGELOG.md | 4 +++- app/Models/Feed.php | 42 +++++++++++++++++++++++++++++++--------- lib/SimplePie/SimplePie.php | 7 ++++++- p/themes/base-theme/template.css | 6 +++++- 4 files changed, 47 insertions(+), 12 deletions(-) (limited to 'lib') diff --git a/CHANGELOG.md b/CHANGELOG.md index c20d8146d..92f7e2dff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,9 @@ # FreshRSS changelog -## 2018-0X-XX FreshRSS 1.11.1-dev +## 2018-06-XX FreshRSS 1.11.1-dev +* Features + * Better support of `media:` tags such as thumbnails and descriptions (e.g. for YouTube) [#944](https://github.com/FreshRSS/FreshRSS/issues/944) * Bug fixing * Fix regression in fetching full articles content [#1917](https://github.com/FreshRSS/FreshRSS/issues/1917) * Updated sharing to Mastodon [#1904](https://github.com/FreshRSS/FreshRSS/issues/1904) diff --git a/app/Models/Feed.php b/app/Models/Feed.php index c8ccff09b..07a7a5459 100644 --- a/app/Models/Feed.php +++ b/app/Models/Feed.php @@ -359,21 +359,45 @@ class FreshRSS_Feed extends Minz_Model { foreach ($item->get_enclosures() as $enclosure) { $elink = $enclosure->get_link(); if ($elink != '' && empty($elinks[$elink])) { - $elinks[$elink] = '1'; + $content .= '
'; + + if ($enclosure->get_title() != '') { + $content .= '

' . $enclosure->get_title() . '

'; + } + + $enclosureContent = ''; + $elinks[$elink] = true; $mime = strtolower($enclosure->get_type()); - if (strpos($mime, 'image/') === 0) { - $content .= '

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

'; + } elseif ($medium === 'audio' || strpos($mime, 'audio/') === 0) { + $enclosureContent .= '

💾

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

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

💾

'; + } elseif ($medium != '' || strpos($mime, 'application/') === 0 || strpos($mime, 'text/') === 0) { + $enclosureContent .= '

💾

'; } else { unset($elinks[$elink]); } + + $thumbnailContent = ''; + foreach ($enclosure->get_thumbnails() as $thumbnail) { + if (empty($elinks[$thumbnail])) { + $elinks[$thumbnail] = true; + $thumbnailContent .= '

'; + } + } + + $content .= $thumbnailContent; + $content .= $enclosureContent; + + if ($enclosure->get_description() != '') { + $content .= '
' . $enclosure->get_description() . '
'; + } + $content .= "
\n"; } } diff --git a/lib/SimplePie/SimplePie.php b/lib/SimplePie/SimplePie.php index 5cd445b6d..b591bcddd 100644 --- a/lib/SimplePie/SimplePie.php +++ b/lib/SimplePie/SimplePie.php @@ -1322,7 +1322,12 @@ class SimplePie function cleanMd5($rss) { - return md5(preg_replace(array('#<(lastBuildDate|pubDate|updated|feedDate|dc:date|slash:comments)>[^<]+#', '##s'), '', $rss)); + return md5(preg_replace(array( + '#<(lastBuildDate|pubDate|updated|feedDate|dc:date|slash:comments)>[^<]+#', + '#<(media:starRating|media:statistics) [^/<>]+/>#', + '##s', + ), '', $rss)); + } /** diff --git a/p/themes/base-theme/template.css b/p/themes/base-theme/template.css index 72487ca17..9b8ad902b 100644 --- a/p/themes/base-theme/template.css +++ b/p/themes/base-theme/template.css @@ -832,11 +832,15 @@ input:checked + .slide-container .properties { display: none; } -.enclosure > [download] { +.enclosure [download] { font-size: xx-large; margin-left: .8em; } +pre.enclosure-description { + white-space: pre-line; +} + /*=== MOBILE */ /*===========*/ @media(max-width: 840px) { -- cgit v1.2.3 From 32676d59a386fe067ae0beac0287c700274f3d57 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sat, 9 Jun 2018 15:57:17 +0200 Subject: Minz fix translate (#1927) Fix https://github.com/FreshRSS/FreshRSS/issues/1797 --- lib/Minz/Translate.php | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) (limited to 'lib') diff --git a/lib/Minz/Translate.php b/lib/Minz/Translate.php index d9cd59f7e..db76e9214 100644 --- a/lib/Minz/Translate.php +++ b/lib/Minz/Translate.php @@ -64,12 +64,16 @@ class Minz_Translate { $list_langs = array(); foreach (self::$path_list as $path) { - $path_langs = array_values(array_diff( - scandir($path), - array('..', '.') - )); - - $list_langs = array_merge($list_langs, $path_langs); + $scan = scandir($path); + if (is_array($scan)) { + $path_langs = array_values(array_diff( + $scan, + array('..', '.') + )); + if (is_array($path_langs)) { + $list_langs = array_merge($list_langs, $path_langs); + } + } } return array_unique($list_langs); @@ -80,12 +84,10 @@ class Minz_Translate { * @param $path a path containing i18n directories (e.g. ./en/, ./fr/). */ public static function registerPath($path) { - if (in_array($path, self::$path_list)) { - return; + if (!in_array($path, self::$path_list) && is_dir($path)) { + self::$path_list[] = $path; + self::loadLang($path); } - - self::$path_list[] = $path; - self::loadLang($path); } /** @@ -94,7 +96,7 @@ class Minz_Translate { */ private static function loadLang($path) { $lang_path = $path . '/' . self::$lang_name; - if (!file_exists($lang_path) || is_null(self::$lang_name)) { + if (!file_exists($lang_path) || self::$lang_name == '') { // The lang path does not exist, nothing more to do. return; } -- cgit v1.2.3 From 6a56894e940db0b1f7ee6788fbc38f26c80d004d Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sat, 9 Jun 2018 15:58:18 +0200 Subject: New extension event + Tumblr GDPR (#1924) * New extension event + Tumblr GDPR https://github.com/FreshRSS/FreshRSS/issues/1894 simplepie_before_init event * Refactor extension enabling + Tumblr GDPR enabled by default Add possibility for extensions to be enabled by default, and disabled back by users. * Minor whitespace --- app/Controllers/extensionController.php | 8 ++++++-- app/Models/Feed.php | 1 + config.default.php | 4 +++- docs/en/developers/03_Backend/05_Extensions.md | 1 + docs/en/users/06_Fever_API.md | 2 +- docs/fr/developers/03_Backend/05_Extensions.md | 1 + extensions/Tumblr-GDPR/README.md | 4 ++++ extensions/Tumblr-GDPR/extension.php | 13 +++++++++++++ extensions/Tumblr-GDPR/metadata.json | 8 ++++++++ lib/Minz/Configuration.php | 14 +++++++------- lib/Minz/ExtensionManager.php | 26 ++++++++++++++++++++------ lib/lib_rss.php | 24 ------------------------ 12 files changed, 65 insertions(+), 41 deletions(-) create mode 100644 extensions/Tumblr-GDPR/README.md create mode 100644 extensions/Tumblr-GDPR/extension.php create mode 100644 extensions/Tumblr-GDPR/metadata.json (limited to 'lib') diff --git a/app/Controllers/extensionController.php b/app/Controllers/extensionController.php index 311fd2e96..806e5a696 100644 --- a/app/Controllers/extensionController.php +++ b/app/Controllers/extensionController.php @@ -140,7 +140,7 @@ class FreshRSS_extension_Controller extends Minz_ActionController { if ($res === true) { $ext_list = $conf->extensions_enabled; - array_push_unique($ext_list, $ext_name); + $ext_list[$ext_name] = true; $conf->extensions_enabled = $ext_list; $conf->save(); @@ -196,7 +196,11 @@ class FreshRSS_extension_Controller extends Minz_ActionController { if ($res === true) { $ext_list = $conf->extensions_enabled; - array_remove($ext_list, $ext_name); + $legacyKey = array_search($ext_name, $ext_list, true); + if ($legacyKey !== false) { //Legacy format FreshRSS < 1.11.1 + unset($ext_list[$legacyKey]); + } + $ext_list[$ext_name] = false; $conf->extensions_enabled = $ext_list; $conf->save(); diff --git a/app/Models/Feed.php b/app/Models/Feed.php index 07a7a5459..cc2196dac 100644 --- a/app/Models/Feed.php +++ b/app/Models/Feed.php @@ -286,6 +286,7 @@ class FreshRSS_Feed extends Minz_Model { if (!$loadDetails) { //Only activates auto-discovery when adding a new feed $feed->set_autodiscovery_level(SIMPLEPIE_LOCATOR_NONE); } + Minz_ExtensionManager::callHook('simplepie_before_init', $feed, $this); $mtime = $feed->init(); if ((!$mtime) || $feed->error()) { diff --git a/config.default.php b/config.default.php index e6297a160..5b993f9e5 100644 --- a/config.default.php +++ b/config.default.php @@ -145,7 +145,9 @@ return array( ), # List of enabled FreshRSS extensions. - 'extensions_enabled' => array(), + 'extensions_enabled' => array( + 'Tumblr-GDPR' => true, + ), # Disable self-update, 'disable_update' => false, diff --git a/docs/en/developers/03_Backend/05_Extensions.md b/docs/en/developers/03_Backend/05_Extensions.md index 034328e07..ae304f6e0 100644 --- a/docs/en/developers/03_Backend/05_Extensions.md +++ b/docs/en/developers/03_Backend/05_Extensions.md @@ -366,6 +366,7 @@ The following events are available: - `entry_before_insert` (`function($entry) -> Entry | null`) : will be executed when a feed is refreshed and new entries will be imported into the database. The new entry (instance of FreshRSS_Entry) will be passed as parameter. - `feed_before_insert` (`function($feed) -> Feed | null`) : will be executed when a new feed is imported into the database. The new feed (instance of FreshRSS_Feed) will be passed as parameter. - `post_update` (`function(none) -> none`) : **TODO** add documentation +- `simplepie_before_init` (`function($simplePie, $feed) -> none`) : **TODO** add documentation ### Writing your own configure.phtml diff --git a/docs/en/users/06_Fever_API.md b/docs/en/users/06_Fever_API.md index 6d8a103b9..7d2af8b02 100644 --- a/docs/en/users/06_Fever_API.md +++ b/docs/en/users/06_Fever_API.md @@ -43,7 +43,7 @@ Following features are implemented: - setting starred marker for item(s) - setting read marker for feed - setting read marker for category -- supports FreshRSS extensions, which use th `entry_before_display` hook +- supports FreshRSS extensions, which use the `entry_before_display` hook Following features are not supported: - **Hot Links** aka **hot** as there is nothing in FreshRSS yet that is similar or could be used to simulate it diff --git a/docs/fr/developers/03_Backend/05_Extensions.md b/docs/fr/developers/03_Backend/05_Extensions.md index f844accd1..2ee81b781 100644 --- a/docs/fr/developers/03_Backend/05_Extensions.md +++ b/docs/fr/developers/03_Backend/05_Extensions.md @@ -329,6 +329,7 @@ TODO : - `entry_before_insert` (`function($entry) -> Entry | null`) - `feed_before_insert` (`function($feed) -> Feed | null`) - `post_update` (`function(none) -> none`) +- `simplepie_before_init` (`function($simplePie, $feed) -> none`) ### Écrire le fichier configure.phtml diff --git a/extensions/Tumblr-GDPR/README.md b/extensions/Tumblr-GDPR/README.md new file mode 100644 index 000000000..fc5e4dd50 --- /dev/null +++ b/extensions/Tumblr-GDPR/README.md @@ -0,0 +1,4 @@ +# Tumblr-GDPR + +Needed for accessing [Tumblr](https://www.tumblr.com/) RSS feeds from the European Union: +bypass the [GPDR](https://en.wikipedia.org/wiki/General_Data_Protection_Regulation) check, implying consent. diff --git a/extensions/Tumblr-GDPR/extension.php b/extensions/Tumblr-GDPR/extension.php new file mode 100644 index 000000000..7a7708c9f --- /dev/null +++ b/extensions/Tumblr-GDPR/extension.php @@ -0,0 +1,13 @@ +registerHook('simplepie_before_init', array('TumblrGdprExtension', 'curlHook')); + } + + public static function curlHook($simplePie, $feed) { + if (preg_match('#^https?://[a-zA-Z_0-9-]+.tumblr.com/#i', $feed->url())) { + $simplePie->set_useragent(FRESHRSS_USERAGENT . ' like Googlebot'); + } + } +} diff --git a/extensions/Tumblr-GDPR/metadata.json b/extensions/Tumblr-GDPR/metadata.json new file mode 100644 index 000000000..b5c33787b --- /dev/null +++ b/extensions/Tumblr-GDPR/metadata.json @@ -0,0 +1,8 @@ +{ + "name": "Tumblr-GDPR", + "author": "Alkarex", + "description": "Bypass Tumblr’ GPDR check (implying consent) for the European Union", + "version": 1.0, + "entrypoint": "TumblrGdpr", + "type": "system" +} diff --git a/lib/Minz/Configuration.php b/lib/Minz/Configuration.php index 5470dc85f..3e486d68e 100644 --- a/lib/Minz/Configuration.php +++ b/lib/Minz/Configuration.php @@ -90,15 +90,15 @@ class Minz_Configuration { private $configuration_setter = null; public function removeExtension($ext_name) { - self::$extensions_enabled = array_diff( - self::$extensions_enabled, - array($ext_name) - ); + unset(self::$extensions_enabled[$ext_name]); + $legacyKey = array_search($ext_name, self::$extensions_enabled, true); + if ($legacyKey !== false) { //Legacy format FreshRSS < 1.11.1 + unset(self::$extensions_enabled[$legacyKey]); + } } public function addExtension($ext_name) { - $found = array_search($ext_name, self::$extensions_enabled) !== false; - if (!$found) { - self::$extensions_enabled[] = $ext_name; + if (!isset(self::$extensions_enabled[$ext_name])) { + self::$extensions_enabled[$ext_name] = true; } } diff --git a/lib/Minz/ExtensionManager.php b/lib/Minz/ExtensionManager.php index 10c49a8b6..3914217ac 100644 --- a/lib/Minz/ExtensionManager.php +++ b/lib/Minz/ExtensionManager.php @@ -35,6 +35,10 @@ class Minz_ExtensionManager { 'list' => array(), 'signature' => 'OneToOne', ), + 'simplepie_before_init' => array( // function($simplePie, $feed) -> none + 'list' => array(), + 'signature' => 'PassArguments', + ), ); private static $ext_to_hooks = array(); @@ -160,7 +164,8 @@ class Minz_ExtensionManager { self::$ext_list[$name] = $ext; if ($ext->getType() === 'system' && - in_array($name, self::$ext_auto_enabled)) { + (!empty(self::$ext_auto_enabled[$name]) || + in_array($name, self::$ext_auto_enabled, true))) { //Legacy format < FreshRSS 1.11.1 self::enable($ext->getName()); } @@ -189,8 +194,12 @@ class Minz_ExtensionManager { * @param string[] $ext_list the names of extensions we want to load. */ public static function enableByList($ext_list) { - foreach ($ext_list as $ext_name) { - self::enable($ext_name); + foreach ($ext_list as $ext_name => $ext_status) { + if (is_int($ext_name)) { //Legacy format int=>name + self::enable($ext_status); + } elseif ($ext_status) { //New format name=>Boolean + self::enable($ext_name); + } } } @@ -255,10 +264,15 @@ class Minz_ExtensionManager { } $signature = self::$hook_list[$hook_name]['signature']; - $signature = 'self::call' . $signature; $args = func_get_args(); - - return call_user_func_array($signature, $args); + if ($signature === 'PassArguments') { + array_shift($args); + foreach (self::$hook_list[$hook_name]['list'] as $function) { + call_user_func_array($function, $args); + } + } else { + return call_user_func_array('self::call' . $signature, $args); + } } /** diff --git a/lib/lib_rss.php b/lib/lib_rss.php index 04bbb2515..5f460862e 100644 --- a/lib/lib_rss.php +++ b/lib/lib_rss.php @@ -480,7 +480,6 @@ function recursive_unlink($dir) { return rmdir($dir); } - /** * Remove queries where $get is appearing. * @param $get the get attribute which should be removed. @@ -497,29 +496,6 @@ function remove_query_by_get($get, $queries) { return $final_queries; } - -/** - * Add a value in an array and take care it is unique. - * @param $array the array in which we add the value. - * @param $value the value to add. - */ -function array_push_unique(&$array, $value) { - $found = array_search($value, $array) !== false; - if (!$found) { - $array[] = $value; - } -} - - -/** - * Remove a value from an array. - * @param $array the array from wich value is removed. - * @param $value the value to remove. - */ -function array_remove(&$array, $value) { - $array = array_diff($array, array($value)); -} - //RFC 4648 function base64url_encode($data) { return strtr(rtrim(base64_encode($data), '='), '+/', '-_'); -- cgit v1.2.3 From 031acde003b85ae34a4996d0c02fdc41ffae5515 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Wed, 13 Jun 2018 09:27:02 +0200 Subject: Fix extension hook for updated articles (#1932) * Fix extension hook for updated articles https://github.com/FreshRSS/FreshRSS/issues/1926 * Enable extensions during PubSubHubbub * A little array protection * Changelog 1926 https://github.com/FreshRSS/FreshRSS/issues/1926 https://github.com/FreshRSS/FreshRSS/pull/1932 * Add null check --- CHANGELOG.md | 1 + app/Controllers/feedController.php | 9 ++++++++- lib/Minz/ExtensionManager.php | 3 +++ p/api/pshb.php | 6 ++++++ 4 files changed, 18 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/CHANGELOG.md b/CHANGELOG.md index 30779d42f..0ffd9c373 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ * Built-in extension to fix Tumblr feeds from European Union due to GDPR [#1894](https://github.com/FreshRSS/FreshRSS/issues/1894) * Bug fixing * Fix bug in case of bad i18n in extensions [#1797](https://github.com/FreshRSS/FreshRSS/issues/1797) + * Fix extension callback for updated articles and PubSubHubbub [#1926](https://github.com/FreshRSS/FreshRSS/issues/1926) * Fix regression in fetching full articles content [#1917](https://github.com/FreshRSS/FreshRSS/issues/1917) * Fix several bugs in the new Fever API [#1930](https://github.com/FreshRSS/FreshRSS/issues/1930) * Updated sharing to Mastodon [#1904](https://github.com/FreshRSS/FreshRSS/issues/1904) diff --git a/app/Controllers/feedController.php b/app/Controllers/feedController.php index ca85e7cb8..ec88156f9 100755 --- a/app/Controllers/feedController.php +++ b/app/Controllers/feedController.php @@ -351,13 +351,20 @@ class FreshRSS_feed_Controller extends Minz_ActionController { //This entry already exists and is unchanged. TODO: Remove the test with the zero'ed hash in FreshRSS v1.3 $oldGuids[] = $entry->guid(); } else { //This entry already exists but has been updated - //Minz_Log::debug('Entry with GUID `' . $entry->guid() . '` updated in feed ' . $feed->id() . + //Minz_Log::debug('Entry with GUID `' . $entry->guid() . '` updated in feed ' . $feed->url() . //', old hash ' . $existingHash . ', new hash ' . $entry->hash()); $mark_updated_article_unread = $feed->attributes('mark_updated_article_unread') !== null ? ( $feed->attributes('mark_updated_article_unread') ) : FreshRSS_Context::$user_conf->mark_updated_article_unread; $needFeedCacheRefresh = $mark_updated_article_unread; $entry->_isRead(FreshRSS_Context::$user_conf->mark_updated_article_unread ? false : null); //Change is_read according to policy. + + $entry = Minz_ExtensionManager::callHook('entry_before_insert', $entry); + if ($entry === null) { + // An extension has returned a null value, there is nothing to insert. + continue; + } + if (!$entryDAO->inTransaction()) { $entryDAO->beginTransaction(); } diff --git a/lib/Minz/ExtensionManager.php b/lib/Minz/ExtensionManager.php index 3914217ac..b086c4001 100644 --- a/lib/Minz/ExtensionManager.php +++ b/lib/Minz/ExtensionManager.php @@ -194,6 +194,9 @@ class Minz_ExtensionManager { * @param string[] $ext_list the names of extensions we want to load. */ public static function enableByList($ext_list) { + if (!is_array($ext_list)) { + return; + } foreach ($ext_list as $ext_name => $ext_status) { if (is_int($ext_name)) { //Legacy format int=>name self::enable($ext_status); diff --git a/p/api/pshb.php b/p/api/pshb.php index 57a7bb0dd..ac78bfd74 100644 --- a/p/api/pshb.php +++ b/p/api/pshb.php @@ -116,6 +116,8 @@ if ($self !== base64url_decode($canonical64)) { $self = base64url_decode($canonical64); } +Minz_ExtensionManager::init(); + $nb = 0; foreach ($users as $userFilename) { $username = basename($userFilename, '.txt'); @@ -132,6 +134,10 @@ foreach ($users as $userFilename) { join_path(FRESHRSS_PATH, 'config-user.default.php')); new Minz_ModelPdo($username); //TODO: FIXME: Quick-fix while waiting for a better FreshRSS() constructor/init FreshRSS_Context::init(); + if (FreshRSS_Context::$user_conf != null) { + Minz_ExtensionManager::enableByList(FreshRSS_Context::$user_conf->extensions_enabled); + } + list($updated_feeds, $feed, $nb_new_articles) = FreshRSS_feed_Controller::actualizeFeed(0, $self, false, $simplePie); if ($updated_feeds > 0 || $feed != false) { $nb++; -- cgit v1.2.3