aboutsummaryrefslogtreecommitdiff
path: root/app/Models/Feed.php
diff options
context:
space:
mode:
Diffstat (limited to 'app/Models/Feed.php')
-rw-r--r--app/Models/Feed.php15
1 files changed, 8 insertions, 7 deletions
diff --git a/app/Models/Feed.php b/app/Models/Feed.php
index 841749312..645dbcf3c 100644
--- a/app/Models/Feed.php
+++ b/app/Models/Feed.php
@@ -122,13 +122,13 @@ class FreshRSS_Feed extends Minz_Model {
}
/**
- * @return array<FreshRSS_Entry>|null
+ * @return list<FreshRSS_Entry>|null
* @deprecated
*/
public function entries(): ?array {
- Minz_Log::warning(__method__ . ' is deprecated since FreshRSS 1.16.1!');
+ Minz_Log::warning(__METHOD__ . ' is deprecated since FreshRSS 1.16.1!');
$simplePie = $this->load(false, true);
- return $simplePie == null ? [] : iterator_to_array($this->loadEntries($simplePie));
+ return $simplePie == null ? [] : array_values(iterator_to_array($this->loadEntries($simplePie)));
}
public function name(bool $raw = false): string {
return $raw || $this->name != '' ? $this->name : (preg_replace('%^https?://(www[.])?%i', '', $this->url) ?? '');
@@ -479,7 +479,7 @@ class FreshRSS_Feed extends Minz_Model {
* @param float $invalidGuidsTolerance (default 0.05) The maximum ratio (rounded) of invalid GUIDs to tolerate before degrading the unicity criteria.
* Example for 0.05 (5% rounded): tolerate 0 invalid GUIDs for up to 9 articles, 1 for 10, 2 for 30, 3 for 50, 4 for 70, 5 for 90, 6 for 110, etc.
* The default value of 5% rounded was chosen to allow 1 invalid GUID for feeds of 10 articles, which is a frequently observed amount of articles.
- * @return array<string>
+ * @return list<string>
*/
public function loadGuids(\SimplePie\SimplePie $simplePie, float $invalidGuidsTolerance = 0.05): array {
$invalidGuids = 0;
@@ -1077,13 +1077,13 @@ class FreshRSS_Feed extends Minz_Model {
$hubFilename = $path . '/!hub.json';
if (($hubFile = @file_get_contents($hubFilename)) != false) {
$hubJson = json_decode($hubFile, true);
- if (!is_array($hubJson) || empty($hubJson['key']) || !ctype_xdigit($hubJson['key'])) {
+ if (!is_array($hubJson) || empty($hubJson['key']) || !is_string($hubJson['key']) || !ctype_xdigit($hubJson['key'])) {
$text = 'Invalid JSON for WebSub: ' . $this->url;
Minz_Log::warning($text);
Minz_Log::warning($text, PSHB_LOG);
return false;
}
- if ((!empty($hubJson['lease_end'])) && ($hubJson['lease_end'] < (time() + (3600 * 23)))) { //TODO: Make a better policy
+ if (!empty($hubJson['lease_end']) && is_int($hubJson['lease_end']) && $hubJson['lease_end'] < (time() + (3600 * 23))) { //TODO: Make a better policy
$text = 'WebSub lease ends at '
. date('c', empty($hubJson['lease_end']) ? time() : $hubJson['lease_end'])
. ' and needs renewal: ' . $this->url;
@@ -1131,7 +1131,8 @@ class FreshRSS_Feed extends Minz_Model {
return false;
}
$hubJson = json_decode($hubFile, true);
- if (!is_array($hubJson) || empty($hubJson['key']) || !ctype_xdigit($hubJson['key']) || empty($hubJson['hub'])) {
+ if (!is_array($hubJson) || empty($hubJson['key']) || !is_string($hubJson['key']) || !ctype_xdigit($hubJson['key']) ||
+ empty($hubJson['hub']) || !is_string($hubJson['hub'])) {
Minz_Log::warning('Invalid JSON for WebSub: ' . $this->url);
return false;
}