QuestionQ21

VerifiedTroubleshoot to identify the root cause of issues with Adobe Commerce

While building new website functionality in developer mode with every cache type enabled, an Adobe Commerce Developer must add \Magento\Sales\Model\Service\InvoiceService $invoiceService as a new dependency to an existing page-action controller in Vendor\CustomModule\Controller\Index\Index. This is done as follows:

Question Image

After cleaning the full_page cache and refreshing the page, the developer receives this exception:

Recoverable Error: Argument 2 passed to Vendor\CustomModule\Controller\Index\Index::__construct() must be an instance of \Magento\Sales\Model\Service\InvoiceService [...]

What action should the Architect recommend to resolve this error?

Explanation

A constructor-signature change makes an existing generated interceptor or child class stale: it still calls the parent with the old positional arguments, causing the former second dependency to be passed where InvoiceService is now expected. In developer mode, Adobe Commerce recommends removing generated factories, proxies, and interceptors after modifying a class signature so they are regenerated on demand.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!