Any call to a website with Lightbox2 7.x-2.3 without HTTP_USER_AGENT variable set (one can easily emulate such request with Fiddler) results in a notice:

Notice: Undefined index: HTTP_USER_AGENT in lightbox2_add_files() (line 752 in /sites/all/modules/lightbox2/lightbox2.module).

I suggest changing

'useragent' => $_SERVER['HTTP_USER_AGENT'],

to

'useragent' => empty($_SERVER['HTTP_USER_AGENT']) ? '' : $_SERVER['HTTP_USER_AGENT'],

or something similar.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Ari Linn created an issue. See original summary.

sandipshirsale’s picture

Assigned: Unassigned » sandipshirsale
sandipshirsale’s picture

Assigned: sandipshirsale » Unassigned
Status: Active » Needs review
FileSize
954 bytes

I have created patch. I hope this will help full for you.

sandipshirsale’s picture

Please try this updated patch.

joseph.olstad’s picture

Hmm, requests from clients that refuse to divulge their HTTP_USER_AGENT usually means its originating from bots. Not sure how the best way to handle this is, maybe instead of putting in a blank string '' we should put in the string 'I am a bot refusing to divulge my http_user_agent and I am scanning your site and reporting back to the mother ship, kill this connection now'

victorlap@outlook.com’s picture

Status: Needs review » Reviewed & tested by the community

I communicate with a custom script with my drupal site. Had the same problem as OP. The solutions works! Thank you!

Ari Linn’s picture

Am getting the same error with Lightbox2 7.x-2.8. Is this fix not merged to master yet?

joseph.olstad’s picture

ok, I'll make another release for this. Didn't think it was much of an issue

joseph.olstad’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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