#61307 closed defect (bug) (fixed)
Wrong variable name in filter documentation
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Milestone: | 6.6 | Priority: | normal |
| Severity: | normal | Version: | 6.0 |
| Component: | Query | Keywords: | has-patch commit |
| Focuses: | docs | Cc: |
Description
In r52974 some $pieces variables were changed to $clauses including the usage in docblocks. However, some of the instances were reverted back to $pieces in r53376 but the docblocks were intact creating possibly mis-leading docblocks.
I'd like to propse to change the docblock back to the original state prior r52974
Attachments (1)
Change History (15)
#1
@
18 months ago
- Keywords has-patch added
- Milestone changed from Awaiting Review to 6.6
- Owner set to audrasjb
- Status changed from new to reviewing
This ticket was mentioned in Slack in #core by oglekler. View the logs.
18 months ago
#6
@
17 months ago
I agree that $clauses more accurately describes the associate array expected here after compact( $pieces ), but it does look funny for the comment to not allude to the obvious use of $pieces in context.
The DocBlock at https://core.trac.wordpress.org/browser/trunk/src/wp-includes/class-wp-query.php#L2934 is verbose in describing what $clauses represents. Would it help for the other filter calls to include these details to avoid ambiguity?
This ticket was mentioned in Slack in #core by oglekler. View the logs.
17 months ago
#8
@
17 months ago
- Keywords changes-requested added
Interesting. Looking at the history:
- [52974] changed
$piecesto$clauses. - [53375] for
WP_Query, reverted part of the change forWP_Query-> the individual query pieces array gets assigned to$piecesandcompact( $pieces )represents the$clauses. - [53376] did the same treatment in
WP_Comment_Query,WP_Network_Query,WP_Site_Query, andWP_Term_Query.
Each of these queries are now consistent, which is good.
IIRC, this part of the DocBlock was not reverted back to
$piecesin [53376] specifically to avoid confusion. My thinking was that $clauses representscompact( $pieces ), which gets passed to the filters, not$piecesitself.
So reverting this to
$pieceswould be more confusing for me, but I'm curious to see what others think.
I agree with @SergeyBiryukov and @ironprogrammer. Pieces and clauses are 2 different things. The naming is consistent and aligns well IMO to these 2 different purposes.
The DocBlock at https://core.trac.wordpress.org/browser/trunk/src/wp-includes/class-wp-query.php#L2934 is verbose in describing what $clauses represents. Would it help for the other filter calls to include these details to avoid ambiguity?
I agree with @ironprogrammer. The filter's DocBlock for the others should also receive the more verbose version for the $clauses. Doing so keeps them consistent, helps with understanding, and should avoid confusion.
This ticket was mentioned in PR #6869 on WordPress/wordpress-develop by @hellofromTonya.
17 months ago
#9
For WP_Comment_Query, WP_Network_Query, and WP_Site_Query, expands the $clauses array structure explanation in filter DocBlock.
Benefits:
- Consistency with
WP_QueryandWP_Term_Query. - Helps to improve understanding.
- Should help to avoid confusion of the purpose for pieces and clauses.
Follow-up to r52974, r53375, and r53376.
Trac ticket: https://core.trac.wordpress.org/ticket/61307
#10
@
17 months ago
- Keywords changes-requested removed
Patch: https://github.com/WordPress/wordpress-develop/pull/6869
Now available for review. What do you think?
#11
@
17 months ago
- Keywords commit added
- Owner changed from audrasjb to hellofromTonya
Patch: https://github.com/WordPress/wordpress-develop/pull/6869
With an approval on the PR (thank you @johnbillion), marking for commit. Reassigning to me, as I'm preparing the commit.
@hellofromTonya commented on PR #6869:
17 months ago
#13
Committed via https://core.trac.wordpress.org/changeset/58454.
Thanks for the ticket!
IIRC, this part of the DocBlock was not reverted back to
$piecesin [53376] specifically to avoid confusion. My thinking was that$clausesrepresentscompact( $pieces ), which gets passed to the filters, not$piecesitself.So reverting this to
$pieceswould be more confusing for me, but I'm curious to see what others think.Another thing to consider is that these variable names are often copied when writing new functions attached to the hooks, and
$clausesseems like a more fitting variable name.