#39211 closed defect (bug) (fixed)
is_page_template could return true on terms
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 4.7.1 | Priority: | normal |
Severity: | normal | Version: | 4.7 |
Component: | Posts, Post Types | Keywords: | has-patch has-unit-tests fixed-major |
Focuses: | template | Cc: |
Description
Since this function no longer checks is_page(), the ID from get_queried_object_id will always be used to check the post template slug - this ID is not guaranteed to be a post ID. If that ID matches a Post ID with that page template it will return true even though that template is not being loaded. If that ID matches with any Post ID that does not have page template set it will most likely return true is_page_template() with no argument.
Attachments (4)
Change History (18)
#1
follow-up:
↓ 3
@
8 years ago
- Component changed from General to Posts, Post Types
- Keywords needs-patch needs-unit-tests added
- Milestone changed from Awaiting Review to 4.7.1
#2
@
8 years ago
- Keywords has-patch added; needs-patch removed
First try at a patch, if I need to do anything differently let me know.
#3
in reply to:
↑ 1
@
8 years ago
- Owner set to swissspidy
- Status changed from new to assigned
The
is_page()
check should have been replaced with anis_singular()
check.
Ditto.
@natereist Thanks! I'd add braces according to our coding standards, but otherwise that's correct.
I'll try to add some unit tests if nobody else gets to it.
#6
@
8 years ago
39211.2.patch includes a test that creates an ID shared between a term and a post assigned a template, and checks is_page_template()
after visiting the term.
I also included a related change to Tests_Query_Conditionals
and Tests_Query_VerbosePageRules
. Their setUp()
methods currently call set_permalink_structure()
before create_initial_taxonomies()
, such that the initial taxonomies won't have added their permastructs before the first test runs. The patch would flip the order of those calls.
You should be able to see the effect of the current order by running just test_is_page_template_not_singular()
without applying the change to the two setUp()
methods. At least for me, go_to( get_term_link() )
fails during Tests_Query_Conditionals
, so the assertInstanceOf()
also fails. Everything passes the second time through with Tests_Query_VerbosePageRules
.
If the change to setUp()
isn't going to work, then I can find another approach for the new test.
#7
@
8 years ago
- Keywords has-unit-tests added; needs-unit-tests removed
Tests behave as described/intended. Thanks!
#8
@
8 years ago
- Keywords needs-testing added
See [38654] (and the related links on its ticket) for the reason the permastructure is set before the initial taxonomies are re-registered.
#9
@
8 years ago
39211.3.patch tests with user instead of a term, which I don't think would require changing setUp()
.
#10
@
8 years ago
- Keywords commit added; needs-testing removed
- Owner changed from swissspidy to johnbillion
- Status changed from assigned to reviewing
Introduced in [38951].
The
is_page()
check should have been replaced with anis_singular()
check.