Make WordPress Core

Opened 17 years ago

Closed 17 years ago

#11839 closed defect (bug) (fixed)

Two notices in post_custom()

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

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 17 years ago.

Download all attachments as: .zip

Change History (4)

#1 @sirzooro
17 years ago

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

#2 @dd32
17 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.

#3 @dd32
17 years ago

  • Resolution → fixed
  • Status new → 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.