bbPress v0.8.3.1 plugin error fix

by jeff

This morning I started seeing a pile of errors on one of our bbPress installations, starting with:

Warning: Invalid argument supplied for foreach() in /bb-settings.php on line 173

This caused a cascade of other errors, prevented login to either the forum or the admin area and generally fubar’d everything. Since it took me over an hour to find a fix (way too long for such a big bug) I’m posting it here to hopefully help others find the solution.

Apparently it’s the result of a PHP upgrade to v5.2.5 last night. It would have been nice if my host had let me know they were doing this ahead of time. Thankfully, it seems only my bbPress installations are affected.

The fix

From a post in the bbPress forums by Neziniux, originally linked from a German post:

Open bb-settings.php, on line 172 find:

if ( is_callable( 'glob' ) )
foreach ( glob(BBPLUGINDIR . '_*.php') as $_plugin )
require($_plugin);

Replace with

if ( is_callable( 'glob' ) ) {
$pluginarray = glob(BBPLUGINDIR . '_*.php');
if ($pluginarray)
foreach ( $pluginarray as $_plugin )
require($_plugin);
}

That’ll take care of it. Thanks to Neziniux and brusdeylins for this.