-
Notifications
You must be signed in to change notification settings - Fork 0
Increase coverage #72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| public function ajax_generate_document() { | ||
| // Verify nonce first before accessing any other POST data. | ||
| if ( ! isset( $_POST['_wpnonce'] ) || ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['_wpnonce'] ) ), 'documentate_generate' ) ) { | ||
| wp_send_json_error( array( 'message' => __( 'Security check failed.', 'documentate' ) ) ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Align AJAX generate nonce with issued nonce action
The new nonce check in ajax_generate_document() now verifies against the fixed action 'documentate_generate', but the configuration sent to the front‑end still issues nonces using the post‑specific action 'documentate_generate_' . $post_id (see build_actions_script_config()). Any document generation request made from the UI will therefore fail nonce verification and return the “Security check failed.” JSON error, blocking downloads/previews for all posts. The handler should validate against the same post‑scoped action it generates.
Useful? React with 👍 / 👎.
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
This pull request introduces several improvements focused on error handling, code organization, and testability in the
Documentateplugin, especially in the admin helper and WP-CLI integration. The main changes include refactoring admin helper methods for better error management, restructuring WP-CLI command registration for improved testability, and enhancing the coverage summary reporting. Below are the most significant updates grouped by theme:Admin Helper Error Handling & Refactoring:
class-documentate-admin-helper.phpto use dedicated response preparation methods and returnWP_Errorobjects on failure instead of immediately callingwp_die(). This centralizes error handling and improves maintainability. [1] [2] [3] [4]Converter Page Rendering Improvements:
class-documentate-admin-helper.phpto separate header preparation and template path resolution into their own methods, improving readability and allowing easier testing. [1] [2]WP-CLI Command Structure & Testability:
Documentate_WPCLIto no longer extendWP_CLI_Commanddirectly, and moved command registration inside a conditional block, allowing easier mocking and testing of CLI methods. Also, abstracted WP-CLI output and confirmation methods for test overrides. [1] [2] [3]Test Coverage Reporting:
Makefileto use a new AWK script (scripts/coverage-summary.awk) for coverage summary reporting, providing more readable and targeted output. Added the AWK script to the repository. [1] [2]Packaging & Export Ignore Updates:
.gitattributesfile to be excluded from export, helping to reduce package size and prevent unnecessary files from being distributed. [1] [2]