backdrop-contrib / profile

Supports configurable user profiles. Port of Drupal Profile2.
GNU General Public License v2.0
0 stars 6 forks source link

Error when overriding profile.tpl.php #35

Open robertgarrigos opened 2 months ago

robertgarrigos commented 2 months ago

Overwriting profile.tpl.php triggers an error:

Warning: Undefined array key "#entity" a template_preprocess_entity_plus() (línia 147 de /Users/robert/Sites/backdrop/modules/entity_plus/theme/entity_plus.theme.inc).
Error: Call to a member function label() on null a entity_label() (línia 774 de /Users/robert/Sites/backdrop/core/modules/entity/entity.module).

I found the same kind of error with paragraphs (https://github.com/backdrop-contrib/paragraphs/issues/91) which has been fixed.

argiepiano commented 2 months ago

What do you mean by "overwriting"? Overriding?

Can you add more specific steps to reproduce? I believe you have Entity Plus enabled (which is not required for this module).

I do see some issues in profile.info.inc which is only used when E+ is enabled. For starters, it has the wrong callbacks: entity_property_verbatim_set and entity_property_getter_method, which don't exist. In Backdrop's Entity Plus, those should be entity_plus_property_verbatim_set and entity_plus_property_getter_method. So perhaps this is in part producing this problem (though I doubt it).

I see another issue, which may also be causing this problem: profile_entity_info() defines a 'label callback' => 'entity_class_label', which doesn't exist in Backdrop. It should probably be 'entity_label'.

If you want to try patching your site with those and seeing if that helps, that'd be helpful to pinpoint the problem.

robertgarrigos commented 2 months ago

Yes, overriding I meant. I need Entity Plus for some other module. Thanks, @argiepiano, those changes didn't fix the problem. Steps are easy, just create a profile and try to override profile.tpl.php file within your theme. Accessing the profile page triggers the error.

argiepiano commented 2 months ago

Did you try clearing caches after the changes? If so, OK, that means that more debugging is needed.

robertgarrigos commented 2 months ago

yep, cache was cleared.

robertgarrigos commented 2 months ago

Commenting the function profile_entity_info_alter(&$entity_info) in profile.module fixes the error. I have been doing actions on profiles with no problem. Is that hook_entity_info_alter() function used at all?

argiepiano commented 2 months ago

Yes, it defines metadata for all of profile properties. You won't be able to use entity_metadata_wrapper with profile entities now. But this also points at the fact that the error is there. Most likely an inexistent callback, like I said above. You probably missed some of those.

To find the culprit, you should look at ALL callbacks specified there (as in setter callback , getter callback and others) and check that the callback function actually exists.

argiepiano commented 2 months ago

Actually, what I just sald above is wrong. profile_entity_info_alter() does not provide metadata. It actually tells your site to use the controller provided by Entity Plus.

So, commenting that out will avoid using E+ entity controller for Profiles in your site. This is an acceptable solution in your case. But the bug needs to be found, since it still exists.

robertgarrigos commented 2 months ago

I'm lost with this bug.

argiepiano commented 2 months ago

If I had the time I'd try to reproduce ... not right now unfortunately.