Stop documenting 'filter' as an available field - #644
Conversation
'filter' is a property of WP_Post and WP_User rather than a column of either table. It holds the sanitization level the object was loaded with, which is 'raw' for every row 'wp post list' returns and empty for every row 'wp user list' returns. Neither tells a reader anything about the post or the user. 'wp post get' has never shown it, so listing it as available only for the list commands was inconsistent as well as useless. This drops it from the documented fields and leaves the commands alone. The property is still on the objects, so asking for it by name still produces what it always did, but nothing advertises it any more. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014SSZzqMJRDTiLiDxQEPYcL
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
💤 Files with no reviewable changes (3)
Included review availability: Your plan includes up to 2 reviews per rolling hour; 1 remains after this review. 📝 WalkthroughWalkthroughThe change removes ChangesList field documentation
Estimated code review effort: 1 (Trivial) | ~2 minutes Merge Risk: ⚪ Minimal · up to This localized documentation-only change removes misleading 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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 |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
filteris a property ofWP_PostandWP_User, not a column of either table. Core's own docblock says so: "Stores the post object's sanitization level. Does not correspond to a DB field." It holdsraw,edit,displayand so on — how the object was sanitized, nothing about the post or the user.In practice it is a constant:
filterprintswp post listraw, for every rowwp user listwp post getwp post gethas never displayed it, so advertising it only for the list commands was inconsistent as well as useless.This drops it from the documented fields on
wp post listandwp user listand leaves the commands themselves alone. The property is still on the objects, so asking for it by name still yields what it always did — nothing advertises it any more.The field list was never exhaustive
Worth knowing when reading this diff: "documented" and "works" have never been the same set for these commands.
WP_Postresolves anything it does not declare through__isset()/__get(), so all of the following work as fields onwp post listtoday, and none of them are listed under AVAILABLE FIELDS:post_category[1]tags_inputpage_templateancestorsmy_meta→helloSo AVAILABLE FIELDS is the useful subset rather than a whitelist, and removing an entry from it says "this is not worth reaching for" rather than "this no longer resolves".
filtersimply joins the group above.Why documentation only
I first tried actually suppressing it, and that turned out to be the wrong trade. Removing it from a
WP_Postmeans either unsetting the property or building an array of the object's properties, and both cost more than they are worth:unset( $post->filter )does not remove the field.property_exists()still returnstruefor a declared property after unsetting it, so the formatter still reports it accessible; andWP_Post::__isset()falls through tometadata_exists( 'post', $this->ID, $key ), so the name becomes a post-meta lookup — a query per row, returning a post meta value literally namedfilterif one existed.get_object_vars( $post )drops every field in the table above.wp post list --fields=ID,post_categoryreturns[1]today and would return an empty column with a warning.wp post getlacks those magic fields precisely because it does build an array, so makinglistmatchgetwould meanlistlosing something real. Not worth it to hide a field that no longer appears in the docs.Refs wp-cli/wp-cli#5286
Summary by CodeRabbit
wp post listandwp user listdocumentation to removefilterfrom the listed optional fields.