Opened 13 years ago
Closed 9 years ago
#18356 closed defect (bug) (fixed)
get_bookmarks() indefinitely caches randomly ordered results
Reported by: | prettyboymp | Owned by: | boonebgorges |
---|---|---|---|
Milestone: | 4.6 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Query | Keywords: | good-first-bug has-patch |
Focuses: | Cc: |
Description
The get_bookmarks() function caches the results of all requests to the function in a single cache result so it can clear all the items when a new book mark is added. However, randomly ordered results shouldn't be cached indefinitely. This specifically affects the Links widget as it never refreshes when set to random order.
Attachments (6)
Change History (28)
#4
follow-up:
↓ 6
@
13 years ago
I'm not sure why you are re-implementing the expiration functionality that is already built into the caching system here.
If we need to use a different cache bucket and add expiration for RAND requests lets do that but don't implement a second level of expiration when we have one already.
#5
in reply to:
↑ 3
@
13 years ago
Replying to SergeyBiryukov:
$orderby == 'rand()'Shouldn't it be
$orderby == 'rand'
(without brackets)?
It's 'rand()' at that point because the $orderby variable is reused when building the query in the case statement.
#6
in reply to:
↑ 4
;
follow-up:
↓ 7
@
13 years ago
Replying to westi:
I'm not sure why you are re-implementing the expiration functionality that is already built into the caching system here.
If we need to use a different cache bucket and add expiration for RAND requests lets do that but don't implement a second level of expiration when we have one already.
The problem with creating a new cache bucket is that you can't purge it automatically after modifying the bookmarks.
#7
in reply to:
↑ 6
@
13 years ago
Replying to prettyboymp:
Replying to westi:
I'm not sure why you are re-implementing the expiration functionality that is already built into the caching system here.
If we need to use a different cache bucket and add expiration for RAND requests lets do that but don't implement a second level of expiration when we have one already.
The problem with creating a new cache bucket is that you can't purge it automatically after modifying the bookmarks.
Yes, but if it has a shortish expiration which is what you are suggesting here to deal with the RAND issue then that doesn't really matter.
#8
@
11 years ago
- Keywords has-patch needs-testing removed
- Resolution set to wontfix
- Status changed from new to closed
Not sure if many people are still using bookmarks and blogrolls.
#10
@
11 years ago
- Keywords has-patch added
- Resolution wontfix deleted
- Status changed from closed to reopened
#14
@
9 years ago
- Component changed from General to Query
- Keywords needs-refresh added
This doesn't strictly belong in the Query component, but I'd be interested to hear feedback from @wonderboymusic or @boonebgorges on this. Too many bookmarks/links-related tickets get stuck in the General component and never come out.
Couple notes on the patch as-is:
- Needs a refresh
- The reiteration of the filter will need a duplicate hook comment
- The expiration should use
MINUTE_IN_SECONDS
instead of 60
#15
@
9 years ago
- Keywords 2nd-opinion added; needs-refresh removed
A separate cache bucket for randomly ordered results seems fine to me. It makes for a funny structure to the cache - the non-random results are stored in a multi-d array in a single cache slot, while random results get their own top-level cache slot - but I guess that's not such a big deal, given that the cache strategies are different in the two cases.
I don't see a good reason to expose 'expire'
as a function parameter. In 18356.4.diff, I moved it to a filtered value.
This seems like a good fix IMO, but would like a second opinion before moving forward.
This ticket was mentioned in Slack in #core by boone. View the logs.
9 years ago
#17
@
9 years ago
- Keywords needs-patch good-first-bug added; has-patch 2nd-opinion removed
- Milestone changed from Awaiting Review to Future Release
After discussion, it seems like a more straightforward fix may be to skip the cache for random results. This is more consistent with other rand()
treatments throughout WP.
#19
@
9 years ago
- Keywords has-patch added; needs-patch removed
@boonebgorges can you review this patch and let me know any changes are needed.
Shouldn't it be
$orderby == 'rand'
(without brackets)?