Opened 13 months ago
Closed 7 months ago
#20519 closed defect (bug) (fixed)
PHP Notice in get_single_template()
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Priority: | normal | Milestone: | 3.5 |
| Component: | Warnings/Notices | Version: | 3.0 |
| Severity: | normal | Keywords: | has-patch commit |
| Cc: |
Description
PHP Notice: Trying to get property of non-object in wp-includes/template.php on line 283
These get_*_template() functions make a lot of assumptions about the current state of the environment.
Attachments (2)
Change History (8)
comment:1
SergeyBiryukov — 13 months ago
wonderboymusic — 8 months ago
comment:3
wonderboymusic — 8 months ago
- Keywords has-patch added
- Milestone changed from Awaiting Review to 3.5
This patch has basic validation for the passing of vars to template file names
I think in most cases it should be enough to validate we have an object. So rather than:
if ( isset( $author->user_nicename ) )
$templates[] = "author-{$author->user_nicename}.php";
if ( isset( $author->ID ) )
$templates[] = "author-{$author->ID}.php";
We can do:
if ( $author ) {
$templates[] = "author-{$author->user_nicename}.php";
$templates[] = "author-{$author->ID}.php";
}
Note: See
TracTickets for help on using
tickets.

Related: #17662, #18614