I'm getting warning: Invalid argument supplied for foreach() in /home/ntumsec/public_html/sites/all/modules/private_upload/private_upload.module on line 287. when I'm browsing through the organic group pages. Using Drupal 5.6 and og 5.0.

CommentFileSizeAuthor
#4 private_upload-287.patch665 bytesbensheldon

Comments

starbow’s picture

Assigned: Unassigned » starbow
Totakeke’s picture

Sorry, but are there any updates on this yet?

bensheldon’s picture

This is the block of code with the example (the foreach is line 287):

if(module_exists('og') && og_is_group_type($node->type)) {
  global $user;
  if( !array_key_exists($node->nid, $user->og_groups) ) { 
    foreach ($node->files as $fid => $file) {    
      if( _private_upload_is_file_private($file->filepath) ) {
        $file->list = false;
      }
    }
  }
}

Basically the issue is that not all nodes may have $node->files set. So I added a check (isset) to the previous if statement:

        if(!array_key_exists($node->nid, $user->og_groups) && isset($node->files)) { 

(Sorry, having some problems actually issuing a patch)

bensheldon’s picture

Status: Active » Needs review
StatusFileSize
new665 bytes

OK, patch attached.

Totakeke’s picture

That works for me, thanks!

starbow’s picture

Status: Needs review » Fixed

Thanks. This has been committed and will get rolled into the next beta.

Anonymous’s picture

Status: Fixed » Closed (fixed)

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