Drupal 11.3 introduces compatibility with PHP 8.5, in preparation for Drupal 12 requiring PHP 8.5

If I use PHP 8.5 for a site with this module, I get the following errors:

    Deprecated function: Mailgun\Mailgun::__construct(): Implicitly marking parameter $hydrator as nullable is deprecated, the explicit nullable type must be used instead in include() (line 576 of {composer-root}/vendor/composer/ClassLoader.php).
    Deprecated function: Mailgun\Mailgun::__construct(): Implicitly marking parameter $requestBuilder as nullable is deprecated, the explicit nullable type must be used instead in include() (line 576 of {composer-root}/vendor/composer/ClassLoader.php).
    Deprecated function: Mailgun\Api\Domain::create(): Implicitly marking parameter $smtpPass as nullable is deprecated, the explicit nullable type must be used instead in include() (line 576 of {composer-root}/vendor/composer/ClassLoader.php).
    Deprecated function: Mailgun\Api\Domain::create(): Implicitly marking parameter $spamAction as nullable is deprecated, the explicit nullable type must be used instead in include() (line 576 of {composer-root}/vendor/composer/ClassLoader.php).
    Deprecated function: Mailgun\Api\Domain::create(): Implicitly marking parameter $wildcard as nullable is deprecated, the explicit nullable type must be used instead in include() (line 576 of {composer-root}/vendor/composer/ClassLoader.php).
    Deprecated function: Mailgun\Api\Domain::create(): Implicitly marking parameter $forceDkimAuthority as nullable is deprecated, the explicit nullable type must be used instead in include() (line 576 of {composer-root}/vendor/composer/ClassLoader.php).

This is fine with PHP 8.4

Issue fork mailgun-3564209

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

jamesoakley created an issue. See original summary.

jamesoakley’s picture

OK, so this is an issue with the mailgun library that is included, not with the code in this module itself

Currently we have this in composer.json

    "require": {
        "mailgun/mailgun-php": "~3.0",

The mailgun/mailgun-php package has 4.3.5 as its most recent release, so I'm guessing PHP 8.5 compatibility was not included in the 3.x branch.

jamesoakley’s picture

Title: PHP 8.5 errors » PHP 8.4 / 8.5 errors

Correction, I am now getting those same errors in PHP 8.4. As-is, this module only works with PHP 8.3 latest.

jamesoakley’s picture

Status: Active » Needs review
StatusFileSize
new472 bytes

Confirming that this merge request fixes this problem on my sites. Attached as a patch version

johnpicozzi’s picture

I'm also having this issue after upgrading to php 8.4. The patch above does update the composer requirements as expected. However composer won't install that requirement without use of the lenient package. I suggest merging this patch and cutting a new release.

jamesoakley’s picture

John, I agree this needs merging and a new release tagging.

If you think the patch addresses the issue, so this is ready to merge, please change the status to RTBC. I can't, because it's my patch, and I don't maintain the module. That will signal to the maintainers that we believe this patch to be ready for merging.

In the meantime, you're right that you can't change a project's composer.json file using composer patches. However, you can switch to using the issue fork.

In the repositories section of your master composer.json file, exclude mailgun from the drupal packages declaration, then add this issue's fork as an additional repository:

 	    "repositories": [
	        {
	            "type": "composer",
	            "url": "https://packages.drupal.org/8",
	            "exclude": ["drupal/mailgun"]
	        },
	        {
	            "type": "git",
	            "url": "https://git.drupalcode.org/issue/mailgun-3564209.git"
	        },

Then change the drupal/mailgun entry in the require section, so it now looks like this:

"drupal/mailgun": "dev-3564209-php-8.4-errors as 2.1.x-dev",

The easiest way to do that is to use the composer command, so it updates the lock file at the same time:

composer require drupal/mailgun:3564209-php-8.4-errors

Here's hoping we can get a new tagged release soon, so these work-arounds are soon redundant.

johnpicozzi’s picture

Status: Needs review » Reviewed & tested by the community
aaronbauman’s picture

RTBC+1

aaronbauman’s picture

Posting related / tangential issue here for posterity, and because I don't know where else to post it.

I ran into an incompatibility between this module and simplesamlphp_auth, even with the update to mailgun-php 4 in this thread, because of mailgun-php's dependency on an old version of webmozart/assert.

Here's the PR that got things going for me: https://github.com/mailgun/mailgun-php/pull/949

Any my composer.json looks like this:

  "repositories": [
        {
            "type": "git",
            "url": "https://git.drupalcode.org/issue/mailgun-3564209.git"
        },
        {
            "type": "git",
            "url": "https://github.com/aaronbauman/mailgun-php.git"
        },
        {
            "type": "composer",
            "url": "https://packages.drupal.org/8",
            "exclude": ["drupal/notification", "drupal/mailgun"]
        }
  ],
  "require": {
    "drupal/mailgun": "dev-3564209-php-8.4-errors as 2.1.x-dev",
    "mailgun/mailgun-php": "dev-webmozarts-assert as 4.1"
  }
jamesoakley’s picture

Aaron, not sure whether it belongs in the issue queue for the mailgun module or the simplesamlphp_auth module, but it sounds like a different issue from this one. I'd suggest creating a new issue just for this. It can then be moved between the issue queues of the two modules, as needed. If you think it relates to this issue, you can always cross-reference the issues to each other using the related issues field.

aaronbauman’s picture

Yes, good suggestion, and my apologies for derailing this thread.

Opened a new issue here: #3580037: Incompatibility between mailgun module, simplesamlphp_auth module, mailgun php library, and latest version of webmozart/assert

ben.hamelin’s picture

RTBC+1

Note @jamesoakley - following your composer.json guidelines did not work for me exactly, I had to run (in DDEV of course)
ddev composer require "drupal/mailgun:dev-3564209-php-8.4-errors as 2.1.x-dev" -W
Adding the quotes and the -W flag to ensure mailgun update happened as well.

Please let me know if there's anything else I can do to get this tagged as a release, thanks!

fizcs3’s picture

usingsession’s picture

RTBC+1
I created the new pipeline. Tests passed.

  • bohart committed 7ebde4a3 on 2.2.x authored by jamesoakley
    task: #3564209 Update mailgun library to 4.x (from 3.x) for PHP 8.4+...
bohart’s picture

Title: PHP 8.4 / 8.5 errors » Update mailgun library to 4.x (from 3.x) for PHP 8.4+ compatibility
Version: 2.1.x-dev » 2.2.x-dev
Status: Reviewed & tested by the community » Fixed

This has been merged into a new 2.2.x-dev (will be a part of a future 2.2.0 release).

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.