I've got this issue today and I got a fix for it but I want to make sure I do the right thing with my fix.

E_ERROR Error in file »profile2_page.module« at line 198: Call to undefined method MetatagEntityMock::type()

I have Profile2 and the Metatag modules enabled.

function profile2_page_uri_callback($profile) {
  $type = $profile->type();
  if (!empty($type->data['use_page'])) {
    return array('path' => profile2_page_get_base_path($type) . '/' . $profile->uid);
  }
  // Fall back to the default callback.
  return $profile->defaultUri();
}

The $profile object contains only a pid value. In other cases (when I load the page /user/ID ) this function is called with a fully loaded profile which allows to check for the type.

I fixed it by checking if we have a type in the supplied object. Is this good enough?

Comments

daniel bornman’s picture

Got the same issue and the original patch fixes it for me. Might be safer to check if we're dealing with a valid profile instance though as it ensures all methods are available?

Edit: Forgot to add, this is still an issue in the 7.x-1.x branch and the patch is against that.

daniel bornman’s picture

Sorry for all the noise but it seems the issue rather lies with the metatag module calling entity uri callbacks using MetatagEntityMock objects.

Issue for profile2 pages here: https://www.drupal.org/node/2516870
And fwiw. similar issue with ECK entities: https://www.drupal.org/node/2514812

robit8deb’s picture

This worked thanks. I tried updating the latest metatag dev from yesterday before patching just to see and it was no bueno.

bocaj’s picture

Version: 7.x-1.3 » 7.x-1.x-dev

I had an issue where I was trying to add a custom View to the list of tabs for a given user. For example, I created a path in Views like so: user/%/projects. I kept getting a WSOD and could not figure out what was going on. After testing different things for quite awhile I finally narrowed it down to the Profile2 Page submodule. After doing some modifications in the profile2_page.module file I finally narrowed it down to the profile2_page_uri_callback() function. Doing some Googling brought me to this page. I applied the patch in #1 (manually since it is small and I didn't want to go through the whole git setup just to try this out) and everything started working properly. I too have Profile2 Page and Metatag enabled.

Might be worth keeping an eye on #2524460: White screen due to Metatag, OG Vocab, Organic Groups and Profile2 since it doesn't sound like this is really a Profile2 issue. However, this patch does work for now :)

hockey2112’s picture

I had the same issue today with a site using the 7.x-1.6 version. I updated to 7.x-1.7, problem solved.

bocaj’s picture

Status: Active » Closed (works as designed)

Doesn't appear that this is an issue now that Metatag 1.7 has been released with this fix.