[wp-trac] [WordPress Trac] #25047: Improve heartbeat queue checking
WordPress Trac
noreply at wordpress.org
Thu Aug 15 03:51:32 UTC 2013
#25047: Improve heartbeat queue checking
--------------------------+-----------------------------
Reporter: evansolomon | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version:
Severity: normal | Keywords: has-patch
--------------------------+-----------------------------
The JS heartbeat API has an `isQueued()` method, but it also checks
whether a given handle is already queued in its `enqueue()` method
(without using `isQueued()`). Unfortunately the checks are not quite
equal. Currently `isQueued()` will return (likely) incorrect truthy
values if you do something like `wp.heartbeat.isQueued('constructor')`, or
the somewhat ironic `wp.heartbeat.isQueued('hasOwnProperty')`.
1. The `enqueue()` method should use the publicly available `isQueued()`
for consistency
1. The `isQueued()` method should use `hasOwnProperty()`
I also rearranged the order of the queue check in `enqueue()` to check
`dont_overwrite` before the checking the queue. The `dont_overwrite`
param is falsey by default, so we might as well check that before doing
the more expensive operation of checking the queue (we don't care if
something is in the queue if we're going to overwrite it anyway).
--
Ticket URL: <http://core.trac.wordpress.org/ticket/25047>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list