diff options
| author | 2025-12-16 18:53:00 +0100 | |
|---|---|---|
| committer | 2025-12-16 18:53:00 +0100 | |
| commit | 6952a13958417e8441645d0777597db679d0e28d (patch) | |
| tree | 8b5a94cac7b59f932deb35771a9058b79419c3d0 /app | |
| parent | 1c50193644e1b69ba2e568c2a4cafc7c7f26854f (diff) | |
Handle null in base64_encode (#8321)
* Handle null in base64_encode
https://github.com/FreshRSS/FreshRSS/discussions/8314#discussioncomment-15269370
* PHPDoc
Diffstat (limited to 'app')
| -rw-r--r-- | app/Models/FeedDAO.php | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/app/Models/FeedDAO.php b/app/Models/FeedDAO.php index a2c64977f..bec7183ee 100644 --- a/app/Models/FeedDAO.php +++ b/app/Models/FeedDAO.php @@ -39,7 +39,7 @@ class FreshRSS_FeedDAO extends Minz_ModelPdo { /** * @param array{id?:int,url:string,kind:int,category:int,name:string,website:string,description:string,lastUpdate:int,priority?:int, - * pathEntries?:string,httpAuth:string,error:int|bool,ttl?:int,attributes?:string|array<string|mixed>} $valuesTmp + * pathEntries?:string,httpAuth?:string,error:int|bool,ttl?:int,attributes?:string|array<string|mixed>} $valuesTmp */ public function addFeed(array $valuesTmp): int|false { if (empty($valuesTmp['id'])) { // Auto-generated ID @@ -75,7 +75,7 @@ SQL; $valuesTmp['lastUpdate'], isset($valuesTmp['priority']) ? (int)$valuesTmp['priority'] : FreshRSS_Feed::PRIORITY_MAIN_STREAM, mb_strcut($valuesTmp['pathEntries'], 0, 4096, 'UTF-8'), - base64_encode($valuesTmp['httpAuth']), + base64_encode($valuesTmp['httpAuth'] ?? ''), isset($valuesTmp['error']) ? (int)$valuesTmp['error'] : 0, isset($valuesTmp['ttl']) ? (int)$valuesTmp['ttl'] : FreshRSS_Feed::TTL_DEFAULT, is_string($valuesTmp['attributes']) ? $valuesTmp['attributes'] : json_encode($valuesTmp['attributes'], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE), @@ -181,7 +181,7 @@ SQL; $set .= '`' . $key . '`=?, '; if ($key === 'httpAuth') { - $valuesTmp[$key] = base64_encode($v); + $valuesTmp[$key] = is_string($v) ? base64_encode($v) : ''; } elseif ($key === 'attributes') { $valuesTmp[$key] = is_string($valuesTmp[$key]) ? $valuesTmp[$key] : json_encode($valuesTmp[$key], JSON_UNESCAPED_SLASHES); } @@ -315,7 +315,7 @@ SQL; } /** @return Traversable<array{id:int,url:string,kind:int,category:int,name:string,website:string,description:string,lastUpdate:int,priority?:int, - * pathEntries?:string,httpAuth:string,error:int|bool,ttl?:int,attributes?:string}> */ + * pathEntries?:string,httpAuth?:string,error:int|bool,ttl?:int,attributes?:string}> */ public function selectAll(): Traversable { $sql = <<<'SQL' SELECT id, url, kind, category, name, website, description, `lastUpdate`, @@ -326,7 +326,7 @@ SQL; if ($stm !== false) { while (is_array($row = $stm->fetch(PDO::FETCH_ASSOC))) { /** @var array{id:int,url:string,kind:int,category:int,name:string,website:string,description:string,lastUpdate:int,priority?:int, - * pathEntries?:string,httpAuth:string,error:int,ttl?:int,attributes?:string} $row */ + * pathEntries?:string,httpAuth?:string,error:int,ttl?:int,attributes?:string} $row */ yield $row; } } else { |
