[wp-trac] [WordPress Trac] #32267: is_page function return true even if it gets 0 as an argument

WordPress Trac noreply at wordpress.org
Wed May 6 14:45:56 UTC 2015


#32267: is_page function return true even if it gets 0 as an argument
--------------------------+-----------------------------
 Reporter:  chandrapatel  |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  General       |    Version:  4.2.1
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 [[Image(http://www.chandra-study.com/chandrastudy/wp-
 content/uploads/2014/05/is_page-returns-true-when-passed-0.jpg)]]

 I think the is_page function should return false if 0 or false is passed.
 I will try to explain why I faced problem because of this.

 I used Product Vendor Plugin, it stores the vendor page id in "options".
 If it's not set, it returns 0.
 Then the if condition satisfies because is_page( 0 ) returns true and then
 next line gets executed which redirects user to myaccount page (We didn't
 want this).

 I corrected this problem in the plugin by different way. But I think that
 is_page should never return true if it gets 0 in parameter.

 So if someone passes pageid = 0, then returning true implies page with
 id=0 is WordPress page. Let me know your thoughts.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/32267>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list