Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Offloaded attachment download resolves to a missing local file

未关闭
#1,119 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
52/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
技术栈
php, wordpress
领域
backend

调研方向

从 inc/media_offload.php 中的 Optml_Media_Offload::generate_image_meta()、add_new_actions() 和 alter_attached_file_response() 开始。运行 composer phpunit -- tests/test-media.php,然后使用一个新完成 offload 的附件重现 WordPress 或扩展的下载操作。完成的标准是下载工作流已得到覆盖,并且不再报告缺少本地文件,同时现有的 offload 和 rollback 测试仍然有效。

由索引模型根据 Issue 内容生成。

描述

bug bug-report bug-report-triage customer report

Summary

Downloading a newly offloaded WordPress attachment can return a file-not-found error. Expected behavior is for an offloaded attachment to remain downloadable. Actual behavior is that the attachment's local source has been removed while the download-facing file lookup resolves to a nonexistent local path, preventing administrators from retrieving the media.

Customer context

Product / area: Optimole WordPress plugin, Image Storage attachment downloads
Version: Customer version not provided; inspected source is 4.2.11
Environment: WordPress admin; browser and WordPress/PHP versions not provided
Integration / third party: Optimole cloud storage
Reported error / symptom: Downloading the newly uploaded attachment returns “file not found” while Optimole is active
Impact: Administrators cannot download affected offloaded attachments through workflows that consume the WordPress attached-file path

Reproduction notes

Reported reproduction:

  1. Keep Optimole active with Image Storage/offloading in use.
  2. Upload an image through WordPress.
  3. Attempt to download the uploaded attachment.
  4. Observe a “file not found” error.

Runtime reproduction was not performed, but the existing unit test and inspected source confirm that the filtered attached-file path does not exist after offload.

Diagnosis

Conclusion

The offload path removes the local source and rewrites attachment metadata to a remote marker. The globally registered get_attached_file filter then combines that remote metadata with the local uploads directory, producing a path for which the source confirms no local file exists. This directly matches the reported file-not-found download behavior. No matching GitHub issue was found.

Where this likely occurs
  • inc/media_offload.php — Optml_Media_Offload::generate_image_meta() lines 1478–1521 validates an Optimole URL, deletes the local source, and stores a remote id: path in attachment metadata.
  • inc/media_offload.php — Optml_Media_Offload::add_new_actions() lines 2654–2701 registers alter_attached_file_response() globally on get_attached_file for the new-offload path.
  • inc/media_offload.php — Optml_Media_Offload::alter_attached_file_response() lines 2715–2728 prefixes the local uploads directory to the remote metadata value.
  • tests/test-media.php — Test_Media::test_image_processed() lines 297–316 explicitly confirms that get_attached_file() resolves to a path that does not exist after processing.
  • Commit 31022521 introduced alter_attached_file_response() in the offloading-without-database-replacement work. Available history does not identify a release where this download path worked before breaking.
Engineering notes

The local deletion is intentional for Image Storage, but get_attached_file is a filesystem-path contract used by WordPress and extensions for attachment operations. The inspected filter is global despite its nearby comment discussing an Elementor file-existence check. The exact download controller used on the customer site is unknown, but any inspected workflow relying on this filtered local path encounters the absent file represented in the existing test.

Test coverage status

tests/test-media.php — Test_Media::test_image_processed() lines 297–316 and Test_Media::test_image_sync() lines 326–346 cover remote URL generation and explicitly assert local-file absence. Test_Media::test_image_rollback() lines 348–358 covers restoration. No relevant coverage was found during inspection for downloading an offloaded attachment or for a consumer requiring a readable result from get_attached_file().

What to verify or explore next
  • May be worth reproducing through the exact WordPress or extension download action that reports “file not found.”
  • May be worth running composer phpunit -- tests/test-media.php with a focused download consumer around a newly offloaded attachment.
  • Compatibility checks may be useful for core media actions and common attachment-download integrations that consume get_attached_file.
Unknowns / follow-up
  • The exact download UI or extension invoking the file lookup is not provided.
  • The customer's plugin version and attachment metadata are unavailable.

Confidence

Confidence: 95/100

Repository inspection independently confirms a stale offload-limit warning path and a missing local download target after offload. The blank-rendering symptom is credible but remains unconfirmed without the affected remote response or offloading logs.


Source: HelpScout #3431088020
Generated by bug-report-triage (ID: bug-report-triage_6a8f62001e0958.60696283)

主要语言
PHP
星标
74
派生
14
平均合并
2 天 9 小时
30 天内合并 PR
22

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

Codeinwp/optimole-wp 的其他 Issue

查看 Codeinwp/optimole-wp 的全部 Issue

相似的 Issue

更多 PHP Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。