Hello,

As you may notice, recently I've added support of Metatag module for Profile2 (#1858512: Add Metatag integration for Profile2 pages). Metatags work only for separate profile pages, and that is absolutely okay. But profile2 module has one interesting feature for separate pages - if user didn't add any content to his profile (actually, didn't save his profile at least once), then a profile page is still available, but profile2 entity generates on the fly with default values (no raw for this profile entity in the database). As a result, this entity doesn't have entity ID value. This issue leads to the following php warnings on an unsaved user profile:

The reason of this warning is that in metatag_generate_entity_metatags() you are trying to reload entity by ID, which is actually empty (who can expect that, huh?). Patch that solves this issue is attached.

Steps to reproduce:
1. Enable Profile2 and Profile2 pages modules.
2. Add any metatags for profile2 entity.
3. Go to /profile-main page. You'll see that warning there.

So if user doesn't have created profile yet and metatags support is enabled, then you will see those warnings there.

Comments

spleshka’s picture

Issue summary: View changes
damienmckenna’s picture

Thanks, I'll give this a review and try to get it into 1.5.

spleshka’s picture

Cool, looking forward for that!

damienmckenna’s picture

This should be safe as it only affects the values used to compile the cache ID. Normally it would use $entity_id as one of the most obvious & important values, however because that is empty it would have to rely upon the URL being different instead. Does Profile2 Pages provide different URLs for each user's profile2-type page for that user, e.g. "user/123/profile2-test", or is it uniform for all users, e.g. "user/profile2-test"?

spleshka’s picture

Actually, both variants are possible. Profile pages work the same way as user page in Drupal: if you request only /profile-main page, it will show your profile. If you request /profile-main/[uid] then it will show specified profile of user with chosen uid.

damienmckenna’s picture

So, given Metatag's caching, how well do the meta tags look on the /profile-page -style page? In fact, does this introduce problems with the token-based default values?

spleshka’s picture

Tokens there display well, but I didn't test metatags with tokens on that page, so can't tell you for sure if there are any issues with token-based default values. Will test this soon.

spleshka’s picture

Test showed that for profile page when profile doesn't exist no field values can be fetched for tokens (both default and not default). So, no entity == no fields data available, no matter if that value is default or not.

damienmckenna’s picture

Status: Needs review » Fixed

Ok, I think this is an acceptable change for this (slightly odd) scenario.

spleshka’s picture

I agree, that is the best solution we can make here. Otherwise we should change A LOT in profile2 :) Thanks for commiting this!

Status: Fixed » Closed (fixed)

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