Skip to content

Fix: Properly set the priority field when saving a new feed#7354

Merged
Alkarex merged 1 commit intoFreshRSS:edgefrom
EricDiao:ericdiao/feed-add-priority
Feb 23, 2025
Merged

Fix: Properly set the priority field when saving a new feed#7354
Alkarex merged 1 commit intoFreshRSS:edgefrom
EricDiao:ericdiao/feed-add-priority

Conversation

@EricDiao
Copy link
Contributor

Background:

I am writing a extension solely for my personal need: not putting entries feeds in a category in my main stream.

For that, I am hooking into the feed_before_insert hook and set the priority field to 0 (so that it only appear in its category).

But I find the priority does not change after doing so (but I tested all other fields including website etc is working). After dig into the source code of FeedDAO.php, I find that the priority field (unlike others) is missing from the values passed to addFeed so comes the proposed patch to solve this issue.

Changes proposed in this pull request:

  • Pass the priority field of FreshRSS_Feed object into the addFeed method of FreshRSS_FeedDAO properly so that the priority of a feed is properly set when a feed is added.

How to test the feature manually:

  1. Hook into the feed_before_insert hook in an extension and change the priority to value other than the default (10);
  2. Add a feed with the extension enabled.
  3. Observe the difference before and after the patch applied:
    • Before, the patch the priority field will be 10, the default value;
    • After, the field is correctly set;

A minimal extension that tests the feature is

<?php

final class MuteExtension extends Minz_Extension
{
    #[\Override]
    public function init(): void
    {
        $this->registerHook('feed_before_insert', [$this, 'hook_feed_before_insert']);
    }

    public function hook_feed_before_insert(FreshRSS_Feed $feed): FreshRSS_Feed
    {
        $feed->_priority(0);
        $feed->_attribute('priority', 0); // Should be either or?

        return $feed;
    }
}

Pull request checklist:

  • clear commit messages
  • code manually tested
    - [ ] unit tests written (optional if too hard)
    - [ ] documentation updated

Additional information can be found in the documentation.

Signed-off-by: Zihao Diao <hi@ericdiao.com>
@Alkarex Alkarex added this to the 1.26.0 milestone Feb 23, 2025
@Alkarex Alkarex added the Bug (confirmed) 🐞 issues that are reproducible label Feb 23, 2025
@Alkarex Alkarex modified the milestones: 1.26.0, 1.27.0 Feb 23, 2025
@Alkarex Alkarex merged commit b0b75dd into FreshRSS:edge Feb 23, 2025
1 check passed
@Alkarex
Copy link
Member

Alkarex commented Feb 23, 2025

Thanks 👍🏻
Please add a line for you in https://github.com/FreshRSS/FreshRSS/blob/edge/CREDITS.md

@Alkarex
Copy link
Member

Alkarex commented Feb 23, 2025

P.S. No, this line should be deleted $feed->_attribute('priority', 0);

EricDiao added a commit to EricDiao/FreshRSS that referenced this pull request Feb 23, 2025
Signed-off-by: Zihao Diao <hi@ericdiao.com>
Alkarex pushed a commit that referenced this pull request Feb 24, 2025
Signed-off-by: Zihao Diao <hi@ericdiao.com>
@Alkarex Alkarex modified the milestones: 1.27.0, 1.26.1 Mar 5, 2025
Sh4kE added a commit to Sh4kE/freshrss-helm-chart that referenced this pull request Mar 15, 2025
This PR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [freshrss/freshrss](https://freshrss.org/) ([source](https://github.com/FreshRSS/FreshRSS)) | patch | `1.26.0-alpine` -> `1.26.1-alpine` |

---

### Release Notes

<details>
<summary>FreshRSS/FreshRSS (freshrss/freshrss)</summary>

### [`v1.26.1`](https://github.com/FreshRSS/FreshRSS/blob/HEAD/CHANGELOG.md#2025-03-13-FreshRSS-1261)

[Compare Source](FreshRSS/FreshRSS@1.26.0...1.26.1)

-   Features
    -   Add cURL version to page about system information [#&#8203;7409](FreshRSS/FreshRSS#7409)
-   Bug fixing
    -   Fix regression with cURL HTTP headers breaking conditional HTTP requests [#&#8203;7403](FreshRSS/FreshRSS#7403), [FreshRSS/simplepie#33](FreshRSS/simplepie#33)
    -   Fix regression with saving states of user queries [#&#8203;7400](FreshRSS/FreshRSS#7400)
    -   Fix regression with dynamic OPML [#&#8203;7394](FreshRSS/FreshRSS#7394)
    -   Fix update of the user’s last activity on login action [#&#8203;7406](FreshRSS/FreshRSS#7406)
    -   Fix setting category option *Maximum number of articles to keep per feed* [#&#8203;7416](FreshRSS/FreshRSS#7416)
    -   Fix priority field when processing a new feed from an extension [#&#8203;7354](FreshRSS/FreshRSS#7354)
-   Deployment
    -   Fix regression with 64-bit timestamps on 32-bit platforms [#&#8203;7375](FreshRSS/FreshRSS#7375)
    -   Fix back-compatibility with cURL 7.51 (we require cURL 7.52+ for `CURLPROXY_HTTPS`) [#&#8203;7409](FreshRSS/FreshRSS#7409)
-   UI
    -   Use case-insensitive sort for categories [#&#8203;7402](FreshRSS/FreshRSS#7402)
    -   Improve dark mode of *Origine* theme [#&#8203;7413](FreshRSS/FreshRSS#7413)
    -   Added API password indicator [#&#8203;7340](FreshRSS/FreshRSS#7340)
-   I18n
    -   Fix (es, fa, sk): do not translate XPath code [#&#8203;7404](FreshRSS/FreshRSS#7404)
    -   Fix date bug in Finish [#&#8203;7423](FreshRSS/FreshRSS#7423)
    -   Add Portuguese from Portugal [#&#8203;7329](FreshRSS/FreshRSS#7329)
    -   Improve Hungarian [#&#8203;7391](FreshRSS/FreshRSS#7391)
-   Misc.
    -   Improve PHP code [#&#8203;7339](FreshRSS/FreshRSS#7339)
    -   Update dev dependencies [#&#8203;7386](FreshRSS/FreshRSS#7386), [#&#8203;7387](FreshRSS/FreshRSS#7387), [#&#8203;7388](FreshRSS/FreshRSS#7388)

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOS4yMDAuMCIsInVwZGF0ZWRJblZlciI6IjM5LjIwMC4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119-->

Reviewed-on: https://gitea.sh4ke.rocks/lickler/freshrss/pulls/35
Co-authored-by: Michael Wittig <michael.wittig@posteo.de>
Co-committed-by: Michael Wittig <michael.wittig@posteo.de>
Sh4kE added a commit to Sh4kE/freshrss-helm-chart that referenced this pull request Mar 15, 2025
This PR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [freshrss](https://github.com/FreshRSS/FreshRSS) | patch | `1.26.0` -> `1.26.1` |

---

### Release Notes

<details>
<summary>FreshRSS/FreshRSS (freshrss)</summary>

### [`v1.26.1`](https://github.com/FreshRSS/FreshRSS/blob/HEAD/CHANGELOG.md#2025-03-13-FreshRSS-1261)

[Compare Source](FreshRSS/FreshRSS@1.26.0...1.26.1)

-   Features
    -   Add cURL version to page about system information [#&#8203;7409](FreshRSS/FreshRSS#7409)
-   Bug fixing
    -   Fix regression with cURL HTTP headers breaking conditional HTTP requests [#&#8203;7403](FreshRSS/FreshRSS#7403), [FreshRSS/simplepie#33](FreshRSS/simplepie#33)
    -   Fix regression with saving states of user queries [#&#8203;7400](FreshRSS/FreshRSS#7400)
    -   Fix regression with dynamic OPML [#&#8203;7394](FreshRSS/FreshRSS#7394)
    -   Fix update of the user’s last activity on login action [#&#8203;7406](FreshRSS/FreshRSS#7406)
    -   Fix setting category option *Maximum number of articles to keep per feed* [#&#8203;7416](FreshRSS/FreshRSS#7416)
    -   Fix priority field when processing a new feed from an extension [#&#8203;7354](FreshRSS/FreshRSS#7354)
-   Deployment
    -   Fix regression with 64-bit timestamps on 32-bit platforms [#&#8203;7375](FreshRSS/FreshRSS#7375)
    -   Fix back-compatibility with cURL 7.51 (we require cURL 7.52+ for `CURLPROXY_HTTPS`) [#&#8203;7409](FreshRSS/FreshRSS#7409)
-   UI
    -   Use case-insensitive sort for categories [#&#8203;7402](FreshRSS/FreshRSS#7402)
    -   Improve dark mode of *Origine* theme [#&#8203;7413](FreshRSS/FreshRSS#7413)
    -   Added API password indicator [#&#8203;7340](FreshRSS/FreshRSS#7340)
-   I18n
    -   Fix (es, fa, sk): do not translate XPath code [#&#8203;7404](FreshRSS/FreshRSS#7404)
    -   Fix date bug in Finish [#&#8203;7423](FreshRSS/FreshRSS#7423)
    -   Add Portuguese from Portugal [#&#8203;7329](FreshRSS/FreshRSS#7329)
    -   Improve Hungarian [#&#8203;7391](FreshRSS/FreshRSS#7391)
-   Misc.
    -   Improve PHP code [#&#8203;7339](FreshRSS/FreshRSS#7339)
    -   Update dev dependencies [#&#8203;7386](FreshRSS/FreshRSS#7386), [#&#8203;7387](FreshRSS/FreshRSS#7387), [#&#8203;7388](FreshRSS/FreshRSS#7388)

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOS4yMDAuMCIsInVwZGF0ZWRJblZlciI6IjM5LjIwMC4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119-->

Reviewed-on: https://gitea.sh4ke.rocks/lickler/freshrss/pulls/37
Co-authored-by: Michael Wittig <michael.wittig@posteo.de>
Co-committed-by: Michael Wittig <michael.wittig@posteo.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug (confirmed) 🐞 issues that are reproducible Extension 🔌

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants