[buddypress-trac] [BuddyPress Trac] #3856: Saving activity update action as an array in db
buddypress-trac
noreply at wordpress.org
Thu Mar 13 18:34:07 UTC 2014
#3856: Saving activity update action as an array in db
-----------------------------------+---------------------------
Reporter: modemlooper | Owner: boonebgorges
Type: enhancement | Status: closed
Priority: normal | Milestone: 2.0
Component: Activity | Version:
Severity: normal | Resolution: fixed
Keywords: has-patch 2nd-opinion |
-----------------------------------+---------------------------
Changes (by boonebgorges):
* owner: => boonebgorges
* status: new => closed
* resolution: => fixed
Comment:
In [changeset:"8125"]:
{{{
#!CommitTicketReference repository="" revision="8125"
Generate activity actions dynamically, instead of using static values
stored in the database
Activity actions - like 'Joe became a registered member' - have always
been
stored as static strings in the activity table. This has been a perennial
thorn
in the side of BP site administrators. For one thing, static strings
cannot be
translated for multilingual audiences (without unreasonable workarounds).
For another, information in these static strings becomes out of date as
users
change their display names, groups change their names, and so on.
This changeset makes it possible for activity types to be registered with
a
new $format_callback function, passed to bp_activity_set_action(), which
BP
will use to generate the action dynamically when building the activity
loop.
This makes the activity stream fully localizable, continually up-to-date,
and
generally the bomb dot com.
Existing plugins that do not register format_callback functions will
continue
to have their actions pulled directly from the database. Likewise, since a
copy
of the static string is saved in the activity table, static strings can be
served if the given component is disabled at any point (and thus the
callback
is no longer available).
The original argument for caching the action strings was that generating
them
inline was too resource intensive; it often requires pulling up display
names,
user permalinks, group links, blog post names, and so forth. To address
this
problem, each component can now prefetch required data at the beginning of
an
activity loop by hooking to bp_activity_prefetch_object_data, and loading
any
relevant data into the cache. The Activity, Friends, Groups, and Blogs
component now do this natively. It's likely that this prefetching will
have
other performance benefits, as plugin authors will now be able to access
user
data etc inline without performance penalties.
The case of the Blogs component is a special one; it's not practical to
prefetch data from multiple blogs at the beginning of a loop, due to the
resources required by switch_to_blog(). For this reason, the
format_callback
functions in the blog component cache some relevant data (like the post
name)
in blogmeta, where it's readily accessible within the loop.
Fixes #3856
}}}
--
Ticket URL: <https://buddypress.trac.wordpress.org/ticket/3856#comment:30>
BuddyPress Trac <http://buddypress.org/>
BuddyPress Trac
More information about the buddypress-trac
mailing list