Skip to content
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

Issue with cloudflare Plugin #34

Closed
bonsdawende opened this issue Nov 5, 2016 · 27 comments
Closed

Issue with cloudflare Plugin #34

bonsdawende opened this issue Nov 5, 2016 · 27 comments

Comments

@bonsdawende
Copy link

Hi,
I got this issue when I activated CloudflarePlugin (in below).
2016/11/05 13:23:54 [error] 5143#5143: *21 FastCGI sent in stderr: "PHP message: PHP Fatal error: Uncaught TypeError: Argument 1 passed to CF\Integration\DefaultIntegration::__construct() must implement interface CF\Integration\ConfigInterface, instance of Magento\Framework\ObjectManager\ObjectManager given, called in vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php on line 93 and defined in vendor/cloudflare/cloudflare-plugin-backend/src/Integration/DefaultIntegration.php:20
Stack trace:
#0 vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php(93): CF\Integration\DefaultIntegration->__construct(Object(Magento\Framework\ObjectManager\ObjectManager))
#1 vendor/magento/framework/ObjectManager/Factory/Compiled.php(88): Magento\Framework\ObjectManager\Factory\AbstractFactory->createObject('CF\Integration\...', Array)
#2 vendor/magento/framework/ObjectManager/Factory/Compiled.php(130): Magento\Framewo" while reading response header from upstream

I followed the steps given to install the module but nothing changed:
From the magento2 root directory run the following commands:
composer require cloudflare/cloudflare-magento
composer update
bin/magento setup:upgrade
bin/magento setup:di:compile

Thanks in advance

@jwineman
Copy link
Contributor

jwineman commented Nov 7, 2016

Hi,

What version of the plugin are you using?
What version of Magento are you using?

Thank,
John

@bonsdawende
Copy link
Author

bonsdawende commented Nov 7, 2016

Hi,
I am using I think the last version 1.0.9.

Thanks in advance for your reply.

Ferdinand

2016-11-07 1:27 GMT+01:00 John Wineman notifications@github.com:

Hi,

What version of the plugin are you using?

Thank,
John


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#34 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AF_wjLswOyeGq61MroadmeXYVRrKBBlOks5q7nBigaJpZM4KqR4y
.

@jwineman
Copy link
Contributor

jwineman commented Nov 8, 2016

Still looking into this - what version of Magento are you running?

@bonsdawende
Copy link
Author

I am using Magento version 2.1.2

2016-11-08 17:57 GMT+01:00 John Wineman notifications@github.com:

Still looking into this - what version of Magento are you running?


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#34 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AF_wjJAwlENw7m7PiAahcHoAgFRugM2eks5q8KnrgaJpZM4KqR4y
.

@jwineman
Copy link
Contributor

jwineman commented Nov 8, 2016

Hi,

My dev environment is 2.0, looks like this is a compatibility issue with 2.1.x. Not sure what the root cause is but I'm setting up a 2.1 environment and working on a fix now! I'll update this issue when I know more.

Thanks,
John

@bonsdawende
Copy link
Author

Hi John,

Please let me know if you find a fix for 2.1.x.

Courage

Thanks.

2016-11-09 0:18 GMT+01:00 John Wineman notifications@github.com:

Hi,

My dev environment is 2.0, looks like this is a compatibility issue with
2.1.x. Not sure what the root cause is but I'm setting up a 2.1 environment
and working on a fix now! I'll update this issue when I know more.

Thanks,
John


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#34 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AF_wjL_xxJ2m9_A8yyDAdVxP1WH2dONOks5q8QMpgaJpZM4KqR4y
.

@jwineman
Copy link
Contributor

Hi,

I'm able to reproduce the issue now and am working on a fix.

Thanks,
John

@jwineman
Copy link
Contributor

Hi,

after running

rm -rf var/*
bin/magento cache:flush

I was able to load the plugin, does this work for you?

@ghost
Copy link

ghost commented Nov 16, 2016

Hello, @jwineman!
This plugin works fine only on development mode.
When you go to production, you need to compile all dependency injections.
You have a problem with Magento DI, and this Exception gives you a good notification about your problem.

With best regards!

@ghost
Copy link

ghost commented Nov 16, 2016

I think:
rm -rf var/**
is very bad idea, because on production environment you will clear logs, preprocessed staff etc, DI compiled files etc.
And this move will get you additional problems.

@jwineman
Copy link
Contributor

Hi @Hawok,

Can you please go into more detail? Before developing this plugin I'd never used magento before so my domain knowledge is lacking.

Doesn't bin\magento setup:di:compile compile the dependency injection graph? We have this as a step after installing the plugin. Is there another command I should be aware of?

Thanks,
John

@ghost
Copy link

ghost commented Nov 16, 2016

Thanks for your fast feedback, @jwineman!

I think you have a problem in di.xml file.
In this file you defined references for CF objects and inject custom objects from Backend.
When Magento processed this file (bin\magento setup:di:compile) and anybody go to the site they get this Exception.
Maybe this issue depends on latest Magento changes in 2.1.x branch.
I think this is a start point of resolving this issue.

Thanks, Dima.

@jwineman
Copy link
Contributor

jwineman commented Nov 16, 2016

The issue is definitely between Magento CE 2.0.x and 2.1.x. However if there is a problem with di.xml I'm not aware what it is. The config in question is:

<type name="\CF\Integration\DefaultIntegration">
        <arguments>
            <argument name="config" xsi:type="object">\CF\Integration\DefaultConfig</argument>
            <argument name="integrationAPI" xsi:type="object">\CloudFlare\Plugin\Backend\MagentoAPI</argument>
            <argument name="dataStore" xsi:type="object">\CloudFlare\Plugin\Backend\DataStore</argument>
            <argument name="logger" xsi:type="object">\Psr\Log\LoggerInterface</argument>
        </arguments>
</type>

The first argument specified is \CF\Integration\DefaultConfig but Magento passes Magento\Framework\ObjectManager\ObjectManager instead. I don't know why Magento isn't injecting the class I specified. It looks like bin\magento cache:flush clears the generated class and forces it to be regenerated correctly though. I'm not sure if rm -rf var/generation is needed.

@ghost
Copy link

ghost commented Nov 16, 2016

If you will run
"bin/magento deploy:mode:set production"
You will see a process of static and DI compilation.
After that U will have this issue again.
When you don't have a compiled DI, Magento will go to all DI.xml and make all injections on the fly.
But I don't understand, why without compiled DI all works fine.
Maybe problems with sort, maybe defects on their compile process.

@jwineman
Copy link
Contributor

Okay this is helpful - thank you! I'll debug further and report back.

@ghost
Copy link

ghost commented Nov 16, 2016

Thank you too!

Would like to help you, but I can debug this problem tomorrow.
If you want to get some understanding of Magento 2 object management you can check http://alanstorm.com/category/magento-2/#magento-2-object-system.

Best regards!

@bonsdawende
Copy link
Author

Hello,
Thanks @jwineman John for your help to debug the issue. I agree with you @Hawok. Effectively if I used the command line rm -rf var/*, I'll loose all the cache...
Let me know please, if you find another idea about that :-)

@jwineman
Copy link
Contributor

jwineman commented Nov 22, 2016

Still looking into this. This issue seems similar but no root cause:
http://magento.stackexchange.com/a/101577

When I run bin/magento deploy:mode:set production it does error like you would expect but not specific enough to debug. Running it a second time it completes successfully. I'm confused.

@ghost
Copy link

ghost commented Dec 1, 2016

Hello, @jwineman!
Yep, this problem depends on var/generation folder. Magento 2 still have this problem on the last release version. Thank you for your work!

@jwineman
Copy link
Contributor

jwineman commented Dec 1, 2016

@Hawok are you saying this is something Magento, not Cloudflare needs to fix?

@ghost
Copy link

ghost commented Dec 6, 2016

This problem depends on Magento 2 DI mechanics. I think you need update README and wait fix from Magento 2.

Thanks,
Dima.

@jwineman
Copy link
Contributor

jwineman commented Dec 6, 2016

I'll submit a bug with Magento and see what happens.

@hardfire
Copy link

Hi, is there an update on this issue? any update from magento?

@andyjv
Copy link

andyjv commented Jan 28, 2017

I just wanted to let you know I have this problem on Magento 2.0.7.

Edit: I was able to circumvent the issue by running setup:di:compile-multi-tenant instead of setup:di:compile

@jwineman
Copy link
Contributor

jwineman commented Feb 3, 2017

Hi Guys,

Sorry I've been slow to reply. I still don't have a root cause for this bug, another work around appears to be running bin/magento deploy:mode:set production twice. Something about having ran setup:di:compile beforehand breaks.

@jwineman
Copy link
Contributor

jwineman commented Apr 2, 2017

Alright I've resolved this issue. Magento allows you to specify a <preference/> in di.xml which tells Magento which implementation to use when a constructor specifies an interface.

http://devdocs.magento.com/guides/v2.0/extension-dev-guide/build/di-xml-file.html#abstraction-implementation-mappings

<preference for="CF\Integration\ConfigInterface" type="CF\Integration\DefaultConfig" />

Fixes the issue. Working on a patch now.

@jwineman
Copy link
Contributor

jwineman commented Apr 2, 2017

Fixed in #47

Can you try upgrading to 1.1.1 and let me know if that fixes the issue?

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

No branches or pull requests

4 participants