In a new install, all pages started getting the above error message. It appears that there is an unhandled initialization case for the "forum_access_rids" persistent variable in the _forum_access_access_any_forum() method.

The code check to see if this is set. If it is not set, it does a query to get information from the db table. However, if there is no information in the table, it still sets the value to NULL. This causes the foreach error to occur. Note that this error goes away once there are some values in the DB. So it can be a transient error.

The solution to this is to initialize the $rids array to an empty array prior to calling the database. Here's the detail on this patch:

In the forum_access.module file, find the _forum_access_access_any_forum method (should be line 477). Modify the code to set the $rids variable to an empy array before the query (the new line at 490). The modified code should look like:

488: $rids = variable_get('forum_access_rids', NULL);
489: if (!isset($rids)) {
490: $rids = array(); // <================= NEW LINE
491: $result = db_query("SELECT fa.rid FROM {forum_access} fa WHERE fa.grant_view > 0 GROUP BY fa.rid");
492: while ($role = db_fetch_object($result)) {
493: $rids[] = $role->rid;
494: }
495: variable_set('forum_access_rids', $rids);
496: }

Comments

salvis’s picture

Status: Active » Fixed

Committed to the -dev version: http://drupal.org/cvs?commit=303768

Thanks!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

NeoID’s picture

Version: 6.x-1.2 » 6.x-1.x-dev
Priority: Normal » Critical
Status: Closed (fixed) » Active

After migrating from phpBB (phpBB2Drupal.module), I get this error, using the latest dev-version... only for anonymous users though...

NeoID’s picture

Status: Active » Fixed

Don't know what was wrong, but after removing and re-enabling the module it seems to work.. :)

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.