Postponed (maintainer needs more info)
Project:
Organic Groups
Version:
7.x-1.1
Component:
og-field-access
Priority:
Normal
Category:
Bug report
Assigned:
Reporter:
Created:
8 Jun 2011 at 12:43 UTC
Updated:
5 Aug 2015 at 17:06 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
amitaibuYou seem to have something wrong in your Drupal setup, as hook_field_access() is expected to get the full $field array. The fact you don't have the field_name points that something is wrong. You should try it with a clean installation and only OG installed.
Comment #2
jolidog commentedHi Amitaibu,
I've encountered the same error on a clean instalation.
Disabled all other modules and did some tests, I've narrowed down the problem to an image field on the group content type, where I use the private file system to store the image.
If I use the public files the error is gone.
Any Ideas?
Comment #3
spacereactor commentedi have this issue.
Notice: Undefined index: field_name in og_field_access_field_access() (line 60 of /var/www/mydomain.com/public_html/sites/all/modules/og/og_field_access/og_field_access.module).
From a private group, i upload a private photo into that private group. I try to access with another user that isn't belong that private group and i get Access denied which is what i want but there is error message that come with it.
Comment #4
spacereactor commentedI enable "Organic groups field access" and no more error.
Comment #5
spacereactor commentedmy mistake still getting the error in log.
Comment #6
spacereactor commentedI start again from a new drupal 7.2 and install only the below modules and this time no error. I have to enable other modules and see which one cause the error. Report back if find anything.
- Chaos tools 7.x-1.x-dev
- OG create permissions 7.x-1.0
- Organic groups 7.x-1.1-rc3
- Organic groups access control 7.x-1.1-rc3
- Organic groups UI 7.x-1.1-rc3
- Entity API 7.x-1.x-dev
- Views 7.x-3.x-dev
- Views UI 7.x-3.x-dev
One thing i notice that my first attempt at admin/config/group/group-membership there is "default" membership. When i start from a fresh drupal 7.2 there isn't this "default" membership type, i have to create a new new membership type, no sure if this is one that cause the error. Hope this help someone.
Comment #7
spacereactor commentedI think is a related problem with http://drupal.org/node/1200974
Comment #8
amitaibuIs the error on a specific type of field?
Also core is assuming we have a field name -- http://api.drupal.org/api/drupal/modules--field--field.api.php/function/...
Comment #9
spacereactor commentedSo far I tested, it only happen to cck image field with private upload setting. if the image field is under public upload it will not cause the error. Sorry not a programmer, hope you understand what i saying.
Comment #10
jason89s commentedOG isn't the only module that's producing the "Undefined index: field_name" error right now. I'm also seeing it on a views generated page that groups results together by date. I have OG installed, but this error is appearing on a page not affiliated with OG. I think it may be related since these problems happened very close to the same time.
My case was reported by another person here: #1194240: Problem with the aggregator.
Comment #11
spacereactor commentedTest with latest OG 7.x-1.x-dev 2011-Jun-30 still having the same problem
Replace back to OG 7.x-1.1-rc3 and error is gone. So between OG 7.x-1.1-rc3 to OG 7.x-1.x-dev new function is added and cause this error.
Comment #12
spacereactor commentedi install the latest 7.x-1.x-dev 2011-Jul-08. Still having error there is node showing private image field. Any solution?
Comment #13
spacereactor commentedI think i find the problem but don't how to make a patch for this. anyway this is what i change
edit this file og/og_field_access/og_field_access.module
Comment #14
spacereactor commentedthe above code doesn't work. Can someone help out?
Comment #15
webflo commentedI have same error but only for file fields with private download.
Backtrace for reference:
Comment #16
spacereactor commentedThe new OG RC4 also have this issue whenever image private is display. Is there a fix on this?
Notice: Undefined index: field_name in og_ui_field_access() (line 278 of /var/www/mydomain.com/public_html/sites/all/modules/og/og_ui/og_ui.module).
Comment #17
amitaibuOn a clean installation and private file system, I've added an image field on the group and group content. I don't get a notice.
Comment #18
spacereactor commented#17 is your image upload as private file?
I install a fresh drupal 7.7, install the following modules
1.) Chaos tool suite (ctools) 7.x-1.0-rc1
2.) Entity API 7.x-1.0-beta10
3.) Organic groups 7.x-1.1-rc4
4.) Views 7.x-3.0-rc1
enable the following,
1. Chaos tools
2. Organic groups
3. Organic groups access control
4. Organic groups UI
5. Entity API
6. Views
7. Views UI
Make two content type, Group and group article. Create a private group, create a private group article with private photo under that private group. And i get the below error whenever private image is display.
Notice: Undefined index: field_name in og_ui_field_access() (line 278 of /Applications/MAMP/htdocs/drupal7/sites/all/modules/og/og_ui/og_ui.module).
Comment #19
spacereactor commentedMiss out another photo to show the error
Comment #20
amitaibu@spacereactor , can you attach the DB of #18?
Comment #21
spacereactor commentedthis is my database
Comment #22
amitaibu@spacereactor,
In which node 1 or 2 do you see the error? With anonymous or with uid 1? I wasn't able to reproduce.
Comment #23
spacereactor commentedbecause it a private group, try using uid 1, node 2 is the one contain private image, but you only have the database and doesn't have the actual image at your site/default/file/private folder. Error will appear with OG and private image. Try create a new group basic content and upload a private photo. Do make sure you have a site/default/file/private folder to store your private file.
Comment #24
TudorGroza commentedHi,
I've encountered the same problem: I have a content type which is a group content type and has some image fields that are stored as private files. Not only I get this notice, but I cannot even see the images.
Comment #25
seddonym commentedHere's my understanding of the issue, which happens when a user downloads a private file:
- file_file_download() runs, which figures out which field the file belongs to;
- it then calls field_access() on the field to see if the user has access to that field;
- field_access() invokes og_ui_field_access(), which tests to see if the $field is the field used to determine the the organic groups audience with the following code:
- For some reason, $field at this point does not contain a 'field_name' index, so it triggers the notice.
Suggestion:
I can't work out if this is strictly speaking a bug with Drupal core (specifically with the file field). However I think we can be sure that if 'field_name' isn't set, organic groups doesn't need to worry about this field, therefore we can probably do this?
Comment #26
amitaibu> isset($field['field_name'])
We can do it ofcourse , but it's fixing the symptom instead of the problem , so I prefer to understand the cause
Comment #27
seddonym commentedOk, in that case I've filed a Drupal core bug report here. If they come back by saying it's 'by design' then perhaps we could make the suggested change?
Comment #28
seddonym commentedUpdate - it looks like the issue is indeed one with Drupal core, so I guess we wait for that to be fixed!
Comment #29
matt bSubscribe
Comment #30
dpolant commentedI encountered this problem and tracked it down to file_file_download() in modules/file/file.module. The issue is that this function is feeding the output of field_get_items() into field_access as the $field argument. field_get_items() just returns field values in an entity object that are already stored in memory. So the field_get_items() call is redundant because that data is available in the $entity argument of field_access(), and doesn't provide useful metadata about the field being checked.
Anyway, the attached patch to file.module should solve the problem. It calls field_read_field() and gets a proper field data object to pass into field_access().
PS sorry I didn't have time to check if the patch applies cleanly, but its a two liner so it should be easy to integrate if it won't apply.
Comment #31
MrPhilbert commentedSorry, but tried the patch and got w.s.o.d. Besides, hacking core is not such a good idea.
Comment #32
amitaibuDpolant, you should submit the patch in the core issue. Make sure it applies if you want someone to check it :)
Comment #33
dpolant commentedHmm the patch had a problem with the header but it should have applied alright and it did fix the problem on my install without crashing the site. MrPhilbert, can you find out from watchdog or your error log what the error actually was? This will help me fix the problem.
I think in this case it is ok to provide a solution that affects core files because this issue is acknowledged to stem from faulty code in a core file (i.e. if the patch works some one will commit it to drupal core).
Anyway, I put the patch in the core issue: http://drupal.org/node/1245220#comment-4871024 after fixing it so that it applies cleanly.
Comment #34
MrPhilbert commentedThanks.
I'm just downloading the update and will try again.
Comment #35
matt bThese notices are also being issued on 7.x-1.1
Comment #36
emmajane commentedI created another issue for this same issue. I do have a simple fix within OG at #1252710: Private files, access permissions and og_field_access_field_access. (It doesn't make the private files "private" ... it just fixes the missing field_access setting.)
Comment #37
bluestarstudios commentedDid anybody get a final patch working for Drupal 7.8? I need to get rid of these errors and open up file access to other group members. Thanks
Comment #38
stevecory commentedUsing Drupal version 7.10 a new_content_type was added. New fields were added.
The Field Types and Widgets were set to "File" with "Public - accessible to all site users" access.
The uploaded files reside in a Private file directory /var/www/files.
The Access Control module was added, and the "role based access control settings" has checks in
"View any content" for the "anonymous user". Under the Organic groups global permissions,
the setting for View the new field for existing groups has been selected.
Links to the uploaded files appear, however, when the anonymous user selects the link to
download the file the following error appears:
Notice: Undefined index: field_name in og_field_access_field_access() (line 60 of
/var/www/html/sitename/sites/all/modules/og/og_field_access/og_field_access.module).
And the page shows:
Access Denied
You are not authorized to access this page.
Returning back to the pages added with the content type, then removing the uploaded
files allows the administrator to Manage fields in the content type and make it so
the Upload destination is Public files. The files can then be uploaded once more
and they are accessible by the anonymous user.
Comment #39
vikramy commentedIt is happening in "image" field type with private upload setting. User 1 can see the image but group member/non-member cannot see and that user is getting the above error message.
Even the latest dev [Jan 04 2012] has this error.
Sorry this was a core bug.
Patch 11 @ http://drupal.org/node/1245220 solved this issue. Thanks everyone
Comment #40
ldegoursac@gmail.com commentedVikramy, Thanks for your note about the patch that works. However, the link you put in your post results in "access denied" when I click on it, so I just used the patch in #30 (I fixed the header). The good new is that there is a simple fix for this issue. The bad news it still hasnt been incorporated and I am not sure what it means that the link to it says access denied. Does that mean the patch isn't going to be incorporated in the next core release do you think? I'd love to hear from anyone who knows.
Comment #41
David_Rothstein commentedSorry, the Drupal core issue at #1245220: file_file_download() passed bogus $field to field_access() gave "access denied" for a while because we had to unpublish it for security reasons (it turned out to be related to a security issue in Drupal 7).
That fix is now released in Drupal 7.11 (see http://drupal.org/node/1425084), so perhaps people should check whether the bug being discussed here is fixed as long as you are using Organic Groups in combination with Drupal 7.11 or higher?
Comment #42
Hardik C commentedHi,
Please replace your og.module file in og module directory with the attached module file. It will resolve this issue.
I made few code changes in this file and it is working perfect for me. Hope, it will be helpful to you,too. :) :)
Comment #43
vali hutchison commentedI had the same sort if issue - non site admins couldn't download private files uploaded to OG content types and upgrading to drupal 7.12 fixed it. So relieved as was driving me mad.
Comment #44
Alexis Brun commentedGreat ! Tks Hardick C. !
Your patch works perfectly for me. (no more issue)
It's a releif.
Comment #45
akshita commentedThank you Hardik - MY issue related is solved by just replacing the following code:
My Issue was : • Warning: Illegal string offset 'field_name' in og_ui_field_access() (line 269 of /var/www/html/sites/all/modules/og/og_ui/og_ui.module).
if (!isset($field['field_name']) || $field['field_name'] != OG_AUDIENCE_FIELD) {
// if ($field['field_name'] != OG_AUDIENCE_FIELD) {
return;
But I have one more issue related to theme hook not sure from where it is coming. This is displayed in the recent log messages only when opened or created a press release:
Warning:Theme hook field_issues not found.
Any help is appreciated.
Thanks in advance.