Make WordPress Core

Opened 8 years ago

Closed 8 years ago

#11592 closed defect (bug) (wontfix)

the_author() always returns a value when it only should for back compat

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


the_author() has a deprecated argument set to false, it returns get_the_author() instead of echoing get_the_author().

However, if the_author() is run on its own, it not only echoes get_the_author(), but returns it as well.

This will introduce hypothetical backwards compatibility issues, but if someone is using the_author() to return a value, they're doing it wrong for one of two reasons. One, they're using a deprecated argument, and _deprecated_argument() should now point them to get_the_author(). Or two, they're not using the deprecated argument, and the_author() is echoing whatever they also want returned.

Patch corrects this by adding the word "else" where it was presumably omitted.

Attachments (2)

11592.diff (1.1 KB) - added by nacin 8 years ago.
11592.2.diff (1.5 KB) - added by nacin 8 years ago.
Refreshed against changes in #11386.

Download all attachments as: .zip

Change History (8)

8 years ago

#1 @nacin
8 years ago

  • Keywords has-patch added

8 years ago

Refreshed against changes in #11386.

#2 follow-up: @prettyboymp
8 years ago

I prefer the return value to always be there. It allows you to easily use the_author() directly within an if statement.

#3 in reply to: ↑ 2 @nacin
8 years ago

Replying to prettyboymp:

I prefer the return value to always be there. It allows you to easily use the_author() directly within an if statement.

No other template tag functions this way, and it is an unintended bug caused by faulty implementation of backwards compat code.

Can you provide an example? That will help a lot here.

Perhaps then provide an example of a template tag that does not return + echo at once, such as the_title().

#4 @prettyboymp
8 years ago

My apologies. I am not sure why I thought the other template functions still returned the value they echoed. While I would personally prefer that the template functions also returned the echoed value, if all others don't, I agree with making them all follow the same rules. Whether that means modifying the_author or the other template functions.

#5 @hakre
8 years ago

Any chances to see this comitted early to get this cleaned up?

#6 @nacin
8 years ago

  • Milestone 3.0 deleted
  • Resolution set to wontfix
  • Status changed from new to closed

According to [4146], the_author() always echo'd and returned a value. Going to close this as wontfix.

Note: See TracTickets for help on using tickets.