Opened 17 years ago
Closed 17 years ago
#10393 closed defect (bug) (fixed)
wp_tag_cloud('order=RAND') broken with PHP >= 5.2.10
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | 2.9 | Priority: | normal |
| Severity: | normal | Version: | 2.8.1 |
| Component: | General | Keywords: | |
| Focuses: | Cc: |
Description
From PHP 5.2.10 the result of array_rand is no longer shuffled. So the output of wp_tag_cloud('order=RAND') is no longer shuffled.
possible solution:
in file category-template.php replace
elseif ( 'RAND' == $order ) {
$keys = (array) array_rand( $tags, count( $tags ) );
$temp = array();
foreach ( $keys as $key )
$temp[$key] = $tags[$key];
$tags = $temp;
$temp = null;
unset( $temp );
}
with
elseif ( 'RAND' == $order ) {
shuffle( $tags );
}
Attachments (1)
Change History (3)
Note: See
TracTickets for help on using
tickets.
The patch contains the suggested change with a small improvement. When sorting randomly what's the point of sorting by count first?
Also not sure how
apply_filters( 'tag_cloud_sort', $tags, $args );is supposed to be used. Is it there so plugins can "re-sort" the already sorted array? Perhaps it needs to be moved up and let a plugin replace the sorting methods, not add more sorting.