Вход на сайт

Просмотр новости

Найдите то, что Вас интересует

Hardcoded 1000-file wipe in Cache::check() — please add a filter

Дата публикации: 19-08-2026 14:02:22

IssueOn a large, busy forum, wpForo’s file cache under {cache_dir}/item/post regularly exceeds 1000 files. Cache::check() then deletes every file in that directory on the same frontend reque...

Основное содержимое страницы с новостью.

4 Posts

2 Users

0 Reactions

81 Views

sc89me

Topic starter

Translate

English

Spanish

French

German

Italian

Portuguese

Russian

Chinese

Japanese

Korean

Arabic

Hindi

Dutch

Polish

Turkish

Vietnamese

Thai

Swedish

Danish

Finnish

Norwegian

Czech

Hungarian

Romanian

Greek

Hebrew

Indonesian

Malay

Ukrainian

Bulgarian

Croatian

Slovak

Slovenian

Serbian

Lithuanian

Latvian

Estonian

Aug 19, 2026 6:02 pm

(@sc89me)

Trusted Member

Joined: 7 years ago

[#73137]

Issue
On a large, busy forum, wpForo’s file cache under {cache_dir}/item/post regularly exceeds 1000 files. Cache::check() then deletes every file in that directory on the same frontend request.

That runs from wp_footer  WPF()->cache->create() when the template is forum (forum index). After the wipe, traffic rebuilds the files, the folder hits 1000 again, and the wipe repeats (for us, every few minutes). PHP CPU spikes and the cache is not useful.

We have thousands of posts. Each cached post is its own file ({postid}_{locale}). A 1000-file cap is far below our working set. There is no setting or filter to change it.

This is still present in 3.1.5. classes/Cache.php check():

Page cache (WP Rocket etc.) is not in use on the forum; this is only wpForo’s on-disk cache.

Request
Please make the limit filterable, default 1000, pass $directory, and treat 0 as never wipe:

That stays backward compatible. Large forums can raise the cap or disable the wipe without forking the plugin.

Optional follow-up
Counting the directory with FilesystemIterator on every forum-index request is expensive once the folder is large, even if you never delete. A throttle (e.g. at most once per N minutes) would help. Full-directory unlink is also harsh vs deleting oldest files; the filter is the minimum we need please.


sc89me

Topic starter

Translate

English

Spanish

French

German

Italian

Portuguese

Russian

Chinese

Japanese

Korean

Arabic

Hindi

Dutch

Polish

Turkish

Vietnamese

Thai

Swedish

Danish

Finnish

Norwegian

Czech

Hungarian

Romanian

Greek

Hebrew

Indonesian

Malay

Ukrainian

Bulgarian

Croatian

Slovak

Slovenian

Serbian

Lithuanian

Latvian

Estonian

Aug 20, 2026 4:14 pm

(@sc89me)

Trusted Member

Joined: 7 years ago

We have modified the check function to skip the file count function calls entirely when the max is set to 0 this avoids expensive CPU calls to count large directories which will not be cleared anyway.  

public function check( $directory ) {
		$directory = (string) $directory;
		$directory = wpforo_fix_dir_sep( $directory );
		$filecount = 0;
        $max = (int) apply_filters( 'wpforo_cache_dir_max_files', 1000, $directory );

        if($max === 0) {
            return;
        }

        if( class_exists( 'FilesystemIterator' ) && is_dir( $directory ) ) {
			$fi        = new FilesystemIterator( $directory, FilesystemIterator::SKIP_DOTS );
			$filecount = iterator_count( $fi );
		}
		if( ! $filecount ) {
			$directory_ns = trim( $directory, DIRECTORY_SEPARATOR ) . DIRECTORY_SEPARATOR . '*';
			$directory_ws = DIRECTORY_SEPARATOR . trim( $directory, DIRECTORY_SEPARATOR ) . DIRECTORY_SEPARATOR . '*';
			$files        = glob( $directory_ns );
			if( empty( $files ) ) $files = glob( $directory_ws );
			$filecount = count( $files );
		}

        if ( $filecount > $max ) {
            $this->clean_files( $directory );
        }
}

Filter Used: 

add_filter( 'wpforo_cache_dir_max_files', fn() => 0 );

Robert

Admin

Translate

English

Spanish

French

German

Italian

Portuguese

Russian

Chinese

Japanese

Korean

Arabic

Hindi

Dutch

Polish

Turkish

Vietnamese

Thai

Swedish

Danish

Finnish

Norwegian

Czech

Hungarian

Romanian

Greek

Hebrew

Indonesian

Malay

Ukrainian

Bulgarian

Croatian

Slovak

Slovenian

Serbian

Lithuanian

Latvian

Estonian

Aug 25, 2026 12:52 pm

(@robert)

Support Team

Joined: 7 months ago

Hi @sc89me,

Thank you for sharing this issue. We'll fix this in the next version release. It'll change the max file number dynamically based on the forum activity and also we'll add filter hook to set a custom value. 


In case you want to say thank you !)
We'd really appreciate and be thankful if you leave a good review on plugin page. This is the best way to say thank you to this project and support team.

sc89me

Topic starter

Translate

English

Spanish

French

German

Italian

Portuguese

Russian

Chinese

Japanese

Korean

Arabic

Hindi

Dutch

Polish

Turkish

Vietnamese

Thai

Swedish

Danish

Finnish

Norwegian

Czech

Hungarian

Romanian

Greek

Hebrew

Indonesian

Malay

Ukrainian

Bulgarian

Croatian

Slovak

Slovenian

Serbian

Lithuanian

Latvian

Estonian

Aug 25, 2026 2:53 pm

(@sc89me)

Trusted Member

Joined: 7 years ago

Hi Robert, 

Appreciate that thanks, 

Will you please still include a skip (early return) of the function if set to infinite?

When we initially didn't return early and still allowed those file count calls to happen it was heavily loading the CPU because we hit periods of 50 - 100 views per second at peak times which caused those to happen per view. 


Схожие новости

#Наименование новостиТональностьИнформативностьДата публикации
1W3 Total Cache causing Mobile Friendly Test fails, blocks Google from CSS/JS08.6705-09-2021
2Pagination problem013.6825-08-2026
3How can I disable profile editing in wpForo?06.5509-08-2026
4Auto Login user by using wpforo signin page0816-08-2026
5Replies, comments, adding topics not working, not showing012.4922-08-2026
6CS Forms Date picker width0211-07-2026
7404 ошибки018.0409-07-2026
8Formlayer 1.0.9 Launched07.0225-08-2026
9Displaying "Total Views"06.5719-08-2026
10Соцфонд напомнил о важности регулярной очистки кэша и файлов куки08.7921-07-2026

Классификация: Мнения. Схожих патентов: 0. Схожих новостей: 10. Тональность: 0. Информативность: 10.37. Источник: wpforo.com.