Repository navigation
Show step errors on GET requests instead of a fatal error - #174
Conversation
Both functions have been no-ops since PHP 8.0 and are deprecated in PHP 8.5, which fails the PHPCS inspection.
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 33 minutes. View limit details
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Exception construction includes/views/class-base-page.php |
The replacement exception receives the escaped message and the original error list. |
Resource cleanup
| Layer / File(s) | Summary |
|---|---|
Image and fileinfo cleanup includes/functions/deprecated.php, includes/media/class-mime-types.php |
The resizer unsets its source and temporary image variables. MIME detection unsets the fileinfo resource. |
Priority:
Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Bug fix
Suggested reviewers: stephywells, wvega
Merge Risk: 
Minimal · previous review bfe87
-
No merge-blocking risk was established in the exception handling or resource cleanup changes.
Pre-merge checks: 
4 · 
1
-
Failed checks: 1 warning Passed checks: 4 passedFull details: Docstring Coverage
-
Explanation
Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 3 functions across 3 files.
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
-
Finishing Touches: 💡 1
-
📝 Generate docstrings: 💡
-
- Commit to this branch
- Create a new PR
🧪 Generate unit tests (beta)
-
- Commit to this branch
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands.
There was a problem hiding this comment.
Approve (non-blocking notes below).
Verified live (WordPress Playground, PHP 8.5, harness mu-plugin driving a real AWPCP_BasePage subclass whose step throws AWPCP_Exception):
- Base
357533e5, GET request:handle_step_exception()fatals withTypeError: Exception::__construct(): Argument #2 ($code) must be of type int, string given(esc_html()turns the errors array into the string"Array"). PRbfe87612: the page renders the generic "Your request cannot be processed…" notice plus the original message and the extra errors. - Output safety: with
<script>and ajavascript:link in the exception message, the rendered page has both stripped (awpcp_print_error()runswp_kses_post), so droppingesc_html()on the errors array does not open an XSS hole. POST path is identical on base and PR. unset()swaps:AWPCP_MimeTypesfileinfo path still returnsimage/png/image/jpeg, andawpcp_resizer()still shrinks PNG and JPEG to 640x480. Base prints PHP 8.5Deprecatednotices forfinfo_close()andimagedestroy(), PR prints none. Unset frees the resource on 7.4 too, and the PHP 7.4 and PHP 8 CI jobs pass.- Repo-wide grep for the same
esc_html( <array> )shape: none left. Remainingfinfo_close/imagedestroyreferences: only thefunction_existscheck below.
Non-blocking
includes/media/class-mime-types.php:19still requiresfunction_exists( 'finfo_close' )to use fileinfo. PHP 9 will remove that function, so the fileinfo path would then be skipped silently in favour of the array fallback. Since the PR stops callingfinfo_close(), drop it from the condition.- No regression test for the GET-error path (a step that throws on GET should render errors, not fatal). Not blocking for a one-line fix, but this is the kind of path that regresses unseen.
- The
finfo_close/imagedestroy→unset()commit is unrelated to the PR title and the linked fix; fine to keep, but worth naming in the description.
Not run: the real front-end Place Ad / Buy Credits flows (only the base-page error handler was exercised directly), PHPUnit locally (CI green).
Fixes Strategy11/awpcp#3210
Pass the original errors array to AWPCP_Exception again so GET step errors render the "cannot be processed" message and the errors instead of a TypeError.