From b154bc7a10e46dc9fa0406996507c4fd410366da Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Mon, 14 Apr 2025 12:59:00 +0300 Subject: initial attempt to remove mysql-related stuff from tt-rss --- classes/RPC.php | 39 ++++++++++++--------------------------- 1 file changed, 12 insertions(+), 27 deletions(-) (limited to 'classes/RPC.php') diff --git a/classes/RPC.php b/classes/RPC.php index 82f85fc11..bad51e4aa 100644 --- a/classes/RPC.php +++ b/classes/RPC.php @@ -252,33 +252,18 @@ class RPC extends Handler_Protected { $default_interval = (int) Prefs::get_default(Prefs::DEFAULT_UPDATE_INTERVAL); // Test if the feed need a update (update interval exceded). - if (Config::get(Config::DB_TYPE) == "pgsql") { - $update_limit_qpart = "AND (( - update_interval = 0 - AND (p.value IS NULL OR p.value != '-1') - AND last_updated < NOW() - CAST((COALESCE(p.value, '$default_interval') || ' minutes') AS INTERVAL) - ) OR ( - update_interval > 0 - AND last_updated < NOW() - CAST((update_interval || ' minutes') AS INTERVAL) - ) OR ( - update_interval >= 0 - AND (p.value IS NULL OR p.value != '-1') - AND (last_updated = '1970-01-01 00:00:00' OR last_updated IS NULL) - ))"; - } else { - $update_limit_qpart = "AND (( - update_interval = 0 - AND (p.value IS NULL OR p.value != '-1') - AND last_updated < DATE_SUB(NOW(), INTERVAL CONVERT(COALESCE(p.value, '$default_interval'), SIGNED INTEGER) MINUTE) - ) OR ( - update_interval > 0 - AND last_updated < DATE_SUB(NOW(), INTERVAL update_interval MINUTE) - ) OR ( - update_interval >= 0 - AND (p.value IS NULL OR p.value != '-1') - AND (last_updated = '1970-01-01 00:00:00' OR last_updated IS NULL) - ))"; - } + $update_limit_qpart = "AND (( + update_interval = 0 + AND (p.value IS NULL OR p.value != '-1') + AND last_updated < NOW() - CAST((COALESCE(p.value, '$default_interval') || ' minutes') AS INTERVAL) + ) OR ( + update_interval > 0 + AND last_updated < NOW() - CAST((update_interval || ' minutes') AS INTERVAL) + ) OR ( + update_interval >= 0 + AND (p.value IS NULL OR p.value != '-1') + AND (last_updated = '1970-01-01 00:00:00' OR last_updated IS NULL) + ))"; // Test if feed is currently being updated by another process. $updstart_thresh_qpart = 'AND (last_update_started IS NULL OR ' -- cgit v1.2.3-54-g00ecf From 3c138a71a1749537680a23aca6d4181b5b2820f0 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Mon, 14 Apr 2025 15:27:58 +0300 Subject: add deprecation notice for sql_random_function() --- classes/Db.php | 1 + classes/RPC.php | 4 +--- plugins/cache_starred_images/init.php | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) (limited to 'classes/RPC.php') diff --git a/classes/Db.php b/classes/Db.php index 6310d11e3..872c6b351 100644 --- a/classes/Db.php +++ b/classes/Db.php @@ -71,6 +71,7 @@ class Db { return self::$instance->pdo; } + /** @deprecated usages should be replaced with `RANDOM()` */ public static function sql_random_function(): string { return "RANDOM()"; } diff --git a/classes/RPC.php b/classes/RPC.php index bad51e4aa..031bef509 100644 --- a/classes/RPC.php +++ b/classes/RPC.php @@ -269,8 +269,6 @@ class RPC extends Handler_Protected { $updstart_thresh_qpart = 'AND (last_update_started IS NULL OR ' . Db::past_comparison_qpart('last_update_started', '<', 5, 'minute') . ')'; - $random_qpart = Db::sql_random_function(); - $pdo = Db::pdo(); // we could be invoked from public.php with no active session @@ -290,7 +288,7 @@ class RPC extends Handler_Protected { $owner_check_qpart $update_limit_qpart $updstart_thresh_qpart - ORDER BY $random_qpart LIMIT 30"; + ORDER BY RANDOM() LIMIT 30"; $res = $pdo->query($query); diff --git a/plugins/cache_starred_images/init.php b/plugins/cache_starred_images/init.php index cc1eef0dc..48c8df3db 100755 --- a/plugins/cache_starred_images/init.php +++ b/plugins/cache_starred_images/init.php @@ -59,7 +59,7 @@ class Cache_Starred_Images extends Plugin { site_url != '' AND ttrss_user_entries.owner_uid = ? AND plugin_data NOT LIKE '%starred_cache_images%' - ORDER BY ".Db::sql_random_function()." LIMIT 100"); + ORDER BY RANDOM() LIMIT 100"); if ($sth->execute([$this->host->get_owner_uid()])) { -- cgit v1.2.3-54-g00ecf