Changeset 55030
- Timestamp:
- 01/05/2023 10:47:06 AM (2 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/pluggable.php
r54952 r55030 518 518 519 519 if ( ! empty( $attachments ) ) { 520 foreach ( $attachments as $attachment ) { 520 foreach ( $attachments as $filename => $attachment ) { 521 $filename = is_string( $filename ) ? $filename : ''; 522 521 523 try { 522 $phpmailer->addAttachment( $attachment );524 $phpmailer->addAttachment( $attachment, $filename ); 523 525 } catch ( PHPMailer\PHPMailer\Exception $e ) { 524 526 continue; -
trunk/tests/phpunit/tests/pluggable/wpMail.php
r54872 r55030 456 456 457 457 /** 458 * Test that attachment file names are derived from array values when their 459 * associative array keys are numeric. 460 * 461 * @ticket 28407 462 */ 463 public function test_wp_mail_sends_attachments_with_original_name() { 464 wp_mail( 'user@example.org', 'Subject', 'Hello World', '', array( 465 DIR_TESTDATA . '/images/canola.jpg', 466 DIR_TESTDATA . '/images/waffles.jpg' 467 ) ); 468 469 /** @var PHPMailer $mailer */ 470 $mailer = tests_retrieve_phpmailer_instance(); 471 472 $attachments = $mailer->getAttachments(); 473 474 $this->assertTrue( $mailer->attachmentExists() ); 475 $this->assertSame( $attachments[0][1], $attachments[0][2] ); 476 $this->assertSame( $attachments[1][1], $attachments[1][2] ); 477 } 478 479 /** 480 * Test that attachment file names are derived from array keys when they 481 * are non-empty strings. 482 * 483 * @ticket 28407 484 */ 485 public function test_wp_mail_sends_attachments_with_custom_name() { 486 wp_mail( 'user@example.org', 'Subject', 'Hello World', '', array( 487 'alonac.jpg' => DIR_TESTDATA . '/images/canola.jpg', 488 'selffaw.jpg' => DIR_TESTDATA . '/images/waffles.jpg' 489 ) ); 490 491 /** @var PHPMailer $mailer */ 492 $mailer = tests_retrieve_phpmailer_instance(); 493 494 $attachments = $mailer->getAttachments(); 495 496 $this->assertTrue( $mailer->attachmentExists() ); 497 $this->assertSame( 'alonac.jpg', $attachments[0][2] ); 498 $this->assertSame( 'selffaw.jpg', $attachments[1][2] ); 499 } 500 501 /** 458 502 * @ticket 50720 459 503 */
Note: See TracChangeset
for help on using the changeset viewer.