#41981 closed enhancement (fixed)
link-template.php: if ($x = $y ) vs if ($x == $y)
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 5.1 | Priority: | low |
Severity: | normal | Version: | |
Component: | Permalinks | Keywords: | 2nd-opinion has-patch |
Focuses: | Cc: |
Description
While reading through the code I came across line 189 of wp-includes/link-template.php (WordPress 4.8.2):
if ( $parent = $category_object->parent )
I don't have a behavior to reflect this but it looks like the common bug where the incorrect single equals sign appears in a conditional. There should probably be 2 or 3 equal signs here.
Attachments (1)
Change History (7)
#2
@
7 years ago
Thanks @JPry for the clarification and for providing a patch. The patch definitely makes it more clear for someone looking over the code for the first time.
#3
@
7 years ago
- Component changed from General to Permalinks
- Priority changed from normal to low
- Type changed from defect (bug) to enhancement
- Version 4.8.2 deleted
Please note that there's also #41057 to fix coding standards in core once and for all. Much easier than having dozens of very small tickets for things not really worth fixing on their own.
Note: See
TracTickets for help on using
tickets.
Hi @danimalbrown, welcome to Trac! In this particular instance, the
$parent
variable is being set deliberately. It is subsequently used within the next line:The
$parent
variable isn't used anywhere else within that function. This certainly is a confusing section of code, and it was a good idea to call it out as a potential issue.Generally, something like this wouldn't be changed for the sole purpose of bringing it into line with the WordPress Coding Standards, but there may be room to eliminate the
$parent
variable in order to help clear up the confusion.I'll upload a patch.