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

wpForo 3.1.6 infinite recursion in cache limit calculation causes PHP stack exhaustion

1 Posts
1 Users
0 Reactions
6 Views
Posts: 51
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
(@upstartdm)
Trusted Member
Joined: 6 years ago
[#73193]

After updating to wpForo 3.1.6, clearing wpForo caches, and purging Cloudflare cache, the site began returning 504s and then CloudLinux 508s as PHP workers accumulated.

PHP logged repeated fatal errors:

 
PHP Fatal error: Uncaught Error: Maximum call stack size ... reached. Infinite recursion?
 

The recursion path is:

 
Posts::get_full_url()
→ Cache::create('item', ..., 'url')
→ Cache::check()
→ WPF()->statistic()
→ statistic() sets last_post_url via Posts::get_url()
→ Posts::get_full_url()
→ Cache::create()
→ Cache::check()
→ ...
 

Relevant code in classes/Cache.php 3.1.6:

 
// Dynamic limit based on online members (scales with forum activity)
$stats = WPF()->statistic();
$online = max( 2, intval( $stats['online_members_count'] ) );
 

WPF()->statistic() eventually calls:

 
$stats['last_post_url'] = $this->post->get_url( $posts[ $first ]['last_post'] );
 

which re-enters URL-cache generation before the original URL cache write has completed.

A one-line fix that has stopped the recursion on our site is to obtain the online-member count directly:

 
$online = max( 2, intval( WPF()->member->online_members_count() ) );
 

replacing:

 
$stats = WPF()->statistic();
$online = max( 2, intval( $stats['online_members_count'] ) );
 

This preserves the intended dynamic cache-file limit while avoiding the recursive statistics → URL cache → statistics dependency.

Environment: wpForo 3.1.6, WordPress, PHP 8.5, CloudLinux/cPanel.

We saw four stack-exhaustion fatals, with stack traces exceeding 156,000 frames. After applying the one-line change above, repeated uncached forum requests return normally and no new recursion errors have appeared.


Share: