WordPress.org

Make WordPress Core

Opened 6 years ago

Closed 6 years ago

#32267 closed defect (bug) (duplicate)

is_page function return true even if it gets 0 as an argument

Reported by: chandrapatel Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.2.1
Component: Query Keywords:
Focuses: Cc:

Description

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.

Attachments (1)

#32267.patch (333 bytes) - added by chandrapatel 6 years ago.
I have attached patch file for ticket #32267

Download all attachments as: .zip

Change History (2)

#1 @SergeyBiryukov
6 years ago

  • Component changed from General to Query
  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Duplicate of #31723.

@chandrapatel
6 years ago

I have attached patch file for ticket #32267

Note: See TracTickets for help on using tickets.