[buddypress-trac] [BuddyPress Trac] #6865: `bp_activity_get_actions()` should only sort when necessary

buddypress-trac noreply at wordpress.org
Fri Feb 5 03:31:23 UTC 2016


#6865: `bp_activity_get_actions()` should only sort when necessary
----------------------------------------+------------------
 Reporter:  boonebgorges                |       Owner:
     Type:  enhancement                 |      Status:  new
 Priority:  normal                      |   Milestone:  2.5
Component:  Component - Activity        |     Version:
 Severity:  normal                      |  Resolution:
 Keywords:  has-patch needs-unit-tests  |
----------------------------------------+------------------

Comment (by boonebgorges):

 Thanks for the tests, @imath.

 I realize now that the patch I uploaded [attachment:6865.2.diff] doesn't
 actually contain the `static $sorted` workaround I described above.
 Whoops. This `$sorted` was meant to address exactly what your test
 demonstrates.

 I repatched and was about to upload, but then I got discouraged. Setting
 flags seems very fragile and bad practice. The problem is that sorting
 should happen only when necessary, which is to say when a new action is
 added. So I decided instead to move the sorting to
 `bp_activity_set_action()`. This means that sorting happens a bit more
 frequently than it otherwise might (every time an action is added - maybe
 20 times during a pageload), but each sort is only on the affected
 component, rather than all components. And subsequent calls to
 `bp_activity_get_actions()` - even hundreds of them - will result in no
 additional sorting. This seems to me to be a good tradeoff.

--
Ticket URL: <https://buddypress.trac.wordpress.org/ticket/6865#comment:7>
BuddyPress Trac <http://buddypress.org/>
BuddyPress Trac


More information about the buddypress-trac mailing list