Make WordPress Core

Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#27487 closed defect (bug) (fixed)

Clarify the return value of wp_generate_tag_cloud()

Reported by: sergeybiryukov's profile SergeyBiryukov Owned by: nacin's profile nacin
Milestone: 3.9 Priority: normal
Severity: normal Version: 2.7
Component: Taxonomy Keywords: has-patch commit
Focuses: docs Cc:

Description (last modified by SergeyBiryukov)

Background: #27413

The function description says that it only returns a string:
tags/3.8.1/src/wp-includes/category-template.php#L604

However, it can also return an array, depending on format argument:
tags/3.8.1/src/wp-includes/category-template.php#L680

It also returns null if $tags argument is empty:
tags/3.8.1/src/wp-includes/category-template.php#L626

I think it should only return a string or an array, for consistency with the format argument.

Attachments (3)

27487.patch (940 bytes) - added by SergeyBiryukov 10 years ago.
27487.2.patch (2.0 KB) - added by SergeyBiryukov 10 years ago.
27487.3.patch (2.3 KB) - added by DrewAPicture 10 years ago.

Download all attachments as: .zip

Change History (10)

#1 @DrewAPicture
10 years ago

The verbiage of return $return is not my favorite, even though it's already in use at the end of the function. Would be nice if it were something like $output instead.

That said, I agree about returning only a string or array.

#2 @SergeyBiryukov
10 years ago

27487.2.patch changes the variable to $output.

#3 @DrewAPicture
10 years ago

Works for me.

27487.3.patch fixes the hook docs to account for the mixed type on $output.

#4 @SergeyBiryukov
10 years ago

  • Description modified (diff)

#5 @SergeyBiryukov
10 years ago

  • Keywords commit added

#6 @nacin
10 years ago

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

In 27708:

Clarify the return value of wp_generate_tag_cloud().

props SergeyBiryukov, DrewAPicture.
fixes #27487.

#7 @nacin
10 years ago

return $return may be a bit weird, but return $output isn't any more descriptive. I've left it alone to reduce churn.

Note: See TracTickets for help on using tickets.