Closed (fixed)
Project:
Mobile Tools
Version:
6.x-1.12
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Reporter:
Created:
22 Apr 2010 at 15:22 UTC
Updated:
9 May 2010 at 21:31 UTC
This one took me a while to find and narrow down, but mobile tools interferes with other modules, such as forum access due to $form['account']['roles']['#default_value'] <<
When you are editing a user, you see all the roles.. including "anonymous" when mobile tools is enabled. Apparently that is messing with forum access. See thread here:
Comments
Comment #1
salvisThe idea of this...
... seems to be to remove some roles. If that's what you want to do, then do just that — don't replace $form['account']['roles']['#options'] but unset() the $form['account']['roles']['#options'][$rid]'s that you want to remove.
Otherwise you trample over data that may already have been massaged in some way, for example by the roleassign module.
Is there a reason why you used unset() if you were going to reassign $form['account']['roles']['#options'] anyway?
This doesn't explain why $form['account']['roles']['#default_value'] is trashed, but let's fix the obvious issue first, and maybe the other one will go away. I wonder whether you need to remove the $rids from the #default_values, too, though. FAPI may not like encountering an item in #default_values that doesn't correspond to any of the checkboxes.
@Yappyfox: What's your PHP version? Do you really use an old version of mobile_tools?
Comment #2
twom commentedHi,
Thanks for pointing this out. The mobile role system is rather experimental. I'll fix the user roles settings so it does not interfere.
I'll keep you posted.
Twom
Comment #3
Yappyfox commentedPHP Ver 5.2.9 (I tried to goto 5.3, but that major trashed a drupal 5 site I had, so I had to roll back.)
Mobile tools was current with the modules web site mobile_tools-6.x-1.12, I had tried -dev, but it still had the same issue, and added some header problem, so currently I just have it disabled.
Comment #4
Yappyfox commentedComment #5
twom commentedI submitted a fix to the dev version. However, it is very unlikely that this has caused the error in other modules. This piece of codes just alters a form when editing a profile.
I hope someone can test this out! (wait till the new dev package is build)
Comment #6
salvisThe change looks good. It's definitely an improvement, but I agree that it's probably not the cause of the original problem.
You may have to add something like
inside the loop to avoid having checkmarks for non-existing checkboxes. I can imagine that this might cause problems.
Comment #7
twom commentedHi,
Thanks for the extra code. However, the purpose of the form alter is to make sure that for a specific user, the 'mobile' roles can not be checked. No user 'has' the mobile user roles. They are being assigned automatically when he visits the mobile site.
So 'normally' the case of checkmarks for not-existing checkboxes should not happen.
What do you think?
Tom
Comment #8
salvisAh, ok, that makes sense.
@Yappyfox: have you tried the -dev version yet?
Comment #9
Yappyfox commentedYes! everything plays nice in -DEV I appreciate both of your's help in resolving this issue. No more PHP Errors :>
Comment #10
twom commentedCool. Happy to know things work fine now!
Thanks to salvis for fixing this!
Comment #11
salvisYou're welcome.
I've seen weird behavior of PHP in this area before — it's always a good idea to tread as lightly as possible when massaging existing arrays.