This is problem when trying to render Commerce Products. The entity_uri call does not take into account whether the entity uri callback returns NULL or not. So entity API should check to make sure a path index exists.

This causes the following error for each product entity being rendered:

Notice: Undefined index: path in template_preprocess_entity() (line 174 of /Users/matt/Sites/acquia-drupal/sites/all/modules/entity/theme/entity.theme.inc)

If not using the dev version of entity API, then the error is:

Notice: Undefined index: path in template_preprocess_entity() (line line 1029 of /Users/matt/Sites/acquia-drupal/sites/all/modules/entity/entity.module)

Comments

jazzdrive3’s picture

Patch attached that checks the 'path" index. This fixes the issue for me.

jazzdrive3’s picture

Status: Active » Needs review

Status: Needs review » Needs work

The last submitted patch, entity-check_path_index_uri-2003826-1.patch, failed testing.

jazzdrive3’s picture

Status: Needs work » Needs review
jazzdrive3’s picture

stella’s picture

StatusFileSize
new946 bytes

I get these errors with the 7.x-1.1 release. Attaching a patch for this version in case it is of use to anyone else who doesn't want to switch to the dev release and use that patch:

Notice: Undefined index: path in template_preprocess_entity() (line 1029 of entity/entity.module).
Notice: Undefined index: path in template_preprocess_entity() (line 1037 of entity/entity.module).

Status: Needs review » Needs work

The last submitted patch, 2003826-6-check_path_index_uri.patch, failed testing.

pog21’s picture

Patch in #1 fixed error on those lines, but I then got an error on line 185. Looks like the following line needs a similar check:
$variables['page'] = $uri && $uri['path'] == $_GET['q'];

I don't know how to make a patch but changing it manually worked for me.

greenmother’s picture

Status: Needs work » Needs review
StatusFileSize
new843 bytes

patch for #1 and #8

Status: Needs review » Needs work

The last submitted patch, entity-check_path_index_uri-2003826-9.patch, failed testing.

greenmother’s picture

StatusFileSize
new844 bytes
greenmother’s picture

Status: Needs work » Needs review
zendka’s picture

The notices disappeared when I enabled commerce customer ui.

greenmother’s picture

I has customer ui enabled. I think this is because of not using product display nodes in my shop, views only.

davidwbarratt’s picture

Status: Needs review » Reviewed & tested by the community

The patched fixed my problem. I was having the problem when trying to render a Commerce Product Entity. Turning on Product UI didn't fix my problem.

Thanks!

stella’s picture

StatusFileSize
new978 bytes

Patch reroll for 7.x-1.x

jenlampton’s picture

+1 RTBC

fago’s picture

Afaik this is a known issue of commerce or core. What's the progress over there, isn't it going to be fixed there?

jazzdrive3’s picture

fago,

I'm not sure which issue you would be referring to. If there is one, please point us there.

I've talked with Ryan and this was the clearest way to fix the issue, since not all entities will necessarily have paths. There isn't really anything to be done on the Commerce side.

ippy’s picture

The two changes in the patch fixed the issue for me. Thank you.

kevinwsauer’s picture

Can anyone help me? Where do I need to apply this patch?

fago’s picture

Status: Reviewed & tested by the community » Closed (won't fix)

Here it is: #1275902: Allow entity URI callbacks to indicate that the entity has no URI, and make the User module use that for anonymous users

So the problem really is an issue of core/commerce, so I don't see why we should work around it here. Let's better fix it in core.

fago’s picture

Issue summary: View changes

Add more details.

jazzdrive3’s picture

Can we not work around it here, while also working to fix in core? At this point, it seems almost impossible to get any patch approved for Drupal 7. I've literally been following several Core issues for over a year, and they can never get to Drupal 7, because they have to first work for the moving target of Drupal 8 before being backported.

astutonet’s picture

#16 solves my issue with template_preprocess_entity does not check for existing 'path' index.

voloda86’s picture

#16 works for entity 7.x-1.2

Exploratus’s picture

16 worked for me.

GuGuss’s picture

Issue summary: View changes

#16 fixed the issue. I'm using Entity 1.3.

acrosman’s picture

#16 worked for me against 1.3 as well. I agree with the above requests to get this committed. Doesn't look like it would conflict if the problem were also fixed in core, and in the meantime it would resolve a problem that's been bugging people for almost a year.

sportel’s picture

I can confirm the patch works!

caw67’s picture

#16 patch works for me

gonssal’s picture

+1 for commiting the patch.

Even if it's a core issue, your code is still wrong because there's no check for the index.

jenlampton’s picture

Status: Closed (won't fix) » Reviewed & tested by the community

Looks like there's a consensus to fix the problem here too, so changing status back to RTBC.

  • fago committed a47dce4 on 7.x-1.x
    Issue #2003826 by greenmother, stella, jazzdrive3, fago: Fixed...
fago’s picture

Status: Reviewed & tested by the community » Fixed

Nope, we are using the API right - it's core who is wrong. Anyway, this is still not fixed in core and obviously bothering people, so let's make our code more bulletproof.

-> I took #16, made parenthese usage consistent and commited it. Thanks!

Status: Fixed » Closed (fixed)

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