Conversation
The standalone editor screen set error_reporting(0) and display_errors=0 for the whole request. Output buffering already guarantees a clean first byte for that document, so the process-wide settings only made the site harder to debug for anyone who happened to load the editor. The buffer stays; the settings go. The upload paths also loaded wp-admin includes they never used: wp-admin/includes/media.php in both the admin-post callback and the REST create handler, and image.php in the REST handler. Each remaining require_once now sits immediately before the core function that needs it.
Contributor
Test in WordPress PlaygroundTest the plugin with the code from this branch:
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #124 +/- ##
============================================
- Coverage 96.87% 96.87% -0.01%
Complexity 864 864
============================================
Files 39 39
Lines 4323 4318 -5
============================================
- Hits 4188 4183 -5
Misses 135 135
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of the WordPress.org plugin review (review ID
D exelearning/18Sep26/T1). Two of the reported findings, both confined to PHP the plugin ships.Error reporting in production code. The standalone editor screen set
error_reporting(0)anddisplay_errors=0for the whole request, so anyone debugging their site while the editor page loaded got a silently altered environment. The page already buffers its own output and discards it before writing the document, which is what actually guarantees a clean first byte, so the process-wide settings bought nothing and are gone.Core files loaded but never used.
wp-admin/includes/media.phpwas required in the admin-post upload callback and in the REST create handler, andimage.phpin the REST handler, without a single function from either being called afterwards. Each remainingrequire_oncenow sits immediately before the core function that needs it (wp_handle_upload(),wp_generate_attachment_metadata()), which is the pattern the review asks for.Verification
make lintclean.make testgreen (931 tests), includingAdminUploadTest,RestApiUploadTest,EditorPageTest,EditorTest,RestApiTest, which cover both upload paths and the buffered-output behavior of the editor screen.wp plugin checkno longer reports the threePluginCheck.CodeAnalysis.PHPErrorReportingwarnings.