[geeklog-devel] RFC: Simplifying PLG_itemSaved
dirk at haun-online.de
Sat Jan 17 11:56:55 EST 2009
This is the third (and last, I promise) Request For Comments on plugin
API changes for Geeklog 1.6. I'm still interested in any feedback on my
previous two, regarding Plugin auto install and Plugin migration.
Almost 4 years ago, Blaine and myself came up with the idea for
PLG_itemSaved. The hope was to provide an API into which plugins could
hook and that would inform them whenever something was saved in Geeklog,
so that they could act on it.
Part of the concept was an abort and rollback mechanism, where plugins
could report an error and signal to Geeklog (and other plugins) that
there was a problem and that the save operation should be aborted. In
which case the user would be taken back to the editor where s/he was
informed of the problem and could try again.
Fast-forward four years and that mechanism has only been implemented for
stories. And, looking at the code (in 1.4 and 1.5), not even been
implemented correctly. And it hasn't caught on either (i.e. isn't being
used by any plugins, to the best of my knowledge). Neither has it been
implemented anywhere else.
Why is that? I think it's because the API is too complicated. Namely,
the abort and rollback isn't really needed.
My suggestion would be: Get rid of the abort. When something is saved (a
story, a static page, etc.), it calls PLG_itemSaved. Plugins interested
in that information can still hook into it, but they can no longer abort
the process (why should a plugin be able to tell Geeklog - and the user
- that a story should not be saved anyway?).
Over the years, we had a lot of scenarios where something like
PLG_itemSaved (implemented everywhere) would have come in handy. I think
it's time we finally do that. And if the complexity of the API is
holding us back here, then we need to fix that.
I realize there's also PLG_itemPreSave, which is supposed to be called
before the save, and which _can_ cause an abort. We should keep that and
implement it everywhere, too, so that every call to PLG_itemSaved is
preceded by a call to PLG_itemPreSave. That should handle situations
where plugins still want to abort, for whatever reason. Only then it
would happen before the object ended up in the database, which gets rid
of the rollback and makes things much easier.
More information about the geeklog-devel