firegento / firegento-pdf

Generates nicer and configurable PDF for invoices, creditmemos and shippings in Magento
100 stars 62 forks source link

Call to a member function instructions() on null #377

Closed Morgy93 closed 6 years ago

Morgy93 commented 6 years ago

Error: PHP Fatal error: Call to a member function instructions() on null in /lib/Zend/Pdf/Canvas/Abstract.php on line 173

This is caused by: https://github.com/firegento/firegento-pdf/blob/development/src/app/code/community/FireGento/Pdf/Model/Engine/Invoice/Default.php#L126

var_dump($this->colors['header']):

array(2) {
  ["black"]=>
  object(Zend_Pdf_Color_GrayScale)#491 (1) {
    ["_grayLevel":"Zend_Pdf_Color_GrayScale":private]=>
    object(Zend_Pdf_Element_Numeric)#475 (2) {
      ["value"]=>
      int(0)
      ["_parentObject":"Zend_Pdf_Element":private]=>
      NULL
    }
  }
  ["grey1"]=>
  object(Zend_Pdf_Color_GrayScale)#490 (1) {
    ["_grayLevel":"Zend_Pdf_Color_GrayScale":private]=>
    object(Zend_Pdf_Element_Numeric)#489 (2) {
      ["value"]=>
      float(0.9)
      ["_parentObject":"Zend_Pdf_Element":private]=>
      NULL
    }
  }
}

So in fact "header" index is missing here.

As a workaround I added

        $helper = Mage::helper('firegento_pdf');

        $this->colors['text']   = $helper->getTextColor();
        $this->colors['labels'] = $helper->getLabelColor();
        $this->colors['header'] = $helper->getHeaderColor();
        $this->colors['footer'] = $helper->getFooterColor();

to the method which is working fine, but also tells me that https://github.com/firegento/firegento-pdf/blob/development/src/app/code/community/FireGento/Pdf/Model/Engine/Abstract.php#L69 is not called.

Sadly I didn't dig deeper into it yet, but maybe someone else has some clue to this already?

sprankhub commented 6 years ago

Could you share the output of Mage::getStoreConfig('sales_pdf/firegento_pdf_colors/table_header') in your store? You can e.g. check this via n98-magerun.phar dev:console.

Morgy93 commented 6 years ago

I was curious what n98-magerun.phar dev:console actually does, but I'm only getting: PHP Fatal error: Cannot instantiate interface Psy\VersionUpdater\Checker in phar:///var/www/web61/htdocs/production/n98-magerun.phar/vendor/psy/psysh/src/Psy/functions.php on line 56

However, .. Mage::getStoreConfig('sales_pdf/firegento_pdf_colors/table_header') returns the backend value just fine, else my workaround using $this->colors['header'] = Mage::helper('firegento_pdf')->getHeaderColor(); wouldn't work. (Which means the helper function works as well)

sprankhub commented 6 years ago

Your n98-magerun error sounds like a local issue with your hosting provider / your local .n98-magerun plugins.

The parent constructor is definitely called and I cannot imagine a situation where this does not work. It sounds like a local problem. I do not see any possibility how we can debug this issue for you. If you can reproduce the issue on a clean system, feel free to re-open with more information. For the time being, I close this as non-reproducable.