[Bug] WooCommerce attachment emails fail on Azure App Service — ABSPATH resolves incorrectly in containerized WordPress (v1.2.1)
还没有人认领这个 Issue。
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 72/100
调研方向
从 admin/mailer/class-azure_app_service_email-controller.php 开始,检查 generate_request_body(),然后使用所列出的 WordPress 和 WooCommerce 配置,在 Azure App Service 容器中复现带附件的电子邮件失败问题。完成的标准是:带有发票 PDF 附件的订单通知电子邮件能够成功送达,同时不带附件的电子邮件继续正常工作。
由索引模型根据 Issue 内容生成。
描述
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.
- 主要语言
- HCL
- 星标
- 139
- 派生
- 84
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
Azure/wordpress-linux-appservice 的其他 Issue
-
难度 1/5 1-3 小时 新手友好度 68/100
Azure/wordpress-linux-appservice#220 · 1 条评论 · 1 个 reaction ·
-
难度 3/5 1-2 天 新手友好度 48/100
Azure/wordpress-linux-appservice#223 · 3 条评论 ·
-
难度 4/5 3-5 天 新手友好度 38/100
-
难度 3/5 1-2 天 新手友好度 48/100
-
难度 5/5 一周以上 新手友好度 25/100
查看 Azure/wordpress-linux-appservice 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 68/100
run-llama/llama_index#23278 ·
维护者通常 2 天内回复
-
from-review-extraction priority: low python severity:nit
难度 2/5 1-3 小时 新手友好度 90/100
LearningCircuit/local-deep-research#6944 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
iMicknl/python-overkiz-api#2263 ·
维护者通常 7 天内回复
-
难度 2/5 1-3 小时 新手友好度 88/100
meshery/meshery#22119 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
sgl-project/sglang#41482 ·
维护者通常 1 天内回复