When I save a user profile form (using profile2) I get the following:

Notice: Undefined property: stdClass::$name in taxonomy_access_field_attach_validate() (line 299 of /var/www/mysite/profiles/myprofile/modules/contrib/taxonomy_access/taxonomy_access.module).

It seems to be that in this case the $entity isn't what is expected.

Files: 
CommentFileSizeAuthor
#20 taxonomy_access-profile2-1362210-20.patch1002 bytesrooby
#6 profile2.patch981 bytesxjm
PASSED: [[SimpleTest]]: [MySQL] 2,240 pass(es).
[ View ]
#4 taxonomy_access-profile2-1362210-4.patch811 bytesrooby
PASSED: [[SimpleTest]]: [MySQL] 2,227 pass(es).
[ View ]
#3 taxonomy_access-profile_entity_dumps-1362210-3.txt32.97 KBrooby

Comments

Thanks @rooby. Two questions:

  1. Could you give steps to reproduce the issue?
  2. Does this only occur when the Profile2 module is installed?

Status:Active» Postponed (maintainer needs more info)

Status:Postponed (maintainer needs more info)» Active
StatusFileSize
new32.97 KB

Sorry, I've been sidetracked from this for a bit.

I tried the same field directly on a user and there is no error.
It is only when the field is on a profile.

I have included a file with dumps of the $entity variable on line 299.
Dumps are for the user account page save (which works correctly), and the profile page save (which doesn't work properly).
The profile one is missing all the user data.

I am using tac to control node access but also have terms on user profiles (vocabs unrelated to the access).

I think all you would need to do to reproduct is to have a site running tac and adda user profile and add to that a term field and then save a user profile.

Version:7.x-1.0-rc1» 7.x-1.x-dev
Status:Active» Needs review
StatusFileSize
new811 bytes
PASSED: [[SimpleTest]]: [MySQL] 2,227 pass(es).
[ View ]

The problem actually seems to be that when you save a profile2 form it runs through the validation twice. Once for the user entity (for which it passes an incomplete entity) and once for the profile (which workds as expected).

So the error is being thrown on the first run through and then everything works as expected on the second, which explains why the error wasn't actually causing any problems for me.

Something like this patch fixes it.

Oh, yuck. I do so hate this part of the Field API. Also, I think this might explain a problem I had during early testing but have not reproduced since.

The patch looks like a reasonable approach. I'll give it a closer look at some point (hopefully soon).

StatusFileSize
new981 bytes
PASSED: [[SimpleTest]]: [MySQL] 2,240 pass(es).
[ View ]

Here's a slightly cleaned-up version of the patch, moved about a little because I'm concerned though that there's no branch of logic for the validation pass that triggers this error. Does the "entity" have an entity ID at that point? Does entity_extract_ids() work on it? (I hate that function.)

Could you check? Thanks!

I had the same error after installing Simplenews. I was using 7.x-1.0-rc1 I upgraded to dev (so I had something to apply the patch to), applied the patch in #6 and the error is gone. I was not using the profile2 module, although I will probably move to that before the site goes live.

Interesting. I'll try to see what might be causing this with simplenews as well.

@xjm:
Sorry, I have been off the project I needed this for for a while, I'll check it out soon.

From looking at the code in the patch though the solution looks fine.

@ehowland:
The simple news error seems a little odd.
What page are you on when you get this error, the user account edit page or somewhere else?
Is your error exactly the same as the one in the original post or is it just similar?

I have removed simplenews and moved to views_send and views_bulk_operations, which is a better fit for me. But I remember that I would see it every time I returned to the list of newsletters. I believe I had defined a newsletter before I saw this error.

I got the same problem after installing CiviCRM to my development site. CiviCRM adds a profile-like contact form to every user account.

I have not yet applied the patch, mainly because I am not sure how to do it. If someone can direct me to a relatively simple set of instructions for applying a patch to a hosted Linux server, I would be grateful. I will also, of course, let you know if it worked.

I have TAC rc1 installed.

Many thanks.

Depends what system you are on.
I don't know about windows but on other systems, put the patch in your tac module directory go there in the terminal and type
patch -p1 < patch-file-name.patch

For more information see http://drupal.org/node/1399218
(A lot of that page relates to using git to patch but there is some other info in there too)

If it doesn't apply properly due to your using a different version you may want to update to the dev version of the module.

Or you can look in the patch file and make the changes to the module manually.

Lines with a preceeding minus are removed and lines with a preceeding plus are added.

You can also reverse patches with
patch -p1 -R < patch-file-name.patch

This can be useful for reverting if a patch only half applies and you want to reverse the changes it made to the module.

Sory, I missed the part where you said linux.
The patch command will work fine.

Thanks, rooby.

The patch in #6 seems to also fix the problem with CiviCRM. I am very grateful.

Will this patch be included in the next version of Taxonomy Access?

Thanks @Rodney N and @rooby. I'll dig around in these modules' code and see what I can find.

Status:Fixed» Closed (fixed)

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

Ran into this today trying to do a bulk operation with VBO and updating to the most recent dev fixed it for me.

FYI for those who want to patch RC1 instead of use dev, the patch in #6 is equivalent to what was committed in #16.

The only difference is a small change to a comment.

StatusFileSize
new1002 bytes

Actually, here is the same as what was committed, but in a patch for 7.x-1.0-rc1