[wp-trac] [WordPress Trac] #41981: link-template.php: if ($x = $y ) vs if ($x == $y)

WordPress Trac noreply at wordpress.org
Mon Sep 25 16:34:28 UTC 2017


#41981: link-template.php: if ($x = $y ) vs if ($x == $y)
-----------------------------------+------------------------------
 Reporter:  danimalbrown           |       Owner:
     Type:  defect (bug)           |      Status:  new
 Priority:  normal                 |   Milestone:  Awaiting Review
Component:  General                |     Version:  4.8.2
 Severity:  normal                 |  Resolution:
 Keywords:  2nd-opinion has-patch  |     Focuses:
-----------------------------------+------------------------------
Changes (by JPry):

 * keywords:   => 2nd-opinion has-patch


Comment:

 Hi @danimalbrown, welcome to Trac! In this particular instance, the
 `$parent` variable is being set deliberately. It is subsequently used
 within the next line:

 {{{#!php
 <?php
 if ( $parent = $category_object->parent )
         $category = get_category_parents($parent, false, '/', true) .
 $category;
 }}}

 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   [https://make.wordpress.org/core/handbook
 /best-practices/coding-standards/php/ 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.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/41981#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list