joomla/joomla-cms — pull request #1840 by Bakual (2013-08-28 10:48:25+00:00)
Title: Moving the tags observer mapping out from cms.php

Moving the calls to map the observer for tags from the cms.php file to the proper tables.

This is done so the code is better understandable by 3rd party extension developers trying to figure out how tags work.

I also strongly believe that the cms.php file is the wrong place for such calls. As far as I see the file is used to define some constants and provide some backward compatibility with library stuff. Stuff which is needed always when the CMS is loaded.
The tag observer mapping on the other hand is only needed during saving of an item, and then only for the extension currently processed. So the mapping isn't needed for general display of stuff, which is the task that is used mostly for websites.
Thus the mapping shouldn't be done in a place where it is executed for each and every request and for all core extensions. It should be done in a place where it is only executed during saving and only for the extension needed.
I know it isn't a lot of code we talk about here and it's probably not a real performance impact but it is still unneeded.

Now I'm open to where those calls should go.
Personally I believe that it should go into the respective table constructor, like suggested in the comment block in JTableContent:

> This would set up the tags observer in $this from here (so not entirely decoupled):
> JTableObserverTags::createObserver($this, array('typeAlias' => 'com_content.article'));
>
> But this makes the relation between content and tags completely external to Content as JTable is observable:
> So we are doing this only once in libraries/cms.php:
> JObserverFactory::addObserverClassToClass('JTableObserverTags', 'JTableContent', array('typeAlias' => 'com_content.article'));

But I know that at least @beat has a different opinion on this. So I'm open to better places to put it (if there is a better place).

Another place would be the controller invoking the item saving, but then the call would probably be needed in multiple places (save, batch copy), while it would only be needed once when it's in the table constructor.

For reference:
Old PR with discussion: https://github.com/joomla/joomla-cms/pull/1612
TrackerItem (also some discussion): http://joomlacode.org/gf/project/joomla/tracker/?action=TrackerItemEdit&tracker_item_id=31603