On "People mentored by [name]" pages for not logged in users one can see:
Notice: Undefined property: stdClass::$visibility in profile_view_field() (line 283 of /var/www/git-dev.drupal.org/htdocs/modules/profile/profile.module).

Example: https://git7site.devdrupal.org/profile/profile_my_mentors/jhodgdon

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

eliza411’s picture

Status: Active » Needs review

Thanks for the detailed report!

jthorson’s picture

function profile_view_field($account, $field) {
  // Only allow browsing of private fields for admins, if browsing is enabled,
  // and if a user has permission to view profiles. Note that this check is
  // necessary because a user may always see their own profile.
  $browse = user_access('access user profiles')
        && (user_access('administer users') || $field->visibility != PROFILE_PRIVATE)
        && !empty($field->page);

The error is thrown when the code above reaches the $field->visibility check ... since $field->visibility does not exist ... even though the other field properties do exist. I found a similar core issue from way back (#326607: undefined property: stdclass visibility when viewing profile pages) which resulted in the $field->visibility check going in ... not sure why it would be failing now, though.

The debug_backtrace on this one is essentially profile_browse -> _profile_update_user_fields -> profile_view_field ... but I didn't dig deep enough to determine where the profile fields are actually being defined.

davidhunter’s picture

I cannot replicate the error in pages wit /user/ in the URL/
I can only replicate the error in pages with /profile/ in the path.
i.e. https://git7site.devdrupal.org/profile/profile_conference_prague_2013

jthorson’s picture

Status: Needs review » Postponed (maintainer needs more info)

I'm no longer able to reproduce the 'undefined property' error on git7site ... I wonder if it may just have been an issue with a particular database snapshot?

Postponing for now, as we can not reproduce with the current instructions ... if this doesn't crop back up, then it's probably safe to assume it was data corruption and/or resolved by another issue elsewhere.

Tor Arne Thune’s picture

Status: Postponed (maintainer needs more info) » Needs work

I'm still getting the error (undefined property visibility together with "creating default object from empty value") by going to https://git7site.devdrupal.org/profile/profile_my_mentors/jhodgdon both as anonymous user and logged in user.
Not sure what more info to give, as I don't see how this could be a browser problem or a problem showing up only for those connecting from Europe.

jthorson’s picture

Status: Needs work » Needs review

No ... you're correct ... I was granted an increased level of user permission on drupal.org this week, which masked the issue. Going back as the anonymous user, it's definitely still there.

Back to confirmed ... Thanks!

tvn’s picture

Issue tags: +drupal.org D7

tag

drumm’s picture

Assigned: Unassigned » drumm

I think this is a duplicate of a core issue which I fixed and it got committed. I'll make sure we are running a dev version of core or have this patch applied.

drumm’s picture

drumm’s picture

Status: Needs review » Closed (duplicate)

Ok, I think it was #2046677: Strict warning: Creating default object from empty value in template_preprocess_profile_listing, fixed on Oct 1, which is after problems reported in this issue.

tvn’s picture

Status: Closed (duplicate) » Active
FileSize
92.02 KB

Please double check. Notices are present on git7site right now for not logged in users (see screenshot), e.g.: https://git7site.devdrupal.org/profile/profile_my_mentors/jhodgdon

#2046677 is about "Strict warning: Creating default object from empty value in template_preprocess_profile_listing()". Here we are talking about "Notice: Undefined property: stdClass::$visibility in profile_view_field()".

helmo’s picture

Project: [Archive] Drupal.org D7 upgrade QA » Drupal core
Version: » 7.x-dev
Component: Code » profile.module
Issue tags: +affects drupal.org

Here's a core patch that seems like a logical fix.
Moving to the core queue to get a review.

Tested on http://project-drupal_7.redesign.devdrupal.org/profile/profile_my_mentor...

helmo’s picture

FileSize
716 bytes
helmo’s picture

Status: Active » Needs review
jthorson’s picture

Status: Needs review » Reviewed & tested by the community

I'm not sure what else adding this might potentially affect, but the approach seems reasonable and I can confirm it resolves the issue.

drumm’s picture

Issue tags: -drupal.org D7 +Drupal.org 7.1

Committed to Drupal.org's BZR repo.

drumm’s picture

Issue summary: View changes

.

David_Rothstein’s picture

Issue summary: View changes
Status: Reviewed & tested by the community » Fixed

Looks correct to me too. The extra field eventually gets passed to profile_view_field(), which expects it to be there (and which already gets it passed in the alternate code path in profile_browse(), not visible in the patch file).

Looks like there shouldn't be any side effects except the PHP notice.

Committed to 7.x - thanks! http://drupalcode.org/project/drupal.git/commit/70e25d7

Status: Fixed » Closed (fixed)

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