WordPress.org

Make WordPress Core

Opened 5 years ago

Closed 5 years ago

#11839 closed defect (bug) (fixed)

Two notices in post_custom()

Reported by: sirzooro Owned by:
Milestone: 3.0 Priority: normal
Severity: normal Version: 2.9.1
Component: Template Keywords: has-patch
Focuses: Cc:

Description

When someone will use non-existing index, PHP will display following notices:
Notice: Undefined index: views in C:\wordpress.local\wp-includes\post-template.php on line 649
Notice: Undefined index: views in C:\wordpress.local\wp-includes\post-template.php on line 652

Attached patch fixes this - when someone will use non-exiting index, post_custom() will return empty string.

Attachments (1)

post-template.php.diff (391 bytes) - added by sirzooro 5 years ago.

Download all attachments as: .zip

Change History (4)

@sirzooro5 years ago

comment:1 @sirzooro5 years ago

Hmm, I wonder if it would be better to return null instead.

comment:2 @dd325 years ago

I've gone with returning (bool)false.

'' == false == null for displaying in a string, they'd all display as nothing, but given that bools cant be returned from the post_meta i do not believe, it seems to be the best choice in this case.

comment:3 @dd325 years ago

  • Resolution set to fixed
  • Status changed from new to closed

[13861] /trunk/wp-includes/post-template.php: Fix notices in post_custom(). Props sirzooro. Fixes #11839

Note: See TracTickets for help on using tickets.