Skip to content
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

fix BookingCodesMessage:sendMessage() wrong $attachment for prepareMail #1606

Merged
merged 1 commit into from
Jul 3, 2024

Conversation

nelarsen
Copy link
Contributor

@nelarsen nelarsen commented Jul 1, 2024

Mit Bezug auf #1605 , das Ziel dieser PR ist, diese Fehlermeldungen in phpunit unter "WP latest on PHP 8.2" loszuwerden. Diese Sequenz trat insgesamt zwei mal auf und wurden durch die Test-Funktionen Service::BookingCodesTest::testSendBookingCodesMessage() und View::BookingCodesTest::testSendBookingCodesMessage() ausgelöst. Siehe Commitbeschreibung für Details.

PHP Deprecated:  preg_match(): Passing null to parameter #2 ($subject) of type string is deprecated in /tmp/wordpress/wp-includes/PHPMailer/PHPMailer.php on line 1880
PHP Deprecated:  is_file(): Passing null to parameter #1 ($filename) of type string is deprecated in /tmp/wordpress/wp-includes/PHPMailer/PHPMailer.php on line 1895
PHP Deprecated:  strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated in /tmp/wordpress/wp-includes/PHPMailer/PHPMailer.php on line 1897

Mit dieser PR verschwinden die o.g. Warnungen, aber sonst ändert sich nichts.

prepareMail expects an associative array or null as $attachment, but sendMessage passed a associate array inside a array (which was actually working due to magic in Message::addStringAttachments) or null inside an array, for the case where an ical-attachment is not to be sent. The [null] was misunderstood by SendNotificationMail() as a mail with an attachment, calling phpmailer with illegal parameters and causing warnings. The mail was seemingly send anyway, totally expected without attachment. So the change is a fix to avoid warnings, but it does not change the behavior for the user in any way.

Additionally, add two more tests to cover the (non-default) case when sending of ical-attachment for BookingCodes is ON
Copy link

codecov bot commented Jul 1, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 49.98%. Comparing base (076ae51) to head (871f0c7).
Report is 2 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #1606      +/-   ##
============================================
+ Coverage     49.79%   49.98%   +0.18%     
  Complexity     2682     2682              
============================================
  Files            97       97              
  Lines         10712    10712              
============================================
+ Hits           5334     5354      +20     
+ Misses         5378     5358      -20     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@hansmorb
Copy link
Contributor

hansmorb commented Jul 3, 2024

Danke für den PR! Das mit dem doppelt verschaltelten Array im Attachment haben wir wohl übersehen! Dann hätte das attachment aber eigentlich vorher nicht funktionieren sollen, oder?

@nelarsen
Copy link
Contributor Author

nelarsen commented Jul 3, 2024

Danke für den PR! Das mit dem doppelt verschaltelten Array im Attachment haben wir wohl übersehen! Dann hätte das attachment aber eigentlich vorher nicht funktionieren sollen, oder?

Doch, tatsächlich funktionert beides. Das hat mich auch gewundert und ich habe mich gefragt, ob mein Fix doch etwas bricht. Aber das ist nicht der Fall, denn in Message::addStringAttachments() gibt es "Magie" (is_multidimensional_array), die mit mehrdimensionellen Arrays umgeht.

@hansmorb
Copy link
Contributor

hansmorb commented Jul 3, 2024

Na dann! Die Magie ist ein importiertes Snippet ;)

@hansmorb hansmorb merged commit 85cd4f1 into wielebenwir:master Jul 3, 2024
14 checks passed
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.

None yet

2 participants