Hello, assistance please.

On Drupal 8.7.7 I installed Mailgun 8.x-1.0-rc1 using composer and all worked well.

composer require drupal/mailgun
drush enable -y mailgun

I was required to uninstalled Mailgun (and Mial System):
drush pm:uninstall mailgun
I then re-installed mailgun. I am now getting the following:
Http\Discovery\Exception\NotFoundException: No PSR-17 url factory found. Install a package from this list: https://packagist.org/providers/psr/http-factory-implementation in Http\Discovery\Psr17FactoryDiscovery::createException() (line 22 of /var/www/mysite.com/vendor/php-http/discovery/src/Psr17FactoryDiscovery.php).
Any ideas how to resolve this?
Thank you

Comments

PatrickMichael created an issue. See original summary.

nickjvm06’s picture

Experiencing the same issue after upgrading to Drupal 8.7.7. Downgrading mailgun/mailgun-php (3.0.0 => 2.8.1) appears to fix things for now.

patrickmichael’s picture

#2 does not seem to solve the issue in my case

patrickmichael’s picture

I ran the following:
composer require kriswallsmith/buzz nyholm/psr7
This removed the PSR-17 message, however I now have:
TypeError: Argument 1 passed to Mailgun\Api\HttpApi::__construct() must implement interface Psr\Http\Client\ClientInterface, instance of Http\Client\Common\PluginClient given, called in /var/www/site.com/vendor/mailgun/mailgun-php/src/Mailgun.php on line 89 in Mailgun\Api\HttpApi->__construct() (line 46 of /var/www/site.com/vendor/mailgun/mailgun-php/src/Api/HttpApi.php).

marcoscano’s picture

Started to see these errors too, when running cron, after upgrading core to 8.7.7 and mailgun/mailgun-php to 3.0.0. Downgrading the latter to 2.8.1 solved the issue for us.

patrickmichael’s picture

@marcoscano perhaps I am not downgrading correctly. Could you assist with what the correct procedure is for downgrading mailgun/mailgun-php to 2.8.1 is? I have just tested on a clean install of Drupal 8.7.7 and Mailgun 1.0-rc1 and the error persists.

The below seemed to work:

I added the following "require": to composer.json, deleted /vendor/mailgun which sorted the issue, thanks all
"mailgun/mailgun-php": "2.8.1"

marcoscano’s picture

In my case I just ran composer require mailgun/mailgun-php:2.8.1.
After doing this, you can check that the version of this library in composer.lock should be 2.8.1 instead of the latest one.
This will have the side-effect though of adding to your composer.json file a line under the "require" group, specifically for the library mailgun/mailgun-php. Unless you really want to pin this library to this version forever, you can just remove this added line in composer.json, without modifying composer.lock.

patrickmichael’s picture

@marcoscano thanks, I will remember that as well, most appreciated.

jcmartinez’s picture

StatusFileSize
new377 bytes

Please note: By the time composer applies the modifications contained in this patch to the module's composer.json file, composer has already read the content of the initial .json file. Therefore; this patch might be useful only to the developer of this module to allow only the versions of mailgun-php beteen 2.3.0 and <3.0.

Since I'm not the developer of the module, I still had to run manually:

composer require mailgun/mailgun-php:"^2.8.1"

After doing the above, I'm getting the following error in my logs:

Warning: require(/app/vendor/mailgun/mailgun-php/src/Mailgun.php): failed to open stream: No such file or directory in require() (line 112 of /app/vendor/symfony/class-loader/ApcClassLoader.php).
require() (Line: 112)
Symfony\Component\ClassLoader\ApcClassLoader->loadClass('Mailgun\Mailgun')
spl_autoload_call('Mailgun\Mailgun') (Line: 37)
Drupal\mailgun\MailgunFactory->create()
call_user_func_array(Array, Array) (Line: 255)
Drupal\Component\DependencyInjection\Container->createService(Array, 'mailgun.mailgun_client') (Line: 173)
Drupal\Component\DependencyInjection\Container->get('mailgun.mailgun_client', 1) (Line: 487)
Drupal\Component\DependencyInjection\Container->resolveServicesAndParameters(Array) (Line: 237)
Drupal\Component\DependencyInjection\Container->createService(Array, 'mailgun.mail_handler') (Line: 173)
Drupal\Component\DependencyInjection\Container->get('mailgun.mail_handler') (Line: 158)
Drupal::service('mailgun.mail_handler') (Line: 186)
Drupal\mailgun\MailgunHandler::checkLibrary() (Line: 56)
mailgun_requirements('runtime')
call_user_func_array('mailgun_requirements', Array) (Line: 403)
Drupal\Core\Extension\ModuleHandler->invokeAll('requirements', Array) (Line: 112)
Drupal\system\SystemManager->listRequirements() (Line: 96)
Drupal\system\SystemManager->checkRequirements() (Line: 102)
Drupal\system\Controller\SystemController->overview('system.admin_config')
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 582)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 151)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 68)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 52)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 693)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

I'm also seeing the following error on /admin/config

Fatal error: require(): Failed opening required '/app/vendor/composer/../mailgun/mailgun-php/src/Mailgun.php' (include_path='/app/vendor/pear/archive_tar:/app/vendor/pear/console_getopt:/app/vendor/pear/pear-core-minimal/src:/app/vendor/pear/pear_exception:.:/usr/local/lib/php') in /app/vendor/symfony/class-loader/ApcClassLoader.php on line 112

Drupal is looking for /app/vendor/mailgun/mailgun-php/src/Mailgun.php but it is located one level deeper inside /app/vendor/mailgun/mailgun-php/src/Mailgun/Mailgun.php

sokru’s picture

Priority: Normal » Critical

Bumped this to critical since this problem causes fatal error both when installing Drupal site with Mailgun dependency or on existing sites using this module. I'd suggest committing patch from #9 and creating follow-up issue "Support mailgun-php:3".

jcmartinez’s picture

I agree that this is critical. People that has mailgun installed may not have realized that it isn't working.

I even tried downgrading the module to 1.0-beta1 and it didn't work either.

joco_sp’s picture

#9 worked for me. I applied the patch and run composer require mailgun/mailgun-php:"^2.8.1"

kuldeep k’s picture

Getting the same issue, applied the above patch and downgrading "mailgun/mailgun-php": "^2.8.1" did not work for me.

Drupal core 8.7.8

abramm’s picture

As a temporary measure, add the following to a project (top-level) composer.json:

"conflict": {
  "mailgun/mailgun-php": ">=3.0"
}

And run:
composer update nothing

This should force installing 2.x.

qsoul’s picture

Can confirm that the solution from #14 works. In my case I also had to uninstall the drupal/mailgun module and reinstall it again after adding the above mentioned "conflict" rule to get 2.x version of mailgun/mailgun-php be installed.

  • Matroskeen committed a9df0a0 on 8.x-1.x
    Issue #3081364 by jcmartinez: No PSR-17 url factory found - restricted...
matroskeen’s picture

Status: Active » Fixed

Thanks everyone for the productive discussion and friendly assistance!

I'm not sure what the hell is going on in Mailgun 3.0+ version, but we'll definitely need to take a look into it.
I would suggest to test PHP SDK apart from the Drupal module and share your solutions on their official github page: https://github.com/mailgun/mailgun-php/issues

In the meantime, I've added a top restriction for the SDK version: https://git.drupalcode.org/project/mailgun/commit/a9df0a0

You are welcome to upgrade Mailgun module to dev version by the following command:
composer require drupal/mailgun:1.x-dev

Please let me know if you have any questions.
Thanks!

abramm’s picture

Is it worth making a new release? The current stable/recommended release is broken right now.

matroskeen’s picture

I think it worth and I like the idea. Thanks!
8.x-1.0-rc2 released 1 November 2019

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.