[Bug] WooCommerce attachment emails fail on Azure App Service — ABSPATH resolves incorrectly in containerized WordPress (v1.2.1)
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
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
- Deploy WordPress on Azure App Service (Linux, containerized)
- Install WooCommerce and the App Service Email plugin v1.2.1
- Place a test order
- Observe that the New Order and Processing Order emails never arrive
- 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
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của Azure/wordpress-linux-appservice
-
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 68/100
Azure/wordpress-linux-appservice#220 · 1 bình luận · 1 reaction ·
-
Vulnerable PHP Minor VersionsĐang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 48/100
Azure/wordpress-linux-appservice#223 · 3 bình luận ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 38/100
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 48/100
-
Using Cloudflare instead of AFDĐang mở
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
Tất cả issue của Azure/wordpress-linux-appservice
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 83/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
langchain-ai/deepagentsjs#898 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày
-
bug documentation P2 UI/UX
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
BasedHardware/omi#20084 ·
Maintainer thường phản hồi trong vòng 1 ngày