You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Heroku部署的WordPress 6.1用WP Offload Media Lite上传S3失败求助

WordPress 6.1部署在Heroku,WP Offload Media Lite无法上传图片到S3

问题详情

  • 已将WordPress 6.1部署在Heroku平台,使用WP Offload Media Lite插件尝试将图片上传至S3存储,但上传完全失败
  • 本地环境使用相同配置可正常运行,当前为全新项目,无其他活跃插件干扰
  • 上传后打开图片显示提示:"item has not been offloaded"

上传日志

Deprecated: strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated in /app/wp-includes/functions.php on line 7022

Deprecated: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in /app/wp-includes/functions.php on line 2162

Deprecated: Return type of Requests_Cookie_Jar::offsetExists($key) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /app/wp-includes/Requests/Cookie/Jar.php on line 63

Deprecated: Return type of Requests_Cookie_Jar::offsetGet($key) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /app/wp-includes/Requests/Cookie/Jar.php on line 73

Deprecated: Return type of Requests_Cookie_Jar::offsetSet($key, $value) should either be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /app/wp-includes/Requests/Cookie/Jar.php on line 89

Deprecated: Return type of Requests_Cookie_Jar::offsetUnset($key) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /app/wp-includes/Requests/Cookie/Jar.php on line 102

Deprecated: Return type of Requests_Cookie_Jar::getIterator() should either be compatible with IteratorAggregate::getIterator(): Traversable, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /app/wp-includes/Requests/Cookie/Jar.php on line 111

Deprecated: Return type of Requests_Utility_CaseInsensitiveDictionary::offsetExists($key) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /app/wp-includes/Requests/Utility/CaseInsensitiveDictionary.php on line 40

Deprecated: Return type of Requests_Utility_CaseInsensitiveDictionary::offsetGet($key) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /app/wp-includes/Requests/Utility/CaseInsensitiveDictionary.php on line 51

Deprecated: Return type of Requests_Utility_CaseInsensitiveDictionary::offsetSet($key, $value) should either be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /app/wp-includes/Requests/Utility/CaseInsensitiveDictionary.php on line 68

Deprecated: Return type of Requests_Utility_CaseInsensitiveDictionary::offsetUnset($key) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /app/wp-includes/Requests/Utility/CaseInsensitiveDictionary.php on line 82

Deprecated: Return type of Requests_Utility_CaseInsensitiveDictionary::getIterator() should either be compatible with IteratorAggregate::getIterator(): Traversable, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /app/wp-includes/Requests/Utility/CaseInsensitiveDictionary.php on line 91
24

排查与解决步骤

1. 修复PHP版本兼容性警告

日志中的Deprecated提示是因为Heroku使用的PHP 8.1+与WordPress 6.1内置的Requests库不兼容,虽不直接导致上传失败,但可能引发逻辑异常:

  • 在Heroku环境变量中添加WP_DEBUG_DISPLAY=false,关闭警告显示
  • 升级WordPress到6.2及以上版本,新版本已修复PHP 8.x兼容性问题

2. 核对Heroku上的S3配置

  • 确认Heroku环境变量中的AWS密钥、存储桶名称、区域配置与本地完全一致,无拼写错误
  • 检查S3存储桶的CORS配置,允许Heroku服务器域名的访问请求
  • 由于Heroku文件系统是临时的,确保插件设置中未依赖本地文件持久化,可开启*"Remove Files From Server"*选项(按需)

3. 验证S3权限

  • 确保S3用户拥有s3:PutObject、s3:GetObject、s3:ListBucket权限,避免权限不足导致上传失败
  • 检查存储桶访问策略,未阻止Heroku IP的请求

4. 插件调试与重置

  • 在wp-config.php中添加define('WP_OFFLOAD_MEDIA_DEBUG', true);,开启插件调试模式,获取更详细的上传错误日志
  • 重新安装WP Offload Media Lite插件,确保Heroku上的插件文件完整无损坏

内容的提问来源于stack exchange,提问作者kailashthakuri

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.13 20:25:27