Closed (fixed)
Project:
Mobile Tools
Version:
7.x-3.x-dev
Component:
Code
Priority:
Critical
Category:
Bug report
Assigned:
Reporter:
Created:
31 Dec 2011 at 15:11 UTC
Updated:
21 Jun 2012 at 17:51 UTC
Jump to comment: Most recent file
I have just downloaded mobile tools dev version and all of the required modules along with. I went to context to create a context and the I get the following error on all my pages:
Warning: Invalid argument supplied for foreach() in mobile_tools_context_init() (line 23 of /home/clients/websites/w_saros/public_html/saros/sites/all/modules/contrib/mobile_tools/mobile_tools_context/mobile_tools_context.module).
Is there a patch or something that I am missing?
| Comment | File | Size | Author |
|---|---|---|---|
| #18 | device-group-array-mobile-tools-1390572-18.patch | 1.56 KB | devin carlson |
| #17 | device-group-array-mobile-tools-1390572-17.patch | 895 bytes | yashadev |
| #15 | bool-array-fix-mobile-tools-context-1390572-15.patch | 974 bytes | yashadev |
| #13 | bool-array-fix-mobile-tools-context-1390572-13.patch | 998 bytes | yashadev |
Comments
Comment #1
jlea9378 commentedI'm getting the same error. I'm using the Dec-14-2011 7.x-2.x-dev version of Mobile Tools and the Dec-23-2011 7.x-3.x-dev version of Context.
Comment #2
leewoodman commentedsubscribe
Comment #3
mellenger commentedany update on this. I'm just getting my mobile modules set up and this came up.
Comment #4
mikefyfer commentedSame here:
Mobile Tools 7.x-2.x-dev
Context 7.x-3.0-beta2
Persistent URL 7.x-1.0-beta1
Chaos tools 7.x-1.0-rc1
Spaces 7.x-3.x-dev
Features 7.x-1.0-beta6
ThemeKey 7.x-2.0
but now that i see there isn't a stable release of any of those, it doesn't really surprise me...
Comment #5
play4quarters commentedI'm having the same issue.
Any update available please?
thanks!
Comment #6
jsfwd commentedThe problem is that on line 23:
$devices = mobile_tools_get_active_device_group() <-- returns the active device groups as an array, FALSE otherwise.
So if you have no active device groups and a boolean is returned then it will break the foreach().
Around line 23, there needs to be a type check to make sure $devices is an array...
Comment #7
dddbbb commentedSame error right here.
7.x-2.x-dev, 2011-Dec-14
Comment #8
merilainen commentedThe fix mentioned in #6 gets rid of the error message, but when I use devel's dsm function to see what the $device contains (dsm($device);), I don't get anything else than an empty array with three empty cells.
Comment #9
jlea9378 commentedAny chance the fix in #6 (which solves the problem on my installation) can get committed to Dev?
Comment #10
areikiera commentedAlso an issue on the 7.x-3.x-dev version. Could someone provide guidance on how to correct for that version, and the file that the fix should be applied to?
Thanks!
Comment #11
jlea9378 commentedI'm also getting this in the mobile_tools 7.x-3.x-dev (2012-Apr-25) release.
Warning: Invalid argument supplied for foreach() in mobile_tools_context_init() (line 20 of /var/www/html/drupal_test/sites/all/modules/mobile_tools/mobile_tools_context/mobile_tools_context.module).
Comment #12
jlea9378 commentedThe fix in comment #6 worked for me.
Comment #13
yashadev commentedHere's a patch that will fix the bool-array bug specified above
Comment #14
Jeff Burnz commentedPatch applies with one white space error, fixes the issue. I don't know enough about this to RTBC but the error message does go away.
$plugin->execute($group['type']);Comment #15
yashadev commentedShould be no white space trailing
Comment #16
awolfey commentedI wonder if it might be better to fix mobile_tools_get_active_device_group() so that it returns an empty array instead of false. However, it looks like other functions are expecting a string to be returned. See mobile_tools_html_head_alter(&$head_elements) for one example.
So maybe there's more work to be done here.
Comment #17
yashadev commentedVery good point. The variable returned, $device_groups, is set to an array containing and id and a type of the mobile device; the functions that are calling mobile_tools_get_active_device_group() are expecting to get an array back. So yeah, I think it's better to return an empty array if it's not set rather than returning FALSE. I also checked the functions that are calling mobile_tools_get_active_device_group(), and they either check if the variable returned is empty or equal to a certain value.
Example:
and
So the following patch fixes the mobile_tools_get_active_device_group() function to return an empty array in case it isn't set instead of returning a FALSE value.
Please test it and let me know if the error still exists.
Comment #18
devin carlson commentedAn updated patch that includes the fix in #17 along with some additional documentation changes.
Comment #19
devin carlson commentedCommitted to 7.x-3.x.
As awolfey said in #16,
mobile_tools_html_head_alter()checks to see if the value returned frommobile_tools_get_active_device_groupis a string but the way the function works now, that will never work. This patch does nothing to break or fix that functionality, so I'm committing it.A separate issue should be opened up to fix
mobile_tools_html_head_alter().