Magento Mage :: log () calls a white screen

When using the logging tool, Magentos Mage :: log () sometimes causes a white screen. Error messages are not displayed either on the screen or on any log file (var / log / system.log, var / log / exception.log)

This only happens when I try to register a very large object. for example, when I try to do this

Mage::log(Mage::helper('catalog/category')->getStoreCategories()); 

inside the block controller, it brings up a white screen.

the same thing happens when I try to register the current product in app/design/frontend/enterprise/default/template/catalog/product/view/media.phtml using

 Mage::log($_product); 

Usually, Mage :: log () works fine and writes everything to the system.log file.

I was wondering if this happened to someone else or does anyone know why this is happening?

+4
source share
2 answers

Mage::log works just like print_r , prints private and protected values, which include detailed information about resources. You can avoid this by using the Varien_Object::debug method made for purposes.

 Mage::log($_product->debug()); 

debug also preferable because it detects recursion, which not all versions of PHP do.

+10
source

I think this happens to everyone.

Try not to register large objects.

If necessary, I would advise you to use die.

for example, for example

  $ object = ...;
     die ($ object);
 or
     die ('pre html tag'.print_r ($ object, true).' pre html tag ');
+1
source

Source: https://habr.com/ru/post/1395202/


All Articles