[wp-trac] [WordPress Trac] #22652: Refine media state machine methods

WordPress Trac noreply at wordpress.org
Fri Nov 30 11:42:41 UTC 2012


#22652: Refine media state machine methods
-------------------------+--------------------------
 Reporter:  koopersmith  |       Type:  defect (bug)
   Status:  new          |   Priority:  normal
Milestone:  3.5          |  Component:  Media
  Version:  trunk        |   Severity:  normal
 Keywords:  has-patch    |
-------------------------+--------------------------
 Currently, the media state machine has a set of most unfortunately named
 methods — `get` and `state` — where `get( id )` returns a state, `state()`
 returns the current state, and `state( id )` sets the current state. The
 biggest problem here is `get`, which is often confusing, and returns a
 result that itself has a get method (calling `get('a').get('b')` becomes a
 bit opaque). This is compounded by the fact that `state()` returns the
 current state, and actually has a sensible name, so it's easy to slip and
 think that `state( id )` will return a state as well. Lastly, the mostly
 unused `previous()` can be renamed to the more verbose `lastState()`.

 So, let's fix that. This is mostly just renaming:
 * `state( id )` becomes `setState( id )`
 * `get( id )` becomes `state( id )`
 * `state()` stays the same
 * `previous()` becomes `lastState()`

 Why now? `get()` is such a common method name, that by leaving this be,
 we'll effectively never be able to add a `get()` method to the media frame
 — the main object you interact with. It's now or never.

 How to test this? Just play around with media in its various incarnations,
 keep an eye out for errors.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/22652>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list