Upgrade alleyinteractive/alley-coding-standards to ^2.0#893
Conversation
Agent-Logs-Url: https://github.com/alleyinteractive/wordpress-fieldmanager/sessions/5aaa55b7-20ff-40ff-8235-425680472340 Co-authored-by: srtfisher <346399+srtfisher@users.noreply.github.com>
Agent-Logs-Url: https://github.com/alleyinteractive/wordpress-fieldmanager/sessions/5aaa55b7-20ff-40ff-8235-425680472340 Co-authored-by: srtfisher <346399+srtfisher@users.noreply.github.com>
Agent-Logs-Url: https://github.com/alleyinteractive/wordpress-fieldmanager/sessions/5aaa55b7-20ff-40ff-8235-425680472340 Co-authored-by: srtfisher <346399+srtfisher@users.noreply.github.com>
|
@copilot ensure that tests pass too |
Agent-Logs-Url: https://github.com/alleyinteractive/wordpress-fieldmanager/sessions/c87f30a6-8bcb-4a36-a40c-24ab84070cd3 Co-authored-by: srtfisher <346399+srtfisher@users.noreply.github.com>
The CI failures were caused by |
|
@copilot revert the strict comparison changes ( |
Agent-Logs-Url: https://github.com/alleyinteractive/wordpress-fieldmanager/sessions/1657c266-403f-465f-b426-b97991f2eb27 Co-authored-by: srtfisher <346399+srtfisher@users.noreply.github.com>
Done in 74d1f6d. All 63 strict comparison changes ( |
There was a problem hiding this comment.
Pull request overview
This PR upgrades the project’s PHPCS ruleset to alleyinteractive/alley-coding-standards:^2.0 and updates configuration + code to satisfy the stricter sniffs across the Fieldmanager plugin codebase.
Changes:
- Bump
alleyinteractive/alley-coding-standardsto^2.0and updatephpcs.xmlfor new config syntax + targeted exclusions. - Apply PHPCS/PHPCBF-driven style fixes and update various
phpcs:ignorereferences to current sniff codes. - Make a few behavior-level adjustments to satisfy new security/output rules (e.g., updated
get_terms()usage, improved escaping/sanitization in a few contexts).
Reviewed changes
Copilot reviewed 32 out of 32 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| phpcs.xml | Updates ruleset config (prefix array syntax) and adds exclusions for short fm_ prefix + mixed function/OO files. |
| composer.json | Upgrades alleyinteractive/alley-coding-standards to ^2.0. |
| fieldmanager.php | Uses __DIR__, tightens/escapes some exception messages, adds targeted PHPCS ignores for wrapper params. |
| php/util/class-fieldmanager-util-validation.php | Refactors conditional to elseif, updates strict-comparison ignore codes, switches output to printf(). |
| php/util/class-fieldmanager-util-term-meta.php | Updates strict-comparison ignore codes and trims trailing whitespace. |
| php/util/class-fieldmanager-util-assets.php | Updates strict-comparison ignore codes. |
| php/datasource/class-fieldmanager-datasource.php | Escapes wp_die/exception messages; adds unused-parameter ignore for interface stub methods. |
| php/datasource/class-fieldmanager-datasource-user.php | Escapes exception messages; updates strict-comparison ignore codes. |
| php/datasource/class-fieldmanager-datasource-term.php | Updates get_terms() calls to the modern single-argument API; updates strict-comparison ignores. |
| php/datasource/class-fieldmanager-datasource-post.php | Updates strict-comparison ignore codes and trims trailing whitespace. |
| php/context/class-fieldmanager-context-term.php | Updates strict-comparison ignore codes and trims trailing whitespace. |
| php/context/class-fieldmanager-context-submenu.php | Updates strict-comparison ignore codes. |
| php/context/class-fieldmanager-context-storable.php | Adjusts exception escaping to satisfy EscapeOutput; trims trailing whitespace. |
| php/context/class-fieldmanager-context-quickedit.php | Updates strict-comparison ignore codes and trims trailing whitespace. |
| php/context/class-fieldmanager-context-post.php | Updates strict-comparison ignore codes and trims trailing whitespace. |
| php/context/class-fieldmanager-context-page.php | Updates ignore codes and POST handling/escaping; adjusts hidden input escaping. |
| php/class-fieldmanager-textfield.php | Trims trailing whitespace. |
| php/class-fieldmanager-textarea.php | Trims trailing whitespace. |
| php/class-fieldmanager-select.php | Trims trailing whitespace. |
| php/class-fieldmanager-richtextarea.php | Updates strict-comparison ignore codes; trims trailing whitespace. |
| php/class-fieldmanager-password.php | Trims trailing whitespace. |
| php/class-fieldmanager-options.php | Updates strict-comparison ignore codes; trims trailing whitespace. |
| php/class-fieldmanager-media.php | Updates strict-comparison ignore codes; minor formatting adjustments; trims trailing whitespace. |
| php/class-fieldmanager-link.php | Trims trailing whitespace. |
| php/class-fieldmanager-hidden.php | Trims trailing whitespace. |
| php/class-fieldmanager-group.php | Updates strict-comparison ignore codes; adjusts escaping in exception messages; trims trailing whitespace. |
| php/class-fieldmanager-grid.php | Style tweak for anonymous function spacing; trims trailing whitespace. |
| php/class-fieldmanager-field.php | Updates ignore codes; adds unused-parameter ignores; escapes validation exceptions for EscapeOutput. |
| php/class-fieldmanager-datepicker.php | Trims trailing whitespace. |
| php/class-fieldmanager-checkboxes.php | Updates strict-comparison ignore codes; trims trailing whitespace. |
| php/class-fieldmanager-checkbox.php | Updates strict-comparison ignore codes for loose equality checks. |
| php/class-fieldmanager-autocomplete.php | Escapes wp_die/exception messages for EscapeOutput. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison, WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- baseline: deprecated method, nonce is checked in save_page_form() | ||
| if ( ! empty( $_POST ) && ! empty( $_POST['fm-page-action'] ) && sanitize_text_field( wp_unslash( $_POST['fm-page-action'] ) ) === $uniqid ) { |
There was a problem hiding this comment.
The hidden input uses sanitize_title( $this->uniqid ) (see render_page_form), but the submit check compares sanitize_text_field( wp_unslash( $_POST['fm-page-action'] ) ) to the raw $uniqid. If $uniqid contains characters that sanitize_title() changes, the form submission won’t be detected and save_page_form() won’t run. Compare against the same sanitized value (e.g., sanitize_title( $uniqid )) and/or sanitize the POSTed value with sanitize_title()/sanitize_key() to match what’s rendered. Also, the phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison is now misleading since this condition uses === and should be removed/updated if still needed.
| // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison, WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- baseline: deprecated method, nonce is checked in save_page_form() | |
| if ( ! empty( $_POST ) && ! empty( $_POST['fm-page-action'] ) && sanitize_text_field( wp_unslash( $_POST['fm-page-action'] ) ) === $uniqid ) { | |
| // phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- baseline: deprecated method, nonce is checked in save_page_form() | |
| if ( ! empty( $_POST ) && ! empty( $_POST['fm-page-action'] ) && sanitize_title( wp_unslash( $_POST['fm-page-action'] ) ) === sanitize_title( $uniqid ) ) { |
| @@ -87,10 +87,10 @@ public function render_page_form() { | |||
| echo '<form method="POST" id="' . esc_attr( $this->uniqid ) . '">'; | |||
| echo '<div class="fm-page-form-wrapper">'; | |||
| // phpcs:ignore WordPress.Security.EscapeOutput.DeprecatedWhitelistCommentFound -- baseline | |||
There was a problem hiding this comment.
This phpcs:ignore WordPress.Security.EscapeOutput.DeprecatedWhitelistCommentFound looks like leftover suppression from the old whitelist-comment system. The printf() call already escapes the value via esc_attr( sanitize_title( ... ) ), so the ignore should be removed (or updated to the current relevant sniff if something still needs suppression) to avoid carrying deprecated/invalid ignore codes forward.
| // phpcs:ignore WordPress.Security.EscapeOutput.DeprecatedWhitelistCommentFound -- baseline |
Upgrades
alleyinteractive/alley-coding-standardsto^2.0and resolves all new PHPCS violations introduced by the stricter ruleset.phpcs.xml
PrefixAllGlobals.prefixesfrom deprecated comma-separated string to<element>array syntaxNonPrefixed*sub-rules: the project'sfm_prefix is 3 chars, below WPCS's 4-char minimum — the prefix is intentional and valid, renaming would be a breaking API changeUniversal.Files.SeparateFunctionsFromOO.Mixed: several files intentionally co-locate deprecated template-tag wrappers and singleton helpers alongside class declarationsCode fixes
datasource-term.php— Fix two deprecatedget_terms( $taxonomies, $args )calls to use the modern single-argument API with ataxonomykeyutil-validation.php— Replaceelse { if () {} }withelseifautocomplete,context-storable,datasource,datasource-user,fieldmanager,field,group) — Wrap exception/wp_diemessages withesc_html()oresc_html__()to satisfyEscapeOutput; use__()insidesprintf()when the outeresc_html()handles escaping to avoid double-encodingcontext-page.php— Update staleDeprecatedWhitelistCommentFoundphpcs:ignore codes to current rule names; replaceesc_html( $_POST[...] )withsanitize_text_field( wp_unslash( ... ) )field.php— Fix phpcs:ignore sniff code:WordPress.CodeAnalysis.AssignmentInCondition→Generic.CodeAnalysis.AssignmentInConditionfield,datasource) andcompact()-based wrappers (fm_add_script,fm_add_style) — Add inlinephpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameteron function signature lines where parameters are intentionally unused in the base implementation or referenced viacompact()Auto-fixed ~100 additional style violations (brace placement, spacing) via
phpcbf.