Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

[Bug] WooCommerce attachment emails fail on Azure App Service — ABSPATH resolves incorrectly in containerized WordPress (v1.2.1)

Đang mở Phù hợp với người mới
#219 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
72/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Ít trao đổi
Công nghệ
azure, php, wordpress
Lĩnh vực
backend, cloud

Hướng nghiên cứu

Bắt đầu trong admin/mailer/class-azure_app_service_email-controller.php và kiểm tra generate_request_body(), sau đó tái hiện lỗi email có tệp đính kèm trong một container Azure App Service bằng cách sử dụng thiết lập WordPress và WooCommerce được liệt kê. Được xem là hoàn thành khi các email thông báo đơn hàng có tệp PDF hóa đơn đính kèm được gửi thành công, trong khi các email không có tệp đính kèm vẫn tiếp tục hoạt động.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Summary

On Azure App Service containerized WordPress deployments, WooCommerce order
notification emails that include attached invoice PDFs fail silently with the
following error in the Azure Email Logs:

Request body validation error. ContentBytes invalid. Should be base64

Basic emails (contact forms, password resets) send successfully. Only emails
with attachments are affected.


Root Cause

In admin/mailer/class-azure_app_service_email-controller.php, the
generate_request_body() method resolves attachment paths using ABSPATH:

foreach ($filePaths as $path) {
    if ($path[0] !== '/') {
        $path = ABSPATH . trim($path);
    }
    if (file_exists($path)) { ... }
}

On Azure App Service containerized WordPress, ABSPATH resolves to
/var/www/html while the actual running WordPress root is
/var/www/wordpress. The path resolves incorrectly, file_exists() returns
false, the attachment is silently dropped, and the ACS REST API rejects the
malformed request body.

The "ContentBytes invalid" error is a red herring — the real issue is a path
mismatch between ABSPATH and the actual WordPress root inside the container.


Steps to Reproduce

  1. Deploy WordPress on Azure App Service (Linux, containerized)
  2. Install WooCommerce and the App Service Email plugin v1.2.1
  3. Place a test order
  4. Observe that the New Order and Processing Order emails never arrive
  5. Check Azure Email Logs — error reads "ContentBytes invalid. Should be base64"

Expected Behavior

WooCommerce order notification emails send successfully with attached invoice
PDFs via Azure Communication Services.


Actual Behavior

Emails with attachments fail. Emails without attachments succeed.


Proposed Fix

Replace ABSPATH with a path derived from WP_CONTENT_DIR, which correctly
resolves to the active WordPress root regardless of container layout. Also
adds an empty path guard and immediate trim to prevent related edge case
failures:

foreach ($filePaths as $path) {
    $path = trim($path);
    if (empty($path)) { continue; }
    if ($path[0] !== '/') {
        $wp_root = rtrim(str_replace('wp-content', '', WP_CONTENT_DIR), '/');
        $path = $wp_root . '/' . $path;
    }
    if (file_exists($path)) { ... }
}

A community fix including a PowerShell automation script and full root cause
analysis is documented here:
https://github.com/JONeillSr/Repair-AppServiceEmailAttachmentPatch


Environment

Component Version
App Service Email Plugin v1.2.1
WordPress 7.x
WooCommerce 8.x+
Azure App Service Linux, containerized
PHP 8.x

Workaround

Apply the patch manually via SSH or using the PowerShell automation script
linked above. The fix is confirmed working in production.

Ngôn ngữ chính
HCL
Star
139
Fork
84
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của Azure/wordpress-linux-appservice

Tất cả issue của Azure/wordpress-linux-appservice

Issue tương tự

Thêm issue về Backend & API Design

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.