Closed (fixed)
Project:
OG Forum
Version:
5.x-2.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Reporter:
Created:
3 Jan 2008 at 20:51 UTC
Updated:
1 Oct 2008 at 10:50 UTC
Jump to comment: Most recent, Most recent file
Hi,
I get this error message when I go to 'Create Forum topic' in an Organic group. I only get it when I am authenticated user, not admin.
* warning: reset() [function.reset]: Passed variable is not an array or object in /example/sites/default/modules/og_forum/og_forum.module on line 712.
* warning: key() [function.key]: Passed variable is not an array or object in /example/sites/default/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 /example/sites/default/modules/og_forum/og_forum.module on line 714.
Thanks!
Seth
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | Backtrace_forum.htm_.txt | 221.82 KB | seth97 |
Comments
Comment #1
rconstantine commentedI think this may be a duplicate of this: http://drupal.org/node/200835
Notice that line 712 (yours) and line 749 (his) have the same code. Perhaps you both use a module which adds a bogus selection value to the drop down list?
Should you attach a backtrace (using the devel module), please zip the html page as a complete page (which will include a folder with css and such) so that it will be easier to read than the one in the issue I mentioned.
In any case, some other module is screwing with the forum taxonomy before this module gets it, so disable, one by one, any taxonomy modules you are using (besides taxonomy of course) to find out which.
Comment #2
seth97 commentedHi!
Not sure what it could be.
I don't have that.
What I have in common with http://drupal.org/node/200835 is that I just upgraded from 5.3 to 5.5. Before it worked fine to 'Create Forum topic'.
Thanks!
Seth
Comment #3
seth97 commentedAnd the backtrace:
Comment #4
seth97 commentedfile
Comment #5
rconstantine commentedActually, you have the same exact --please choose-- as in the other post as you can see here:
So we need to find out where this is coming from since it isn't there for my install. I have noticed an increase in problems since Drupal 5.5 came out. I haven't gotten around to upgrading myself, though I have downloaded it. Perhaps Drupal is to blame? Could you poke around a bit and try to find out? Are you using D5.5? If not, what other modules are you using?
Comment #6
seth97 commentedYes I have D5.5!
Everything was working fine before with D5.3. I haven't seen this error before. I haven't installed any new modules lately.
/Seth
Comment #7
rconstantine commentedHmm. Check and see if the taxonomy module changed. Do you keep your installations in a repository like SVN or CVS? That would be an easy way to check. If we can pinpoint what changed in Drupal to screw this up, I can come up with some kind of solution.
Comment #8
seth97 commentedYou are right it is something with the Taxonomy module!!
No, I don't.
I tired this: I downloaded the Taxonomy module 5.3 (from the D5.3 release, http://drupal.org/node/3060/release). Then I went to my D5.5 site and replaced the Taxonomy 5.5 with the 5.3 module. Then the error message is gone when I 'Create Forum topic'!!!
I know that there was a security issue with Taxonomy 5.3, but at least the error message is gone! Maybe this could help you to figure out what is wrong.
Thanks!
Comment #9
rconstantine commentedAlright, I'll take a look. It should be a simple matter to do a diff of the files and see what changed. I don't see how adding a non-option increases security. What a pain in the butt! Unfortunately, since it is CORE, I'll have to accommodate it. Phooey!
Comment #10
dkruglyak commented+1 for fixing this in 5.5. I believe this also belongs to 2.x-dev branch.
Comment #11
Anonymous (not verified) commentedI have the same problem. I followed Seth's suggestions (#8) and installed the Taxonomy module from Drupal 5.3 and it all works fine. So it is definitely something related to that.
Comment #12
rconstantine commentedThis caused the problem: http://drupal.org/node/180109
I don't like it at all and I think it was a bad move to port the 6.x fix to 5.x as it clearly affects more modules than this one.
In checking the changes between the 5.3 and 5.5 versions of the taxonomy module, I see that there are two sections changed due to the issue above, and one other section changed which probably had the security fix.
I'll see what the difficulty would be in adapting to the new ugly code. Meanwhile, I would suggest that you apply the security portion of the changes to your 5.3 version. I use a windows program called WinMerge to visually inspect differences in file versions and move code from one to another easily.
Comment #13
rconstantine commentedNevermind about applying one portion of the 5.5 to the 5.3 version. Instead, try this on og_forum. Sorry I'm not doing a patch right now, but my version has gone quite a bit away from yours. If one of you can test this and report that it works, I will post a new official release which includes it (and the stuff in dev).
What you do is this:
1) find the two instances of this code:
foreach ($form['taxonomy'][$vid]['#options'] as $key => $the_rest) {which are in the og_forum_form_alter function.2) immediately after them, insert this code:
It should allow the routine to skip the invalid item and run as normal.
Comment #14
rconstantine commentedComment #15
Anonymous (not verified) commentedIt works for me!
Comment #16
seth97 commentedSeems to work fine for me too!
Thanks!
Comment #17
rconstantine commentedThanks guys. I'll try to roll out a new release in the next day or two.
Comment #18
dkruglyak commentedExcellent. I would suggest equivalent, but more compact code:
Comment #19
rconstantine commentedThat doesn't follow the Drupal coding standard. All if statements are supposed to have braces for any commands issued if the condition is met.
Comment #20
dkruglyak commentedNo problem. I just got too used to our more compact coding style. I would still use 'empty' expression though, as more precise.
Comment #21
rconstantine commentedNormally, I would use empty as well. Strictly speaking though, using an 'if' to test for one result is more precise than using an 'empty' which has more than one possible true outcome. Neither approach is more right than the other. As the conversation in the thread I mentioned in #12 focused on the empty string for the key, and as other changes and/or modules could introduce other keys that 'empty' would return true for, and as we wouldn't know about those other cases, which might need different handling, unless an error is thrown, I think I'll stick to checking for an empty string. That way if other changes are made, you good people that post issues will run into them and alert me. Hopefully my explanation as to why satisfies you, although technically, you are free to change your version as you wish.
Comment #22
swirtI am getting the same error Seth reported in the initial post using Drupal 5.6 and OG Forum 5.x-2.1
The error does not appear when trying to add a forum topic when logged in as Admin, but when logged in as any other user the error is generated and no options for selecting the particular group appear in the Forums: pull-down or in the Groups: Dropdown.
I have made the two alterations described in #13 and still receive the same error (only the line numbers change to show the added lines)
The errors only appear when these 2 conditions are met:
1) logged in as someone other than user1
2) when trying to add a forum using mysite.com/node/add/forum?gids[]=21 ( or any other forum reference number - error does not appear when using mysite.com/node/add/forum)
Comment #23
rconstantine commentedThe first error should not have its line number change since you were supposed to add the code after it. So I'll assume you meant that only the second one's changed. Feel free to cut and paste your modified form_alter function in your next post. Perhaps we'll find something wrong there. Did you have the problem with D5.5? I wonder if another issue has been introduced from D5.5 to D5.6...
In any case, I'm going to need much more data than you have provided since I can't duplicate your problem. Also, you needn't have changed the version number just because you aren't using 2.x. The original change was to show that both versions were affected and as 2.x is the latest, it should make sense to keep it set to that.
Try following comment #4's example.
Comment #24
swirtApologies about changing the version, I thought I was reporting the version I was using.
You are right, the first line number did not change, only the latter 2.
THis is a new site so it started from scratch as 5.6.
In a fit of desperation (needed results fast) I solved the problem by actually modifying the "group details" block to not append the "?gids[]=21" to the Create Forum topic menu link. I know it was not a wise modification but I needed to solve the problem before daylight.
I'll revert it back on the test site and give you the backtrace data. (It'll take me a bit of time)
Comment #25
softtouch commentedSo, for the newbie and non-programmer, whats now the solution to do?
Comment #26
rconstantine commentedEither wait for me to get around to rolling the change in #13 into a release, or make the change yourself with any text editor.
Comment #27
nath commentedThanks, this code was helpful.
Comment #28
rconstantine commentedComment #29
slowtrain commentedSee next msg.
Comment #30
slowtrain commentedHi folks: I can't seem to fix this problem w/ the above advice. I am running OG forum 5.x-2.1. I tried adding the if ($key == '') code in the appropriate places in the og_forum.module. I still get exactly the warning msgs above whenever someone tries to add a new forum topic. Do I need to restart apache or erase some cache copies of the module somewhere?
The weird thing is I'm running OG forum 5.x-2.1 on my test site as well, without the if ($key...) code changes, but am not getting these warning msgs. The two sites have somewhat different versions of drupal: 5.2 for the test site and 5.5 for the server (and it wants 5.7). Does this mean I should move my server back to drupal 5.2?
Peter
Comment #31
slowtrain commentedBTW the exact version of og_forum I'm running is: * @version $Id: og_forum.module,v 1.11.2.11.2.11 2007/10/26 19:38:05.
Comment #32
rconstantine commentedAs mentioned clearly somewhere above, the change in Drupal versions is the cause of the problem. Did you cut and paste the exact three lines of code, or did you retype? Sometimes there are issues in retyping.
No, there are no caches for php files, only the generated pages for anonymous users, which shouldn't be a problem. You also should not need to restart Apache. You could revert your live site to Drupal 5.2 (or 5.3, I think that was before the changes), and then get this all working with the latest Drupal 5.7 on your test site before moving it back over.
A silly question: you didn't make the code changes on your test site and then forget to upload them to the live site before testing did you? Make sure.
Comment #33
slowtrain commentedHi rconstantine:
Sorry about missing the point about change of versions being responsible--was doing this at 3am trying to get a site up for a research project.
I did retype the code, so I'll go back and copy / paste to give that a whirl. I did the code changes straight into the 'production' site.
I think I can follow the update instructions to try to down-date, but part of these instructions won't work in the reverse direction--e.g. there's no php script to revert a database structure to a prior version. So, might I not create some serious problems trying to go from 5.5 to 5.2?
Thanks so much for your input!
Peter
Comment #34
slowtrain commentedProblem solved! I altered my og_forum.module again, as suggested above, and now my installation doesn't get the warning msgs. Whew! When I first changed the module, I thought the if ($key == '') needed to go after the foreach loop, not inside it. My bad. It's great that there's such an attentive contributor community for drupal.
Peter
Comment #35
dkruglyak commentedThis just goes to show why it is a bad idea to post "instructions" for hacking the code.
Patch files is the only way to avoid such errors.
Comment #36
rconstantine commented@dkruglyak I already said 'uncle', but I realize I'm taking a while getting the next version out. I'm picking up a co-maintainer and we'll be getting together to go over this and other modules of mine. He'll hopefully be able to stay on top of the 'easy' fixes and releases like this one. I think we're getting together on Monday. Stay tuned.
Comment #37
kev52 commentedi have changed the code but now i have an other error.
warning: Invalid argument supplied for foreach() in /www/htdocs/w008b8c6/vereinsmeier/sites/all/modules/og_forum/og_forum.module on line 1104.Here the Code:
Comment #38
Anonymous (not verified) commentedWe have a solution for this problem which will be pushed hopefully by the end of the week
Comment #39
rconstantine commentedComment #40
Anonymous (not verified) commentedPlease download the latest development snapshop to resolve this issue , thanks.
Comment #41
francoud commentedI am experiencing exactly the same problem with Drupal 5.10; i downloaded the latest 5.x.2.x-dev but I STILL have lot or errors like this:
warning: reset() [function.reset]: Passed variable is not an array or object in
[...]og_forum\og_forum.module on line 1220.
when creating new forum topic with urls like "...node/add/forum/87?gids[]=5"...
I replaced
if ($key == '') {
continue;
}
with
if ($the_test->option == '') {
continue;
}
and now no more warning... and it seems working; but I dont know what's the final effect ;)