Skip to content

grabUrlsFromLastEmail passes null to preg_match_all for single-part emails #138

Closed

Description

@wazum

grabUrlsFromLastEmail() passes $message->getTextContent() and $message->getHtmlContent() straight to preg_match_all(). mail-mime-parser returns null for a part that doesn't exist, so every single-part email triggers a deprecation notice:

Deprecated: preg_match_all(): Passing null to parameter #2 ($subject) of type string is deprecated
in src/Module/MailCatcher.php on line 282 / 285
  • Plain-text-only email: no HTML part, so the notice comes from line 285.
  • HTML-only email: no text part, so the notice comes from line 282.

The returned URLs are still correct today. However, test suites that turn deprecations into failures error out, and this becomes a TypeError once PHP drops the null-to-internal-parameter coercion.

Reproduction

$I->sendEmail('user@example.com', 'Subject', 'Visit https://example.com/a'); // plain-text only
$I->grabUrlsFromLastEmail(); // Deprecated: preg_match_all(): Passing null to parameter #2 ...

Expected

A missing part is treated as empty content, with no notice.

Activity

  1. added a commit that references this issue on Oct 1, 2026
    6ea2b4f
  2. Jamesking56 commented on Oct 1, 2026

    @Jamesking56
    Collaborator

    Fixed by #130

  3. added a commit that references this issue on Oct 1, 2026
    b59877c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions