Skip to content

PHP 8.6 fix: patch pear/mail_mime to use instanceof instead of is_a() - #38304

Open
monishdeb wants to merge 1 commit into
civicrm:masterfrom
JMAConsulting:php86_fix_tests
Open

monishdeb wants to merge 1 commit into
civicrm:masterfrom
JMAConsulting:php86_fix_tests

Conversation

@monishdeb

@monishdeb monishdeb commented Nov 26, 2026 •

Copy link
Copy Markdown
Member

Fixes :

TypeError: array_merge(): Argument #1 must be of type array, null given

Origin: tests/phpunit/CRM/Activity/BAO/ActivityTest.php:1707

  1. CRM_Activity_BAO_ActivityTest::testSendEmailWillReplaceTokensUniquelyForEachContact3TypeError: array_merge(): Argument #1 (closed) must be of type array, null given
    Origin: tests/phpunit/CRM/Activity/BAO/ActivityTest.php:1707

CRM_Activity_BAO_ActivityTest::testSendEmailWillReplaceTokensUniquelyForEachContact3

Failed asserting that 1 is identical to 2.

Origin: CRM/Activity/BAO/ActivityTest.php:1760

  1. CRM_Activity_BAO_ActivityTest::testSendEmailDoesNotDuplicateAttachmentFileIDsForActivitiesCreated

Before

This test sends one email to three contacts via CRM_Utils_Mail::send($mailParams) with attachment. During this it calls pear/mail_mime while building attachment. In that library, PHP 8.6 deprecates calling is_a() with a string first argument. And these deprecations are treated as exception. Then CRM_Utils_Mail::send catches that exception and return FALSE here. Hence the target contact don't get created here as it doesn't reach this point. This eventually fails at tests/phpunit/CRM/Activity/BAO/ActivityTest.php:1707

After

Replaced all is_a() in pear/mail_mime to instanceof and one place in core. This fixes all deprecation notices and clears the path for the unit-test.

Technical Details

The latest state of https://github.com/pear/Mail_Mime has partially fixed 8.6 deprecation notice - commit. So I thought its better to patch the pear/mail_mime . But as I don't have enough privilege to publish the patch file. I followed the doc here to generate the patch. If this PR is approved please publish https://download.civicrm.org/patches/9c5ac4dfb7575adf131e7ee023aa2bb1b730b85b48133d96111e8ca4914af48e/php-86-is-a.patch

Comments

ping @colemanw @seamuslee001 @JoeMurray

@civibot

civibot Bot commented Nov 26, 2026

Copy link
Copy Markdown

🤖 Thank you for contributing to CiviCRM! ❤️ We will need to test and review this PR. 👷

Introduction for new contributors...
  • If this is your first PR, an admin will greenlight automated testing with the command ok to test or add to whitelist.
  • A series of tests will automatically run. You can see the results at the bottom of this page (if there are any problems, it will include a link to see what went wrong).
  • A demo site will be built where anyone can try out a version of CiviCRM that includes your changes.
  • If this process needs to be repeated, an admin will issue the command test this please to rerun tests and build a new demo site.
  • Before this PR can be merged, it needs to be reviewed. Please keep in mind that reviewers are volunteers, and their response time can vary from a few hours to a few weeks depending on their availability and their knowledge of this particular part of CiviCRM.
  • A great way to speed up this process is to "trade reviews" with someone - find an open PR that you feel able to review, and leave a comment like "I'm reviewing this now, could you please review mine?" (include a link to yours). You don't have to wait for a response to get started (and you don't have to stop at one!) the more you review, the faster this process goes for everyone 😄
  • To ensure that you are credited properly in the final release notes, please add yourself to contributor-key.yml
  • For more information about contributing, see CONTRIBUTING.md.
PR commands & links...
  • /rebase <?branch-name> will rebase your branch and change the base of the PR (if <branch-name> is specified).
  • /squash will combine all commits (keeping only the first commit messsage).
  • /port <branch-name> will create a copy of this PR against a different branch.
  • /lint will automatically fix linting errors, amending commits as needed.
  • retest this please will rerun the tests and rebuild the demo site.
  • 📖 Review standards
  • 🗒️ Review template (brief or verbose)

➡️ Online demo of this PR 🔗

@civibot civibot Bot added the master label Nov 26, 2026
@monishdeb

Copy link
Copy Markdown
Member Author

test build will fail until the patch is published :

- Applying patches for pear/mail_mime
    https://download.civicrm.org/patches/38231167f0c789e0b368b38c1499973d562de65e87094b402156a6b928cc4c38/crm_3133.patch (Apply patch for CRM-3133 wordwrap body to be 750 characters to apply with RFC 2821)
    https://download.civicrm.org/patches/9c5ac4dfb7575adf131e7ee023aa2bb1b730b85b48133d96111e8ca4914af48e/php-86-is-a.patch (Replace is_a() with instanceof for PHP 8.6 compatibility (is_a() with a string argument is deprecated))
   Could not apply patch! Skipping. The error was: The "https://storage.googleapis.com/civicrm/patches/9c5ac4dfb7575adf131e7ee023aa2bb1b730b85b48133d96111e8ca4914af48e/php-86-is-a.patch" file could not be downloaded (HTTP/1.1 404 Not Found)

@colemanw

Copy link
Copy Markdown
Member

@monishdeb please also send a PR upstream to https://github.com/pear/Mail_Mime

@monishdeb

Copy link
Copy Markdown
Member Author

@colemanw done pear/Mail_Mime#41

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants