URL replacement emits PHP warnings when the upload resource is null
Maintainer thường phản hồi trong vòng 1 ngày
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
- 69/100
Hướng nghiên cứu
Bắt đầu với Optml_Manager::do_url_replacement() trong inc/manager.php và getter nullable trong inc/app_replacer.php; theo dõi cách tài nguyên tải lên được khởi tạo thông qua optml_replacer_setup. Bổ sung kiểm thử trong tests/test-replacer.php cho một lần gọi trực tiếp với danh sách URL hình ảnh không rỗng trước khi thiết lập, sau đó so sánh với các trường hợp thay thế đã khởi tạo. Trường hợp chưa khởi tạo được xem là đạt nếu không phát ra cảnh báo và trả về HTML như mong đợi; cần có PHP để chạy kiểm thử.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Summary
Optimole 4.2.21 emits PHP warnings when URL replacement is invoked in an early/admin context before its upload resource is initialized. Content processing is expected to handle this uninitialized state without warnings; instead, processing a nonempty list of image URLs accesses unavailable upload-resource values. The reported impact is warnings during early/admin processing. Normal initialized frontend requests are reported to work.
Customer context
- Product / area: Optimole WordPress plugin, URL replacement.
- Version: 4.2.21.
- Environment: PHP 8.3; WordPress 7.1.5, as reported.
- Integration / third party: Not provided.
- Reported symptom: PHP warnings with an uninitialized upload resource in early/admin processing.
- Impact: Warning-producing content processing; no frontend image-rendering failure reported. The reporter describes successful local checks with a temporary guard, but supplied no executable test artifact.
Reproduction notes
Reported reproduction: invoke URL replacement in an early/admin context with the upload resource still null on Optimole 4.2.21, PHP 8.3 and WordPress 7.1.5.
Source-derived verification case, not executed: before optml_replacer_setup, obtain the manager and call do_url_replacement() with <img src="/wp-content/uploads/sample.jpg"> and the corresponding nonempty extracted-URL array. The getter remains null and processing reaches the unchecked content_path access.
The reporter describes six uninitialized and six initialized local scenarios, but the test source and exact admin trigger were not supplied. Independent execution was unavailable because PHP is not installed.
Diagnosis
Conclusion
Source inspection confirms that a documented nullable upload resource is dereferenced without validation in v4.2.21. A nonempty list containing an ordinary non-Optimole image URL reaches the unchecked access when the tag replacer remains uninitialized. The reporter's PHP 8.3 reproduction was not independently executed.
Where this likely occurs
inc/manager.php, lines 819–849 —Optml_Manager::do_url_replacement()retrieves the resource at line 833 and readscontent_pathat lines 842–843, followed conditionally bycontent_hostat line 846, without a resource-state check.inc/app_replacer.php, lines 99–104 and 463–469 —Optml_App_Replacer::$upload_resourcedefaults tonull;get_upload_resource()explicitly documentsnull|arrayand returns that value directly.inc/tag_replacer.php, lines 44–58 —Optml_Tag_Replacer::instance()defers initialization tooptml_replacer_setup;init()delegates to the parent initializer.inc/app_replacer.php, lines 331–333 and 374–397 —Optml_App_Replacer::init()callsset_properties(), which populates the resource.inc/manager.php, lines 178–206, 304–318 and 414–416 —Optml_Manager::init()can return beforeregister_hooks(), including on ordinary non-AJAX admin requests;register_hooks()triggers replacer initialization.
Engineering notes
The default-null state is part of the product's initialization lifecycle, not evidence of a partial deployment. Direct calls to the public replacement method have no equivalent readiness check. Conversely, normal registered frontend processing initializes the replacer first; the evidence does not establish that merely opening an admin screen triggers the warnings. The exact early/admin caller remains unknown.
History inspection identifies e3886ebb0cf4d27fbf0862b364a8e07bec1eb16c as introducing the resource lookup and dereferences for relative-URL support. No verified previously working equivalent workflow or release boundary was established, so this is not classified as a regression. The defect remains in the latest local release tag, v4.2.21.
Test coverage status
tests/test-replacer.php — Test_Replacer::setUp(), lines 129–154, explicitly initializes the replacers before cases such as test_wc_json_replacement(), lines 166–176. tests/test-zz-buffer.php — Test_Buffer::setUp(), lines 28–40, also initializes them before test_long_url_replacement_stays_within_pcre_limits(), lines 326–344. No relevant nullable-resource coverage was found during inspection. Tests were not run because PHP is unavailable in this environment.
What to verify or explore next
- Verify a direct call with a nonempty image-URL list before
optml_replacer_setupon PHP 8.3, capturing warnings and returned HTML. - Verify initialized relative, absolute, escaped-JSON, duplicate-URL and multi-chunk inputs against the existing replacement suites.
- Identify the reporter's concrete early/admin caller and hook timing.
Unknowns / follow-up
The reporter's isolated test and bootstrap checks were described but not attached. No independent WordPress bootstrap reproduction was performed; initialization observations above are based on plugin source, not locally inspected WordPress core.
Confidence
Confidence: 95/100
The affected release directly contradicts its getter's nullable return contract, and the initialization flow explains how that state persists. Remaining uncertainty concerns the exact application caller, not the unchecked access.
Source: HelpScout #3526039770
Generated by bug-report-triage (ID: bug-report-triage_6b075a828383e7.95862540)
- Ngôn ngữ chính
- PHP
- Star
- 75
- Fork
- 14
- Merge trung bình
- 1 ngày 6 giờ
- Pull request đã merge (30 ngày)
- 31
Chuẩn bị môi trường
- Có Dockerfile hoặc tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
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 Codeinwp/optimole-wp
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Codeinwp/optimole-wp#1259 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Lazyload SVG placeholder runs uncached attachment lookups with JSON-escaped URLs on REST responsesĐang mởcustomer report
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Codeinwp/optimole-wp#1253 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
customer report feature-request-triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Codeinwp/optimole-wp#1239 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Throttle and optimize `/wp-json/optml/v1/optimizations` REST API endpoint execution and validationĐang mởcustomer report feature-request-triage
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 45/100
Codeinwp/optimole-wp#1250 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Cache `attachment_url_to_postid()` lookups in `Optml_Lazyload_Replacer` to reduce database overheadĐang mởcustomer report feature-request-triage
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 65/100
Codeinwp/optimole-wp#1249 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của Codeinwp/optimole-wp
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
recca0120/vscode-phpunit#620 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Validation rule generation for recursive Data objects is unbounded (O(payload depth))Có thể đã có người làm @irfanm96 đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
spatie/laravel-data#1226 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
Maintainer thường phản hồi trong vòng 1 ngày