Skip to content

Fix notices and failure of deploy static content #7059

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

convenient
Copy link
Contributor

@convenient convenient commented Oct 17, 2016

System notes

The following is run on

The Error

bin/magento setup:static-content:deploy -f
Requested languages: en_US
Requested areas: adminhtml, frontend
Requested themes: Magento/backend, Magento/blank, Magento/luma

  [Exception]
  Notice: Undefined index: arguments in /src/mtwo/lib/internal/Magento/Framework/ObjectManager/Config/Compiled.php on line 132

The problem
I think this issue was introduced with this section of code which adds a fake cache class for static content deployments: DeployStaticContentCommand.php#L493

    private function mockCache()
    {
        $this->objectManager->configure([
            'preferences' => [
                Cache::class => DummyCache::class
            ]
        ]);
    }

This calls configure on the object manager which has a constructor like

    public function __construct($data)
    {
        $this->arguments = $data['arguments'];
        $this->virtualTypes = $data['instanceTypes'];
        $this->preferences = $data['preferences'];
    }

see ObjectManager/Config/Compiled.php#L34 for more

As the fake cache command only passes in the preferences argument we get a notice for arguments and we'd get one for instanceTypes if it got that far. Even if we suppress notices things still won't work, as we'd be wiping out all the legitimate configuration for the di config.

The solution

I think the solution for this would be to do a selective update of the diConfig so that we're only mocking out the cache class and leaving the remainder untouched.

To do this I had to expose the entirety of the arguments stored in the config. This seems to allow the command to run and do its thing. After a di recompile the world seemed to be working again.

A caveat, this is my first foray into the M2 configuration and DI system, my solution could be totally whack. Feel free to say point me in the correct direction if I'm doing something silly 👍

Notice: Undefined index: arguments in /src/magento2/lib/internal/Magento/Framework/ObjectManager/Config/Compiled.php on line 132
Notice: Undefined index: instanceTypes in /src/magento2/lib/internal/Magento/Framework/ObjectManager/Config/Compiled.php on line 133
@convenient
Copy link
Contributor Author

The failing tests look legit, i'll get around to them tomorrow.

@PascalBrouwers
Copy link
Contributor

@dthampy this one seems related to #7108

@convenient
Copy link
Contributor Author

Good spot @PascalBrouwers, it does appear to be the same issue doesn't it.

@AVoskoboinikov
Copy link
Contributor

Hi, guys this issue was already fixed in develop branch. Check this commit f6f3cf8

@convenient convenient deleted the fix/static-content-deploy-cli branch November 7, 2016 11:33
@convenient
Copy link
Contributor Author

@AZVO I got there first by a few days ;)

But f6f3cf8 is by far a better solution, seems legit.

Could you cherry-pick in a42ed22 ? it's a simple typo fix.

magento-engcom-team pushed a commit that referenced this pull request Sep 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants