AI Search
Classic Search
 Search Phrase:
 Search Type:
Advanced search options
 Search in Forums:
 Search in date period:

 Sort Search Results by:

AI Assistant
Notifications
Clear all

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

1 Posts
1 Users
0 Reactions
6 Views
sc89me
Posts: 29
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
(@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():

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

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:

$max = (int) apply_filters( 'wpforo_cache_dir_max_files', 1000, $directory );
if ( $max > 0 && $filecount > $max ) {
$this->clean_files( $directory );
}

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.


Share: