Opened 8 years ago
Last modified 4 years ago
#31711 new defect (bug)
is_front_page flag affected by frontpage ID and page Title strange conflict
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 3.1 |
Component: | General | Keywords: | has-patch |
Focuses: | Cc: |
Description
I want to report a strange bug. The is_front_page flag has incorrect value in cases like described below:
Front page in Settings / Reading is set to a static page: http://i.imgur.com/DzrbOVM.png
This Sample Page ID is 2
If you visit any other page, all is fine. For example the Lorem ipsum page: http://i.imgur.com/n5M0x8R.png
However, if you change title of this page to be the same as ID of a frontpage - in my case 2, then the is_front_page flag changes value to incorrect: http://i.imgur.com/KCa1JYo.png
It happens for titles like: 2, 02, 000002. Basically always if (int)$page_title == $front_page_id
The wrong is_front_page flag may affect themes/plugins which use it.
It's quite rare for the bug to take effect, but it happens, as I got a report from a user of my theme.
I was able to reproduce the described issue. That's such an interesting bug.
This is caused by the (expected) ambiguous behavior of the
is_page()
conditional tag, which is used withinis_front_page()
.As the documentation states,
is_page()
accepts:Page ID, title, slug, path, or array of such
, so in that case2
is being accepted as title, which is why theis_front_page()
function returnstrue
.Patch with a fix is coming in a minute.