Thanks. I don’t have an Android device so I wasn’t sure if that was an option.

OP: You should definitely use that, just re-work the database query to get published versus marked articles.

Thanks fox and JustAMacUser

I’ll try to rework the cache_starred_images plugin with your advices.

Just to be sure, when you say “re-work the database query to get published versus marked articles” that just means replace

WHERE ref_id = ttrss_entries.id AND
				marked = true AND
				site_url != '' AND 
			    ttrss_user_entries.owner_uid = ? AND

by

WHERE ref_id = ttrss_entries.id AND
				published= true AND
				site_url != '' AND 
			    ttrss_user_entries.owner_uid = ? AND

?

Yup.

/20chars…

Thanks again.

Another noob question : where do I set debug mode “on”, or at least see echo results ?

Nothing in the Event log in the Preferences of TT RSS website. I guess it’s because it only show errors but I have no results for my plugin and no way to debug using at least echo.

that depends on where you’re debugging

  1. there’s Debug::log() you can check other plugins using it for examples
  2. there’s user_error(“something”, E_USER_NOTICE)
  3. there’s always echo which you’re going to see in the console output if your plugin is invoked by the updater, for example

1 & 2 go to tt-rss event log, it doesn’t have to be an error, necessarily

Thanks again. I used 2 and it helped me to make it work.

Just out of curiosity, sometimes it works within seconds and other times it needs several minutes (it should be the same for the cached_starred_images plugin). It’s absolutely fine for my usage but I would like to understand.

The maintenance hooks runs when the daemon is done processing feed updates. By default that means a minimum of 2 minutes.

OK. Thanks for the information… and for everything.

Hello,

I have one last question about this : is there away to unpublishe the article I published after mail has been sent ? That would “clean” the published articles category as I use it.
I saw a start of a clue here but can’t find a way to write the plugin part by myself.

update ttrss_user_entries set published = false where int_id = ...

Thanks a lot for the help.

I tried with several kind of lines of code and the best I could have was :

$usth = $this->pdo->prepare("UPDATE ttrss_entries SET published = false WHERE id = ?");
$usth->execute([$line['id']]);

with ERROR :

Uncaught PDOException: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'published' in 'field list' in /var/www/ttrss/plugins.local/published_to_share/init.php:211 Stack trace: #0 /var/www/ttrss/plugins.local/published_to_share/init.php(211): PDOStatement->execute(Array) #1 /var/www/ttrss/classes/pluginhost.php(132): published_to_share->hook_house_keeping('') #2 /var/www/ttrss/classes/rssutils.php(1493): PluginHost->run_hooks(24, 'hook_house_keep...', '') #3 /var/www/ttrss/classes/rssutils.php(174): RSSUtils::housekeeping_user('1') #4 /var/www/ttrss/update.php(250): RSSUtils::update_daemon_common(50) #5 {main} thrown

Does anyone have an idea on how to fix this ?

Look at the database, took me 30 sec to find the column is in ttrss_user_entries

tl;dr

The published state is stored in ttrss_user_entries, you can see this by looking at the schema (see the schema directory in the root of the installation).

Long version:

I don’t have the complete code of your plugin, but if you have the row IDs in an array, it might be better to use PDO’s bindParam() method and then loop the execute() call. There will be a performance improvement by only creating the statement once and calling it with a new value in the variable.

For example:

$stmt = $this->pdo->prepare("UPDATE ttrss_user_entries SET published = false WHERE id = :id");
$stmt->bindParam(":id", $id, PDO::PARAM_INT);

foreach ($ids as $id) {
	$stmt->execute();
}

You could also use WHERE id IN (?,?,?) and skip the loop altogether. This method probably provides the best performance, but either would be better than re-creating the statement in a loop. Personally, I like the first method better because I find creating the exact amount of question marks in the IN clause to be ugly, but that’s just my preference.

I tried the first solution but couldn’t make it work. But the second did :slight_smile:

Thanks a lot for your help

Hi all,

I just started using TT-RSS, replacing TheOldReader, which had the option of sending starred articles to Pocket (I use Raindrop.io now), so I was very happy to see this thread here, as it is exactly what I’m missing to have a perfect setup.

@yukes33, would you mind sharing the results of your efforts in this thread?

Thanks everyone in advance.

Hi,

I can share my “work” if you want. I just want to say that the code will not be pretty as I am a noob and without the help on this forum, I couldn’t have done half of the work.
I changed the plugin so that the published articles are sent to Wallabag (my read it later service).

function hook_house_keeping() {
            /* since HOOK_UPDATE_TASK is not available to user plugins, this hook is a next best thing */

            Debug::log("caching media of starred articles for user " . $this->host->get_owner_uid() . "...");
            $sth = $this->pdo->prepare("SELECT content, ttrss_entries.title, 
            ttrss_user_entries.owner_uid, link, site_url, ttrss_entries.id, plugin_data
                    FROM ttrss_entries, ttrss_user_entries LEFT JOIN ttrss_feeds ON
                            (ttrss_user_entries.feed_id = ttrss_feeds.id)
                    WHERE ref_id = ttrss_entries.id AND
                            published = true AND
                            site_url != '' AND 
                        ttrss_user_entries.owner_uid = ?  AND
                             plugin_data NOT LIKE '%share_published%'
                    ORDER BY ".sql_random_function()." LIMIT 100");

            if ($sth->execute([$this->host->get_owner_uid()])) {
                    $usth = $this->pdo->prepare("UPDATE ttrss_entries SET plugin_data = ? WHERE id = ?");

                    while ($line = $sth->fetch()) {

                            Debug::log("processing article " . $line["title"], Debug::$LOG_VERBOSE);

                            if ($line["site_url"]) {

                                    $plugin_data = "share_published,${line['owner_uid']}:" . $line["plugin_data"];
                                    $usth->execute([$plugin_data, $line['id']]);

            /* Send to Wallabag
                                    $this->_oauth();
                                    $this->_send( $line["title"], $line["link"], 'filter');

            /* Delete from published article list
                                    $stmt = $this->pdo->prepare("UPDATE ttrss_user_entries SET published = false");
                                    $stmt->execute();

Thanks a lot @jukes33!

I will try it as soon as I can. Hopefully I’ll get it to work with Raindrop, otherwise I might switch to Wallabag (was #2 in my list of replacements for Pocket…)

Thanks again!

that got recently refactored in the Db class btw.

Hi fox,

I just updated some packages, including ttrss, and got an error on this line (you predicted my future 10 days before it happens).

I tried to change this line (removing ORDER BY ".sql_random_function()." for example) but failed everytime.

Do you have an idea on how I could make it work again ?

Thanks in advance

The function was moved into a class so you have to use that: Db::sql_random_function()