rss-bridge icon indicating copy to clipboard operation
rss-bridge copied to clipboard

UID ignored if provided as integer in bridge

Open wrobelda opened this issue 1 month ago • 2 comments

Describe the bug I noticed today that the bridge I am working on has an empty id field in feed articles, even though I do provide a relevant value to $item['uid'] in the code.

Turns out the value I am providing is an integer and RSS-Bridge does not like that. After converting to string with strval, it works as expected.

Seems to me that this is a bug? And if it is not, then I suppose it should be documented, as I did not see anything on this in dev docs — unless I missed something?

wrobelda avatar Nov 14 '25 16:11 wrobelda

You are correct. We can classify this is a bug indeed.

Here is relevant code in FeedItem:

    public function setUid($uid): void
    {
        $this->uid = null;
        if (!is_string($uid)) {
            return;
        }
        if (preg_match('/^[a-f0-9]{40}$/', $uid)) {
            // Preserve sha1 hash
            $this->uid = $uid;
        } else {
            $this->uid = sha1($uid);
        }
    }

dvikan avatar Nov 14 '25 17:11 dvikan

I'm thinking about it and imho while the code should accept string, integers and UUIDs, it should not fail silently for other types but instead throw an exception, since an ID of some sort is intentionally delivered, after all, even even if of a wrong type. A bridge author should be made aware of it if this happens.

wrobelda avatar Nov 18 '25 19:11 wrobelda