From cb4ff592d90ef80b35fc6e9cef386eeb9cac1967 Mon Sep 17 00:00:00 2001 From: Shish Date: Fri, 13 Dec 2024 23:11:27 +0000 Subject: [PATCH] [tag_list] remove hacky caching for tag lists --- ext/comment/main.php | 2 +- ext/speed_hax/main.php | 3 --- ext/tag_list/main.php | 39 --------------------------------------- 3 files changed, 1 insertion(+), 43 deletions(-) diff --git a/ext/comment/main.php b/ext/comment/main.php index 9d0d8987f..98e3da8e3 100644 --- a/ext/comment/main.php +++ b/ext/comment/main.php @@ -236,7 +236,7 @@ public function onPageRequest(PageRequestEvent $event): void if ($event->page_matches("comment/list", paged: true)) { $threads_per_page = 10; - $speed_hax = (Extension::is_enabled(SpeedHaxInfo::KEY) && $config->get_bool(SpeedHaxConfig::CACHE_TAG_LISTS)); + $speed_hax = (Extension::is_enabled(SpeedHaxInfo::KEY) && $config->get_bool(SpeedHaxConfig::RECENT_COMMENTS)); $where = $speed_hax ? "WHERE posted > now() - interval '24 hours'" : ""; $total_pages = cache_get_or_set("comment_pages", fn () => (int)ceil($database->get_one(" diff --git a/ext/speed_hax/main.php b/ext/speed_hax/main.php index 9f81a37a1..c156d46d8 100644 --- a/ext/speed_hax/main.php +++ b/ext/speed_hax/main.php @@ -8,7 +8,6 @@ abstract class SpeedHaxConfig { public const NO_AUTO_DB_UPGRADE = "speed_hax_no_auto_db_upgrade"; public const CACHE_EVENT_LISTENERS = "speed_hax_cache_listeners"; - public const CACHE_TAG_LISTS = "speed_hax_cache_tag_lists"; public const PURGE_COOKIE = "speed_hax_purge_cookie"; public const RECENT_COMMENTS = "speed_hax_recent_comments"; public const BIG_SEARCH = "speed_hax_big_search"; @@ -26,7 +25,6 @@ public function onInitExt(InitExtEvent $event): void $config->set_default_bool(SpeedHaxConfig::NO_AUTO_DB_UPGRADE, false); $config->set_default_bool(SpeedHaxConfig::CACHE_EVENT_LISTENERS, false); - $config->set_default_bool(SpeedHaxConfig::CACHE_TAG_LISTS, false); $config->set_default_bool(SpeedHaxConfig::PURGE_COOKIE, false); $config->set_default_bool(SpeedHaxConfig::RECENT_COMMENTS, false); $config->set_default_int(SpeedHaxConfig::BIG_SEARCH, 0); @@ -42,7 +40,6 @@ public function onSetupBuilding(SetupBuildingEvent $event): void $sb->start_table(); $sb->add_bool_option(SpeedHaxConfig::NO_AUTO_DB_UPGRADE, "Don't auto-upgrade database: ", false); $sb->add_bool_option(SpeedHaxConfig::CACHE_EVENT_LISTENERS, "
Cache event listeners: ", false); - $sb->add_bool_option(SpeedHaxConfig::CACHE_TAG_LISTS, "
Cache tag lists: ", false); $sb->add_bool_option(SpeedHaxConfig::PURGE_COOKIE, "
Purge cookie on logout: ", false); $sb->add_bool_option(SpeedHaxConfig::RECENT_COMMENTS, "
List only recent comments: ", false); $sb->add_int_option(SpeedHaxConfig::BIG_SEARCH, "
Anonymous search tag limit: ", false); diff --git a/ext/tag_list/main.php b/ext/tag_list/main.php index 8c9b79565..5b88e8922 100644 --- a/ext/tag_list/main.php +++ b/ext/tag_list/main.php @@ -220,15 +220,6 @@ private function build_tag_map(string $starts_with, int $tags_min): string { global $config, $database; - // check if we have a cached version - $cache_key = warehouse_path( - "cache/tag_cloud", - md5("tc" . $tags_min . $starts_with . VERSION) - ); - if (file_exists($cache_key)) { - return \Safe\file_get_contents($cache_key); - } - $tag_data = $database->get_all(" SELECT tag, @@ -257,10 +248,6 @@ private function build_tag_map(string $starts_with, int $tags_min): string $html .= " $h_tag_no_underscores \n"; } - if (Extension::is_enabled(SpeedHaxInfo::KEY) && $config->get_bool(SpeedHaxConfig::CACHE_TAG_LISTS)) { - file_put_contents($cache_key, $html); - } - return $html; } @@ -268,15 +255,6 @@ private function build_tag_alphabetic(string $starts_with, int $tags_min): strin { global $config, $database; - // check if we have a cached version - $cache_key = warehouse_path( - "cache/tag_alpha", - md5("ta" . $tags_min . $starts_with . VERSION) - ); - if (file_exists($cache_key)) { - return \Safe\file_get_contents($cache_key); - } - $tag_data = $database->get_pairs(" SELECT tag, count FROM tags @@ -325,10 +303,6 @@ private function build_tag_alphabetic(string $starts_with, int $tags_min): strin $html .= "$h_tag\n"; } - if (Extension::is_enabled(SpeedHaxInfo::KEY) && $config->get_bool(SpeedHaxConfig::CACHE_TAG_LISTS)) { - file_put_contents($cache_key, $html); - } - return $html; } @@ -342,15 +316,6 @@ private function build_tag_popularity(int $tags_min): string $tags_min = 1; } - // check if we have a cached version - $cache_key = warehouse_path( - "cache/tag_popul", - md5("tp" . $tags_min . VERSION) - ); - if (file_exists($cache_key)) { - return \Safe\file_get_contents($cache_key); - } - $tag_data = $database->get_all(" SELECT tag, count, FLOOR(LOG(10, count)) AS scaled FROM tags @@ -372,10 +337,6 @@ private function build_tag_popularity(int $tags_min): string $html .= "$h_tag ($count)\n"; } - if (Extension::is_enabled(SpeedHaxInfo::KEY) && $config->get_bool(SpeedHaxConfig::CACHE_TAG_LISTS)) { - file_put_contents($cache_key, $html); - } - return $html; }