After enabbling this (GREAT!) module, without further configuration i get a WSOD in a commerce checkout:
mod_fcgid: stderr: PHP Fatal error: Cannot access empty property in .../sites/all/modules/display_cache/display_cache.module on line 280, referer: http://example.com/cart

Did not investigate further yet, of course this may be due to another module.

Comments

geek-merlin’s picture

Offending code:

    $bundle = $entity->{$bundle_key};

Looks like the code assumes every entity has a bundle key. Commerce orders do not.

Caseledde’s picture

Thanks for your report. I will investigate this problem soon.

zhl841129’s picture

Status: Active » Needs review
StatusFileSize
new806 bytes

This patch provides a fallback if there is no bundle available. I checked and it looks like $bundle is only used by display_cache internally and should not care whether it's a legitimate bundle or not (it just creates a cache key, of sorts).

Caseledde’s picture

kars-t’s picture

Hi

I added one more occurence of "bundle" and some minor codingstyle changes. I am quiet sure that this patch will work. But we would really need some help with a meaningfull test.

geek-merlin’s picture

i do not get why we need all this complexity introduced in #4.
if an entity declares no bundle, a bundle named like the entity is created implicitly.
so why not as simple as #2 changed to:

$bundle = !empty($entity->{$bundle_key}) ? $entity->{$bundle_key} : $entity_type; // did not check $entity_type is defined here...
thedavidmeister’s picture

#6 makes sense to me, and appears to work when I applied it manually.

Can someone explain clearly why we need the extra code in #4 and #5?

geek-merlin’s picture

StatusFileSize
new940 bytes

Patch flying in.

thedavidmeister’s picture

Status: Needs review » Needs work

I'm actually getting notices with #6:

Notice: Undefined index: bundle keys in display_cache_view_entity() (line 290 of /srv/bindings/7a0d2b55f77a4b45ac5bd2f7e8416abe/code/sites/all/modules/contrib/display_cache/display_cache.module).

geek-merlin’s picture

line 290 does not have this index here when applied #8 to dev. (it's "else {")
please post your line 290 in context.

thedavidmeister’s picture

    // Disable display_cache by global setting.
    if (variable_get('display_cache_disable', FALSE) === FALSE) {
      $entity_info = entity_get_info($entity_type);
      if (!empty($entity_info['entity keys']['bundle'])) {
        $bundle_key = $entity_info['entity keys']['bundle'];
      }
      else {
        $bundle_key = $entity_info['bundle keys']['bundle'];
      }

      $bundle = !empty($entity->{$bundle_key}) ? $entity->{$bundle_key} : $entity_type;
      $settings = display_cache_get_settings($entity_type, $bundle, $view_mode);

Line 290 for me, after applying #8 is $bundle_key = $entity_info['bundle keys']['bundle']; inside the else {}

thedavidmeister’s picture

This is for user entities, btw.

thedavidmeister’s picture

Status: Needs work » Needs review
StatusFileSize
new1.11 KB

patch.

geek-merlin’s picture

YES this #13 totally makes sense.

thedavidmeister’s picture

rtbc then?

geek-merlin’s picture

we need a 2nd person to test that to rtbc.
(unfortunately i don't have an installation to do so right now and no time to set one up.)

nimek’s picture

I have same issue in ubercart. Cant access to cart

Patch 13 solved problem but line 177 should also be changed to
$bundle = isset($build['#bundle']) ? $build['#bundle'] : null;

otherwise watchdog will save a lot of notices about undefined #bundle property.

With this quick fix now it works :)

@axel please add patch with line 177 to official release because without that your mod looks like dev version ;)

  • Kars-T committed 2dddc98 on 7.x-1.x
    Issue #2152653 by axel.rutz, thedavidmeister, Caseledde, zhl841129, Kars...
kars-t’s picture

Hi

I added the patch to the latest dev.
A minor change I did is that I changed the long ternary operation to a "real" if()

Thank you all for your work! :)

kars-t’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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