aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2017-04-10 19:46:22 +0200
committerGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2017-04-10 19:46:22 +0200
commit510045b3c554261a0a6434bfe73adac32b12cc81 (patch)
treecc0907d84ec5ad72baed8e0fb6fe7d81176bbb3c
parent8854f230866f458382f6dc207f706220e9c32351 (diff)
parente849de7296efbece490447cdceeed9726f10b33c (diff)
Merge branch 'FreshRSS/dev' into multiuser-token
-rw-r--r--CHANGELOG.md2
-rw-r--r--app/Controllers/userController.php1
-rw-r--r--app/Models/Feed.php15
-rw-r--r--app/SQL/install.sql.mysql.php2
-rw-r--r--app/SQL/install.sql.pgsql.php2
-rw-r--r--app/SQL/install.sql.sqlite.php2
-rw-r--r--app/i18n/en/gen.php2
-rw-r--r--app/install.php2
-rw-r--r--lib/Favicon/Favicon.php14
-rw-r--r--lib/lib_install.php2
-rw-r--r--p/api/pshb.php39
11 files changed, 56 insertions, 27 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index d4bb4a5b2..504886a23 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -13,8 +13,10 @@
* Add support for PHP 7.1 [#1471](https://github.com/FreshRSS/FreshRSS/issues/1471)
* PostgreSQL is not experimental anymore [#1476](https://github.com/FreshRSS/FreshRSS/pull/1476)
* Bug fixing
+ * Fix PubSubHubbub bugs when deleting users, and improved behaviour when removing feeds [#1495](https://github.com/FreshRSS/FreshRSS/pull/1495)
* Fix SQL uniqueness bug with PostgreSQL [#1476](https://github.com/FreshRSS/FreshRSS/pull/1476)
* (Require manual update for existing installations)
+ * Do not require PHP extension `fileinfo` for favicons [#1461](https://github.com/FreshRSS/FreshRSS/issues/1461)
* Fix UI lowest subscription popup hidden [#1479](https://github.com/FreshRSS/FreshRSS/issues/1479)
* I18n
* Improve English [#1465](https://github.com/FreshRSS/FreshRSS/pull/1465)
diff --git a/app/Controllers/userController.php b/app/Controllers/userController.php
index ee575fa09..ed30eb69f 100644
--- a/app/Controllers/userController.php
+++ b/app/Controllers/userController.php
@@ -217,6 +217,7 @@ class FreshRSS_user_Controller extends Minz_ActionController {
$userDAO = new FreshRSS_UserDAO();
$ok &= $userDAO->deleteUser($username);
$ok &= recursive_unlink($user_data);
+ array_map('unlink', glob(PSHB_PATH . '/feeds/*/' . $username . '.txt'));
}
return $ok;
}
diff --git a/app/Models/Feed.php b/app/Models/Feed.php
index 7a9cf8612..1bc6e48e8 100644
--- a/app/Models/Feed.php
+++ b/app/Models/Feed.php
@@ -429,7 +429,7 @@ class FreshRSS_Feed extends Minz_Model {
}
} else {
@mkdir($path, 0777, true);
- $key = sha1($path . FreshRSS_Context::$system_conf->salt . uniqid(mt_rand(), true));
+ $key = sha1($path . FreshRSS_Context::$system_conf->salt);
$hubJson = array(
'hub' => $this->hubUrl,
'key' => $key,
@@ -451,15 +451,16 @@ class FreshRSS_Feed extends Minz_Model {
//Parameter true to subscribe, false to unsubscribe.
function pubSubHubbubSubscribe($state) {
- if (FreshRSS_Context::$system_conf->base_url && $this->hubUrl && $this->selfUrl) {
- $hubFilename = PSHB_PATH . '/feeds/' . base64url_encode($this->selfUrl) . '/!hub.json';
+ $url = $this->selfUrl ? $this->selfUrl : $this->url;
+ if (FreshRSS_Context::$system_conf->base_url && $url) {
+ $hubFilename = PSHB_PATH . '/feeds/' . base64url_encode($url) . '/!hub.json';
$hubFile = @file_get_contents($hubFilename);
if ($hubFile === false) {
Minz_Log::warning('JSON not found for PubSubHubbub: ' . $this->url);
return false;
}
$hubJson = json_decode($hubFile, true);
- if (!$hubJson || empty($hubJson['key']) || !ctype_xdigit($hubJson['key'])) {
+ if (!$hubJson || empty($hubJson['key']) || !ctype_xdigit($hubJson['key']) || empty($hubJson['hub'])) {
Minz_Log::warning('Invalid JSON for PubSubHubbub: ' . $this->url);
return false;
}
@@ -474,13 +475,13 @@ class FreshRSS_Feed extends Minz_Model {
}
$ch = curl_init();
curl_setopt_array($ch, array(
- CURLOPT_URL => $this->hubUrl,
+ CURLOPT_URL => $hubJson['hub'],
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($this->selfUrl)
+ . '&hub.topic=' . urlencode($url)
. '&hub.callback=' . urlencode($callbackUrl)
)
);
@@ -488,7 +489,7 @@ class FreshRSS_Feed extends Minz_Model {
$info = curl_getinfo($ch);
file_put_contents(USERS_PATH . '/_/log_pshb.txt', date('c') . "\t" .
- 'PubSubHubbub ' . ($state ? 'subscribe' : 'unsubscribe') . ' to ' . $this->selfUrl .
+ 'PubSubHubbub ' . ($state ? 'subscribe' : 'unsubscribe') . ' to ' . $url .
' with callback ' . $callbackUrl . ': ' . $info['http_code'] . ' ' . $response . "\n", FILE_APPEND);
if (substr($info['http_code'], 0, 1) == '2') {
diff --git a/app/SQL/install.sql.mysql.php b/app/SQL/install.sql.mysql.php
index 6b07f5965..09defd452 100644
--- a/app/SQL/install.sql.mysql.php
+++ b/app/SQL/install.sql.mysql.php
@@ -92,7 +92,7 @@ INSERT IGNORE INTO `%1$sfeed` (url, category, name, website, description, ttl) V
INSERT IGNORE INTO `%1$sfeed` (url, category, name, website, description, ttl) VALUES("https://github.com/FreshRSS/FreshRSS/releases.atom", 1, "FreshRSS @ GitHub", "https://github.com/FreshRSS/FreshRSS/", "FreshRSS releases @ GitHub", 86400);
');
-define('SQL_DROP_TABLES', 'DROP TABLE IF EXISTS `%1$sentry`, `%1$sfeed`, `%1$scategory`');
+define('SQL_DROP_TABLES', 'DROP TABLE IF EXISTS `%1$sentrytmp`, `%1$sentry`, `%1$sfeed`, `%1$scategory`');
define('SQL_UPDATE_UTF8MB4', '
ALTER DATABASE `%2$s` CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
diff --git a/app/SQL/install.sql.pgsql.php b/app/SQL/install.sql.pgsql.php
index 74c6d1b79..4cfeb2517 100644
--- a/app/SQL/install.sql.pgsql.php
+++ b/app/SQL/install.sql.pgsql.php
@@ -84,4 +84,4 @@ $SQL_INSERT_FEEDS = array(
'INSERT INTO "%1$sfeed" (url, category, name, website, description, ttl) SELECT \'https://github.com/FreshRSS/FreshRSS/releases.atom\', 1, \'FreshRSS @ GitHub\', \'https://github.com/FreshRSS/FreshRSS/\', \'FreshRSS releases @ GitHub\', 86400 WHERE NOT EXISTS (SELECT id FROM "%1$sfeed" WHERE url = \'https://github.com/FreshRSS/FreshRSS/releases.atom\');',
);
-define('SQL_DROP_TABLES', 'DROP TABLE IF EXISTS "%1$sentry", "%1$sfeed", "%1$scategory"');
+define('SQL_DROP_TABLES', 'DROP TABLE IF EXISTS "%1$sentrytmp", "%1$sentry", "%1$sfeed", "%1$scategory"');
diff --git a/app/SQL/install.sql.sqlite.php b/app/SQL/install.sql.sqlite.php
index bce9f5a95..c4e4af006 100644
--- a/app/SQL/install.sql.sqlite.php
+++ b/app/SQL/install.sql.sqlite.php
@@ -86,4 +86,4 @@ $SQL_INSERT_FEEDS = array(
'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 entry, feed, category');
+define('SQL_DROP_TABLES', 'DROP TABLE IF EXISTS `entrytmp`, `entry`, `feed`, `category`');
diff --git a/app/i18n/en/gen.php b/app/i18n/en/gen.php
index d6ae266b7..a502e829a 100644
--- a/app/i18n/en/gen.php
+++ b/app/i18n/en/gen.php
@@ -2,7 +2,7 @@
return array(
'action' => array(
- 'actualize' => 'Updating',
+ 'actualize' => 'Actualize',
'back_to_rss_feeds' => '← Go back to your RSS feeds',
'cancel' => 'Cancel',
'create' => 'Create',
diff --git a/app/install.php b/app/install.php
index f598f6528..ebfffa47d 100644
--- a/app/install.php
+++ b/app/install.php
@@ -465,7 +465,7 @@ function printStep1() {
<?php if ($res['fileinfo'] == 'ok') { ?>
<p class="alert alert-success"><span class="alert-head"><?php echo _t('gen.short.ok'); ?></span> <?php echo _t('install.check.fileinfo.ok'); ?></p>
<?php } else { ?>
- <p class="alert alert-error"><span class="alert-head"><?php echo _t('gen.short.damn'); ?></span> <?php echo _t('install.check.fileinfo.nok'); ?></p>
+ <p class="alert alert-warn"><span class="alert-head"><?php echo _t('gen.short.damn'); ?></span> <?php echo _t('install.check.fileinfo.nok'); ?></p>
<?php } ?>
<?php if ($res['data'] == 'ok') { ?>
diff --git a/lib/Favicon/Favicon.php b/lib/Favicon/Favicon.php
index 8571a1b95..85d2ef19b 100644
--- a/lib/Favicon/Favicon.php
+++ b/lib/Favicon/Favicon.php
@@ -179,7 +179,7 @@ class Favicon
// Sometimes people lie, so check the status.
// And sometimes, it's not even an image. Sneaky bastards!
// If cacheDir isn't writable, that's not our problem
- if ($favicon && is_writable($this->cacheDir) && !$this->checkImageMType($favicon)) {
+ if ($favicon && is_writable($this->cacheDir) && extension_loaded('fileinfo') && !$this->checkImageMType($favicon)) {
$favicon = false;
}
@@ -229,10 +229,14 @@ class Favicon
$fileContent = $this->dataAccess->retrieveUrl($url);
$this->dataAccess->saveCache($tmpFile, $fileContent);
- $finfo = finfo_open(FILEINFO_MIME_TYPE);
- $isImage = strpos(finfo_file($finfo, $tmpFile), 'image') !== false;
- finfo_close($finfo);
-
+ $isImage = true;
+ try {
+ $finfo = finfo_open(FILEINFO_MIME_TYPE);
+ $isImage = strpos(finfo_file($finfo, $tmpFile), 'image') !== false;
+ finfo_close($finfo);
+ } catch (Exception $e) {
+ }
+
unlink($tmpFile);
return $isImage;
diff --git a/lib/lib_install.php b/lib/lib_install.php
index 76871c98a..c625a670a 100644
--- a/lib/lib_install.php
+++ b/lib/lib_install.php
@@ -67,7 +67,7 @@ function checkRequirements($dbType = '') {
'favicons' => $favicons ? 'ok' : 'ko',
'http_referer' => $http_referer ? 'ok' : 'ko',
'message' => $message ?: 'ok',
- 'all' => $php && $minz && $curl && $pdo && $pcre && $ctype && $fileinfo && $dom && $xml &&
+ 'all' => $php && $minz && $curl && $pdo && $pcre && $ctype && $dom && $xml &&
$data && $cache && $users && $favicons && $http_referer && $message == '' ?
'ok' : 'ko'
);
diff --git a/p/api/pshb.php b/p/api/pshb.php
index e9b66b167..378f43516 100644
--- a/p/api/pshb.php
+++ b/p/api/pshb.php
@@ -23,8 +23,13 @@ if (!ctype_xdigit($key)) {
chdir(PSHB_PATH);
$canonical64 = @file_get_contents('keys/' . $key . '.txt');
if ($canonical64 === false) {
+ if (!empty($_REQUEST['hub_mode']) && $_REQUEST['hub_mode'] === 'unsubscribe') {
+ logMe('Warning: Accept unknown unsubscribe');
+ header('Connection: close');
+ exit(isset($_REQUEST['hub_challenge']) ? $_REQUEST['hub_challenge'] : '');
+ }
header('HTTP/1.1 404 Not Found');
- logMe('Error: Feed key not found!: ' . $key);
+ logMe('Warning: Feed key not found!: ' . $key);
die('Feed key not found!');
}
$canonical64 = trim($canonical64);
@@ -36,7 +41,7 @@ if (!preg_match('/^[A-Za-z0-9_-]+$/D', $canonical64)) {
$hubFile = @file_get_contents('feeds/' . $canonical64 . '/!hub.json');
if ($hubFile === false) {
header('HTTP/1.1 404 Not Found');
- //@unlink('keys/' . $key . '.txt');
+ unlink('keys/' . $key . '.txt');
logMe('Error: Feed info not found!: ' . $canonical64);
die('Feed info not found!');
}
@@ -50,8 +55,19 @@ chdir('feeds/' . $canonical64);
$users = glob('*.txt', GLOB_NOSORT);
if (empty($users)) {
header('HTTP/1.1 410 Gone');
- logMe('Error: Nobody is subscribed to this feed anymore!: ' . $canonical64);
- die('Nobody is subscribed to this feed anymore!');
+ $url = base64url_decode($canonical64);
+ logMe('Warning: Nobody subscribes to this feed anymore!: ' . $url);
+ unlink('../../keys/' . $key . '.txt');
+ Minz_Configuration::register('system',
+ DATA_PATH . '/config.php',
+ DATA_PATH . '/config.default.php');
+ FreshRSS_Context::$system_conf = Minz_Configuration::get('system');
+ $feed = new FreshRSS_Feed($url);
+ $feed->pubSubHubbubSubscribe(false);
+ unlink('!hub.json');
+ chdir('..');
+ recursive_unlink($canonical64);
+ die('Nobody subscribes to this feed anymore!');
}
if (!empty($_REQUEST['hub_mode']) && $_REQUEST['hub_mode'] === 'subscribe') {
@@ -108,7 +124,9 @@ $nb = 0;
foreach ($users as $userFilename) {
$username = basename($userFilename, '.txt');
if (!file_exists(USERS_PATH . '/' . $username . '/config.php')) {
- break;
+ logMe('Warning: Removing broken user link: ' . $username . ' for ' . $self);
+ unlink($userFilename);
+ continue;
}
try {
@@ -119,11 +137,14 @@ foreach ($users as $userFilename) {
new Minz_ModelPdo($username); //TODO: FIXME: Quick-fix while waiting for a better FreshRSS() constructor/init
FreshRSS_Context::init();
list($updated_feeds, $feed) = FreshRSS_feed_Controller::actualizeFeed(0, $self, false, $simplePie);
- if ($updated_feeds > 0) {
+ if ($updated_feeds > 0 || $feed != false) {
$nb++;
+ } else {
+ logMe('Warning: User ' . $username . ' does not subscribe anymore to ' . $self);
+ unlink($userFilename);
}
} catch (Exception $e) {
- logMe('Error: ' . $e->getMessage());
+ logMe('Error: ' . $e->getMessage() . ' for user ' . $username . ' and feed ' . $self);
}
}
@@ -132,8 +153,8 @@ unset($simplePie);
if ($nb === 0) {
header('HTTP/1.1 410 Gone');
- logMe('Error: Nobody is subscribed to this feed anymore after all!: ' . $self);
- die('Nobody is subscribed to this feed anymore after all!');
+ logMe('Warning: Nobody subscribes to this feed anymore after all!: ' . $self);
+ die('Nobody subscribes to this feed anymore after all!');
} elseif (!empty($hubJson['error'])) {
$hubJson['error'] = false;
file_put_contents('./!hub.json', json_encode($hubJson));