Hello,

Great module, thanks for it. Using 7.x-1.1. I found while using it that we would get the occasional streak of errors like this:

Notice: Trying to get property of non-object in instagram_block_block_view() (line 131 of sites/all/modules/instagram_block/instagram_block.module)
Warning: Invalid argument supplied for foreach() in instragram_block_block_view() (line 131 of sites/all/modules/instagram_block/instagram_block.module)

Taking a look at the code, it seems that bad Instagram credentials (username, token, etc.) or a non-responsive Instagram can cause the response back from Instagram to be something other than expected. Rather than error out, I've attached a patch that will ensure an expected response.

Thanks,
Matt

Comments

yanniboi’s picture

Status: Active » Needs work

The module has moved on since this patch has been posted. It might need rerolling, but I think that this bug has been fixed anyway...

joelpittet’s picture

Title: Patch: Protect against an unexpected response back from Instagram » Protect against an unexpected response back from Instagram for end user.
Version: 7.x-1.1 » 7.x-1.2
Assigned: m4olivei » Unassigned
Status: Needs work » Needs review
StatusFileSize
new486 bytes

On thing this patch could do is avoid rethrowing the exception and fail to watchdog.

I'd rather see nothing on a block than throwing a big red error to the user when the host goes down or times out which seems to happen often enough for me to see it in the watchdog.

Site: https://example.com
Severity: Error (3)
Timestamp: 2015-02-09 12:51:15
Type: instagram_block
IP Address: 136.243.5.219
Request URI: https://example.com/us/blog
Referrer URI:
User: Guest (0)
Link:
Message:

Exception: Service Unavailable in InstagramRequest->request() (line 99 of
/var/www/example/html/sites/all/modules/contrib/instagram_block/instagram_block.lib.php).

joelpittet’s picture

Issue summary: View changes
StatusFileSize
new41.95 KB

Example error message, by faking the URL:

thijsvdanker’s picture

Status: Needs review » Reviewed & tested by the community

Patch applies cleanly, and it makes a lot of sense not having your entire site fail over an instagram block :)
rtbc!

jacmkno’s picture

Related issue being addressed here: https://www.drupal.org/node/2428913#comment-9659213

yanniboi’s picture

StatusFileSize
new929 bytes

I've updated the patch. What you posted is good, but I also added swapped a watchdog exception for a watchdog in the request call.
Will be committing this shortly.

  • joelpittet authored 5052413 on 7.x-1.x
    Issue #2259207 by joelpittet, yanniboi, m4olivei: Protect against an...
jcalais’s picture

I could not get @yanniboi 's patch to work, because it referenced the lib.php -file that in our case didn't contain the code mentioned in the patch (no mention of Watchdog at all in our file).

The second newest patch by @joelpittet did apply correctly.

yanniboi’s picture

Status: Reviewed & tested by the community » Fixed

My patch has been committed and pushed to 7.x-1.x-dev.

Status: Fixed » Closed (fixed)

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

don greco’s picture

I have a site in a hosting environment and I can not apply patches.
I made a demo site a year ago for a client and they are now looking to see it and I cannot log into it to take it out of maintenance mode because of this error.
Does anyone have any insight ?
this is what I am getting:

Exception: BAD REQUEST in InstagramRequest->request() (line 99 of /hsphere/local/home/xyz/demo.somedomain.com/profiles/multipurpose_corporate_profile/modules/contrib/instagram_block/instagram_block.lib.php).
joelpittet’s picture

Upload the latest release to your site. It should resolve this issue for you.