2

I'm using Magento Community Edition 1.7.0.2.

LightBox2 stopped working after clearing js/css cache via cache management.

I receive the following error:

PHP Fatal error:  Call to a member function addItem() on a non-object in home/*******/public_html/app/code/community/IG/LightBox2/Block/Catalog/Product/View/Media/Gallery.php on line 163

The front-end now only shows WSOD / blank page.

I have tried:

  • commenting out line 162 & 163,
  • Clearing caches,
  • Logging In/Out,
  • Uncommenting line in index.php to display errors,
  • disabling module,
  • un/reinstalling via magento connect

Any suggestions on where else to go to debug this issue? Or should I just restore from backup?

Will Palmer
  • 5,742
  • 1
  • 26
  • 33
Joshua34
  • 394
  • 2
  • 10
  • given `$something->addItem()`, figure out where $something is NOT being defined properly. the reported line number is merely the first place that you tried to use this non-object improperly. the real error is elsewhere. – Marc B Oct 01 '12 at 22:10
  • @MarcB $this->getLayout()->getBlock('head')->addItem('skin_js', $js); – Joshua34 Oct 01 '12 at 22:13
  • so $this is not being defined within the file Gallery.php? Line 162 is: foreach ($this->_jsList as $js) – Joshua34 Oct 01 '12 at 22:16
  • if $this isn't defined, then you'd have big problems, and would get `call to a member function getLayout` anyways. Most likely getBlock('head') isn't returning anything. – Marc B Oct 01 '12 at 22:20
  • Is there any reason that getBlock('head') would not return anything? It is being referenced in the page.xml file here on line 73: – Joshua34 Oct 01 '12 at 22:47
  • no idea. I don't do magento, but when you get a "X is not an object" thing, that's the first place I'd start looking. – Marc B Oct 01 '12 at 23:37
  • Thanks Marc! Appreciate your help. – Joshua34 Oct 01 '12 at 23:41

1 Answers1

1

First, I'd suggest reaching out to the people who developed you extension for support. The better Magento extension shops and indie developers are always the best people to help you with a problem.

As for your specific problem, the code your error message is complaining about is here

foreach ($this->_jsList as $js)
    $this->getLayout()->getBlock('head')->addItem('skin_js', $js);

Which means the call to $this->getLayout()->getBlock('head') is returning a non-object, mostly likely the boolean "false".

There's only three reasons I could think of for this happening.

  1. You're using this on a page where Magento doesn't instantiate a "head" object

  2. Some other customization you've made/module you've installed attempts to rewrite the page/html_head block class, but does so incorrectly such that Magento can't instantiate a `page/html_head' block

  3. Some other customization you've made/module you've installed removes the head block

Lacking access to anyone with basic Magento skills, I'd start diff-ing your system and/or theme files vs. a standard installation.

Alana Storm
  • 164,128
  • 91
  • 395
  • 599