Skip to content
This repository has been archived by the owner on Apr 22, 2019. It is now read-only.

Logging not working after setup:di:compile #17

Closed
erikhansen opened this issue May 31, 2016 · 4 comments
Closed

Logging not working after setup:di:compile #17

erikhansen opened this issue May 31, 2016 · 4 comments

Comments

@erikhansen
Copy link
Contributor

erikhansen commented May 31, 2016

Steps to reproduce

  1. Install the AvaTax extension.
  2. Compile using: bin/magento setup:di:compile
  3. Any actions that trigger the AvaTax code will result in this error "$serverData must be an array or object implementing ArrayAccess": image001

Overview of issue

This issue is being caused because the \ClassyLlama\AvaTax\Model\Logger\FileHandler and \ClassyLlama\AvaTax\Model\Logger\DbHandler classes are getting the \Monolog\Processor\WebProcessor class via dependency injection. However whenever Magento \Magento\Framework\ObjectManager\Config\Compiled::getArguments method is called to get the constructor arguments for the \Monolog\Processor\WebProcessor class, since that class doesn't have any arguments specified in di.xml, the WebProcessor class defaults to getting a single argument which is an instance of Magento\Framework\ObjectManagerInterface (see https://github.com/magento/magento2/blob/2.0.6/lib/internal/Magento/Framework/ObjectManager/Config/Compiled.php#L79)

NOTE: This issue hasn't been detected before as Magento has recommended against using the bin/magento setup:di:compile due to issues with it ("There is a known issue with the single-tenant compiler; it does not currently compile proxies. Therefore, if you're preparing to deploy to production, you must use the multi-tenant compiler."), so testing wasn't being done using that compilation method.

@erfanimani
Copy link

I came across this issue, and another way to solve it is to create a virtualType with null arguments for the web processor:

<virtualType name="MyWebProcessor" type="Monolog\Processor\WebProcessor">
    <arguments>
        <argument name="serverData" xsi:type="null"></argument>
        <argument name="extraFields" xsi:type="null"></argument>
    </arguments>
</virtualType>

@erikhansen
Copy link
Contributor Author

@erfanimani Would you be interested in submitting a PR to resolve this issue?

@erfanimani
Copy link

erfanimani commented Jul 4, 2018

My bad @erikhansen — I came across the same root issue, but not in this specific module :)

(This issue comes up #1 for the search "$serverData must be an array or object implementing ArrayAccess.")

@erikhansen
Copy link
Contributor Author

@erfanimani Ok, no problem.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants