warning:reset() function.reset : Line 749, 750, 751

luf - May 6, 2008 - 00:46
Project:OG Forum
Version:5.x-2.x-dev
Component:Code
Category:bug report
Priority:critical
Assigned:luf
Status:duplicate
Description

Alright here is what I am seeing every time I try to post a forum topic using a regular user to log into the forums, before and after they make a group:

warning: reset() [function.reset]: Passed variable is not an array or object in /mnt/gs02/herd05/15572/domains/guildcry.com/html/modules/og_forum/og_forum.module on line 749.
warning: key() [function.key]: Passed variable is not an array or object in /mnt/gs02/herd05/15572/domains/guildcry.com/html/modules/og_forum/og_forum.module on line 750.
warning: array_key_exists() [function.array-key-exists]: The first argument should be either a string or an integer in /mnt/gs02/herd05/15572/domains/guildcry.com/html/modules/og_forum/og_forum.module on line 751.

The administrator however does not see this error and everything proceeds as usual.

Here are the 3 lines of code as per ogforum.module file:

(749) reset($the_rest->option);
(750) $option_key = key($the_rest->option);
(751) if (array_key_exists($option_key, $all_results)) {

Please help!

#1

luf - May 6, 2008 - 01:01

I attempted to set the users to be able to "administer forums" and the error disappears when trying to post something BUT appears now when attempting to EDIT a previous post.

So;
if User Access Control = No Administer Forums, then Error appears
if User Access Control = Administer Forums, then no error when post - but error when EDIT

Now to add to it, here is the error I see when I hit EDIT - and since I turned off "administer forums" on the user:

warning: reset() [function.reset]: Passed variable is not an array or object in /mnt/gs02/herd05/15572/domains/guildcry.com/html/modules/og_forum/og_forum.module on line 712.
warning: key() [function.key]: Passed variable is not an array or object in /mnt/gs02/herd05/15572/domains/guildcry.com/html/modules/og_forum/og_forum.module on line 713.
warning: array_key_exists() [function.array-key-exists]: The first argument should be either a string or an integer in /mnt/gs02/herd05/15572/domains/guildcry.com/html/modules/og_forum/og_forum.module on line 714.

#2

luf - May 6, 2008 - 12:47

Here is the other piece of code for the second error.

Both seem to come from the user_access

if (!user_access('administer forums')) {
foreach ($form['taxonomy'][$vid]['#options'] as $key => $the_rest) {
reset($the_rest->option);
$option_key = key($the_rest->option);
if (!array_key_exists($option_key, $all_results)) {
unset($form['taxonomy'][$vid]['#options'][$key]);

#3

ramsalt - May 16, 2008 - 18:57

The probem is the first item in the options array: - Please choose - This has to be unset for the ongoing code to function. I solved it by unsetting unset($form['taxonomy'][$vid]['#options']['']); It works.

The code will then be:

      if (!user_access('administer forums')) {
      unset($form['taxonomy'][$vid]['#options']['']);
        foreach ($form['taxonomy'][$vid]['#options'] as $key => $the_rest) {

#4

John Morahan - June 4, 2008 - 14:43
Status:active» patch (code needs review)

Here's ramsalt's suggestion as a patch.
Seems to work for me.

AttachmentSize
og_forum-255109.patch430 bytes

#5

rconstantine - July 9, 2008 - 22:01
Status:patch (code needs review)» duplicate

Already fixed in our developer copy and posted in at least two other issues. Will be included in the next release.

 
 

Drupal is a registered trademark of Dries Buytaert.