joomla/joomla-cms — pull request #3414 by Paladin (2014-04-07 00:34:33+00:00)
Title: Conversation starter for JTable::publish() revision

Not sure how valuable this will turn out to be in the long run, but while I was tooling around the db I noticed that some components used "published" for the publishing state column, and some used "state". Since JTable::publish() is hard-coded for the "published" column, anything using 'state' has to "roll their own" publish method.

By adding a fourth parameter ($column) to JTable's publish method, which defaults to 'published', any of the existing components that rolled their own with 'state' (from appearances, 'state' seems to be the current thinking of what that column should be called) can turn their current publish method into a one-line shim with a call to parent::publish that adds the table column they're using on the end. This results in a savings of around 70 lines per method replaced, if they pulled the entire publish method in.

Change adds one comment line to the docblock, and simply replaces the hard-coded table name with the fourth parameter. Older code is unaffected, because the parameter is written to default to what it is currently hard-coded to be. This simply allows 'state' to be used in place of 'published' for any component that needs it.

Attached to this PR is the change at its very simplest to illustrate the point.

Alternatively, existing components using state could be brought into line with the hardcoded 'published' to achieve the same goal. It just seemed to me that 'state' makes for a more accurate column name and looks to be where we're headed so this makes it possible for everyone to start moving that way now.