Browse Source

Hot fix: fix type hint null regression (#4207)

Alexandre Alapetite 4 years ago
parent
commit
946b0a0876
2 changed files with 9 additions and 6 deletions
  1. 5 5
      app/Models/Feed.php
  2. 4 1
      lib/lib_rss.php

+ 5 - 5
app/Models/Feed.php

@@ -33,7 +33,7 @@ class FreshRSS_Feed extends Minz_Model {
 	private $ttl = self::TTL_DEFAULT;
 	private $attributes = [];
 	private $mute = false;
-	private $hash = null;
+	private $hash = '';
 	private $lockPath = '';
 	private $hubUrl = '';
 	private $selfUrl = '';
@@ -58,7 +58,7 @@ class FreshRSS_Feed extends Minz_Model {
 	}
 
 	public function hash(): string {
-		if ($this->hash === null) {
+		if ($this->hash == '') {
 			$salt = FreshRSS_Context::$system_conf->salt;
 			$this->hash = hash('crc32b', $salt . $this->url);
 		}
@@ -191,7 +191,7 @@ class FreshRSS_Feed extends Minz_Model {
 		$this->id = intval($value);
 	}
 	public function _url(string $value, bool $validate = true) {
-		$this->hash = null;
+		$this->hash = '';
 		if ($validate) {
 			$value = checkUrl($value);
 		}
@@ -304,9 +304,9 @@ class FreshRSS_Feed extends Minz_Model {
 				}
 
 				$links = $simplePie->get_links('self');
-				$this->selfUrl = isset($links[0]) ? $links[0] : null;
+				$this->selfUrl = $links[0] ?? '';
 				$links = $simplePie->get_links('hub');
-				$this->hubUrl = isset($links[0]) ? $links[0] : null;
+				$this->hubUrl = $links[0] ?? '';
 
 				if ($loadDetails) {
 					// si on a utilisé l’auto-discover, notre url va avoir changé

+ 4 - 1
lib/lib_rss.php

@@ -193,7 +193,10 @@ function timestamptodate ($t, $hour = true) {
 	return @date ($date, $t);
 }
 
-function html_only_entity_decode(string $text): string {
+/**
+ * @param string|null $text
+ */
+function html_only_entity_decode($text): string {
 	static $htmlEntitiesOnly = null;
 	if ($htmlEntitiesOnly === null) {
 		$htmlEntitiesOnly = array_flip(array_diff(