Make WordPress Core

Changes between Initial Version and Version 2 of Ticket #27413


Ignore:
Timestamp:
03/21/2014 02:29:43 PM (11 years ago)
Author:
SergeyBiryukov
Comment:

Looks like the only way to trigger these warnings is to return an empty array in tag_cloud_sort filter:

add_filter( 'tag_cloud_sort', '__return_empty_array' );

This looks like a developer error, so the developer should see the warning.

If the goal is to remove the output, wp_generate_tag_cloud filter should be used instead: tags/3.8.1/src/wp-includes/category-template.php#L694

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #27413

    • Property Keywords has-patch close added
    • Property Component changed from General to Taxonomy
  • Ticket #27413 – Description

    initial v2  
     1
    12 PHP Warning: min(): Array must contain at least one element in /var/vhost/xxxx/wp-includes/category-template.php on line 658
    23 PHP Warning: max(): Array must contain at least one element in /var/vhost/xxxx/wp-includes/category-template.php on line 659
    34
    4 I'm not sure how to reproduce the bug but it can be fixed easily by replacing min( $counts ) with count( $counts ) > 0 ? min( $counts ) : 0 and replacing max( $counts ) with (count( $counts ) > 0 ? max( $counts ) : 0). Or by checking whether $counts is empty and returning early.
     5I'm not sure how to reproduce the bug but it can be fixed easily by replacing `min( $counts )` with `count( $counts ) > 0 ? min( $counts ) : 0` and replacing `max( $counts )` with `(count( $counts ) > 0 ? max( $counts ) : 0)`. Or by checking whether $counts is empty and returning early.