Skip to content

Add ClassDiscovery::safeClassExists #111

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

Merged
merged 2 commits into from
Oct 31, 2018
Merged

Add ClassDiscovery::safeClassExists #111

merged 2 commits into from
Oct 31, 2018

Conversation

Nyholm
Copy link
Member

@Nyholm Nyholm commented Aug 17, 2018

Q A
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Related tickets fixes #107
Documentation
License MIT

What's in this PR?

This is an alternative to #110.

Copy link
Contributor

@dbu dbu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@Nyholm
Copy link
Member Author

Nyholm commented Aug 17, 2018

@localheinz could you try this patch? Does it work for you?

@localheinz
Copy link

@dbu @Nyholm

Will do, give me a moment!

@localheinz
Copy link

Unfortunately fails with

Warning: include(Nyholm\Psr7\Request.php): failed to open stream: No such file or directory  in /www/shop/lib/Varien/Autoload.php on line 94

Personally, though, I have worked around the issue by creating the client without using php-http/discovery. Works fine for my use case (legacy application), but might not for others.

@Nyholm
Copy link
Member Author

Nyholm commented Aug 17, 2018

That is strange.. I tried to reproduce and the patch do work.

@localheinz
Copy link

@Nyholm

Maybe a cache issue, let me try again!

@localheinz
Copy link

@Nyholm

No, issue still persists. But don't worry, I assume this Magento installation (1.9.1.2) has been patched a bit, maybe that's an issue.

Warning: include(Nyholm\Psr7\Request.php): failed to open stream: No such file or directory  in /www/shop/lib/Varien/Autoload.php on line 94

#0 /www/shop/lib/Varien/Autoload.php(94): mageCoreErrorHandler(2, 'include(Nyholm\\...', '/www/shop/lib/V...', 94, Array)
#1 /www/shop/lib/Varien/Autoload.php(94): include()
#2 [internal function]: Varien_Autoload->autoload('Nyholm\\Psr7\\Req...')
#3 [internal function]: spl_autoload_call('Nyholm\\Psr7\\Req...')
#4 /www/shop/vendor/php-http/discovery/src/ClassDiscovery.php(165): is_callable(Array)
#5 /www/shop/vendor/php-http/discovery/src/ClassDiscovery.php(63): Http\Discovery\ClassDiscovery::evaluateCondition(Array)
#6 /www/shop/vendor/php-http/discovery/src/MessageFactoryDiscovery.php(25): Http\Discovery\ClassDiscovery::findOneByType('Http\\Message\\Me...')
#7 /www/shop/vendor/foo/bar-api/src/Client.php(104): Http\Discovery\MessageFactoryDiscovery::find()
#8 /www/shop/app/code/local/Foo/Bar/Helper/Externalservice.php(37): Foo\Bar\Api\Client::create(Object(Http\Adapter\Guzzle6\Client))
#9 /www/shop/app/Mage.php(557): Foo_Bar_Helper_Externalservice->__construct()
#10 /www/shop/app/code/local/Foo/Bar/controllers/CategoryController.php(29): Mage::helper('coursemanager/e...')
#11 /www/shop/app/code/local/Foo/Bar/controllers/CategoryController.php(19): Foo_Bar_CategoryController->api()
#12 /www/shop/app/code/core/Mage/Core/Controller/Varien/Action.php(418): Foo_Bar_CategoryController->listAction()
#13 /www/shop/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(254): Mage_Core_Controller_Varien_Action->dispatch('list')
#14 /www/shop/app/code/core/Mage/Core/Controller/Varien/Front.php(172): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#15 /www/shop/app/code/core/Mage/Core/Model/App.php(365): Mage_Core_Controller_Varien_Front->dispatch()
#16 /www/shop/app/Mage.php(693): Mage_Core_Model_App->run(Array)
#17 /www/shop/index.php(94): Mage::run('default', 'store')
#18 {main}

@Nyholm
Copy link
Member Author

Nyholm commented Aug 17, 2018

Okey. I cloned https://github.com/magento/magento2. Tested with last commit (which is the same as version 2.2.5).

Should we consider this as an accepted solution or should we try to target Magento 1 as well?

@localheinz
Copy link

@Nyholm

I can't say, since I have worked around the issue, it's not pressing at the moment. Maybe some of the people who commented on #105 or #107 might be interested, though.

Either way, thank you for your efforts! 👍

@dbu
Copy link
Contributor

dbu commented Oct 31, 2018

should we merge this?

@Nyholm
Copy link
Member Author

Nyholm commented Oct 31, 2018

Yes please

@dbu dbu merged commit 9fcc4c9 into master Oct 31, 2018
@dbu dbu deleted the patch-107b branch October 31, 2018 11:07
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.

Composer dependency missing?
3 participants