Just installed browsercap/ block to hide a slider block on mobile devices, after installation im shown this error constantly.

Notice: Undefined index: ismobiledevice in browscap_block_block_list_alter() (line 78 of /sites/all/modules/browscap_block/browscap_block.module).

and the block set to be hidden is still shown.

I tried using the lates dev version but then the error moves

Notice: Undefined index: ismobiledevice in browscap_block_block_list_alter() (line 83 of /sites/all/modules/browscap_block/browscap_block.module).

CommentFileSizeAuthor
#14 browsecap.JPG49.92 KBchrisdomingo

Comments

Jeff Burnz’s picture

Title: Browser block not hiding block on mobile devices - Notice: Undefined index: ismobiledevice in browscap_block_block_list_alter() » Undefined index: ismobiledevice in browscap_block_block_list_alter()

If $browser['ismobiledevice'] is not set then it can never return TRUE.

What browser/device are you getting this on?

The bug here would be that you get a notice, so we need to check if $browser['ismobiledevice'] isset.

jkirkby’s picture

Well we was getting this error when viewed on desktops haven't tried mobile yet.

checking to see if the variable has been set or not doesn't seem to fix any issues here

jkirkby’s picture

Sorry wasn't checking the syntax right this fixes the error at line 83

  if (!isset($browser['ismobiledevice']) == 1) {
    $is_mobile = TRUE;
  }
  else {
    $is_mobile = FALSE;
  }
jkirkby’s picture

Back to work .....

Even though the error has now gone, browsecap block is still not hiding block for any mobile device. I've configured the blocks to hide for mobile, i've tested on browserstack.com with the ios simulators with safari developer to change the user agent to apple and my own iphone blocks are still displayed.

In the browsecap configuration page it is registering the different user agents so this must be a bug with browsecap block.

I could just display:none the slideshows but the images/code will still be downloaded which defies the point of using this module

Jeff Burnz’s picture

Version: 7.x-1.0 » 7.x-1.x-dev
Status: Active » Postponed (maintainer needs more info)

Well, I can't reproduce this and no one else is saying they have the same problem - being able to reproduce the issue is very important.

Is this live, if so please link to it. I can't do anything more because I cannot reproduce it, so without access to the site, admin, code base etc its not possible for me the guess the issue.

jkirkby91’s picture

Well i was using the dev Browscap Block with rc Browscap that was the duff setup,

Now i switched it round and used the rc browscap block and dev browscap and it works fine?

I have a dev and live environment i can show you the dev with the defunc setup if it would help

Jeff Burnz’s picture

Status: Postponed (maintainer needs more info) » Active

OK, yes I would like to see. Regarding the broken setup - can you attach the .module file from that version, or paste the code from that file.

Jeff Burnz’s picture

Status: Active » Fixed

I've added an isset check, so this is now fixed.

Status: Fixed » Closed (fixed)

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

cllamas’s picture

could you post now the code with the isset included?

thanks

oscardax’s picture

I get the same error in 7.x-1.0.
It would be great if you could post the code or even a patch. Otherwise, may you recommend just downloading the 7.x-1.x-dev version?
Thanks!!

oscardax’s picture

I've tried a minor variation of the code in #3, and seems to be all right.
Thanks!

vonfracas’s picture

Version: 7.x-1.x-dev » 7.x-1.0

Same problem after Browscap 2.0 upgrade. Code in #3 seems to fix it.

chrisdomingo’s picture

StatusFileSize
new49.92 KB

I'm also experiencing this error. I'm using Chrome version 24.0.1312.57 m in my desktop, as well as the mobile firefox version in my android phone.

chrisdomingo’s picture

Status: Closed (fixed) » Reviewed & tested by the community

I found out why I keep on getting these notices. It's quite simple, really. My webserver doesn't have access to the internet, so browscap cannot connect to http://tempdownloads.browserscap.com/versions/version-number.php and http://tempdownloads.browserscap.com/stream.php?BrowsCapINI.

What I did is to download these files and placed them inside the "files' folder of my drupal installation, then edited the corresponding links in "import.inc".

Once these files were recognized by browscap, the notices were gone and the blocks set to be viewed/hidden in mobile were displayed accordingly.

deejmer’s picture

I've done exactly as instructed on #15, but the error persists. I've downloaded those files, staged them on my server. Relative paths didn't seem to work, so I've tried absolute file system path and an absolute URL based path (http://......).

I then tried disabling and re-enabling all browscap modules i have installed (browscap, browscap block and browscap ctools).

Using all the latest stable versions of 7x core and browscap (and Ctools) modules.

Any ideas? Thanks!

Jeff Burnz’s picture

Looking at this as the real fix: http://drupal.org/node/1898936

Problem is here: http://drupal.org/node/1868808

Jeff Burnz’s picture

Status: Reviewed & tested by the community » Active

Change status.

Magic03’s picture

Issue summary: View changes

http://browscap.org/

Important Information
Download URLs

Version:
http://browscap.org/version
http://browscap.org/version-number
Download:
http://browscap.org/stream?q=BrowsCapINI (replace BrowsCapINI with the appropriate version)

import file needs to be updated

TenzAirbrush’s picture

#3 worked for me. Thanks.

ugintl’s picture

#3 worked for me. Thanks.

subir_ghosh’s picture

#3 worked for me as well. Thanks.

namjoo’s picture

  1. Go to http://yourdomain.com/admin/config/system/browscap
  2. check "Enable automatic updates" and save configuration
  3. check "Refresh browscap data" and wait to end updates
  4. finish