Code / Appnel Solutions 

Posted
9 October 2007 @ 2pm

No Settings for YAML

I admit to being very critical and not at all fond of the plugin settings interfaces to the extent I don't use them and rolled my own. Seems I have one more reason to be frustrated with them.

If your plugin has blog or system settings you can't use a YAML definition file.

There wasn't an example in the documentation or example code that doesn't mean much so I took the one plugin I wrote that uses the built-in MT plugin settings functionality and hacked together a quick script that dumps the settings data structure to YAML.

settings:
  -
    - api_key
    -
      Scope: system
  -
    - weight
    -
      Default: 1
      Scope: blog

Egads! Even the YAML looks ugly. I adapted what I was seeing for the plugin I'd been working on.

settings:
  -
    - enabled
    -
      default: 1
      scope: blog

This is when I found the shop stopper. When I enter a blog's plugin setting screen I get this error:

Can't call method "defaults" on unblessed reference at lib/MT/Plugin.pm line 179.

Plugins are now completely inaccessible. That's problem one. A misbehaving plugin shouldn't be allowed to know out MT like this. (How would a user without technical skills handle this now?)

The plugin stores the settings data structure in the correct registry location. The problem is line 179 expects a MT::PluginSettings object and not a HASH reference that causes the error to occur. (MT shouldn't lock up with an error of this nature either, but that is a different matter.)

This is a real bummer to me because I see YAML definition files being the best way for developing and managing components in MT going forward that it should be a good habit all plugin developers get into. With something as common and important as plugin settings unimplemented and the existence of a YAML file causing a .pl file to be ignored, it makes it really hard to use YAML for anything but the most simplistic plugins. I had a similar experience with MT 4.0 where callbacks defined in a registry file were note registered and never ran. (This was subsequently fixed in 4.01.)

This brings me back to one gripe I have about the MT4 code. The YAML registration files were are a highly touted part of the component architecture plan for MT4, but the application itself doesn't use them opting for embedded Perl code. (Whatever happened to practicing what you preach?) Had they been used in developing MT4 I'm certain these sort of issues would have come to light sooner and perhaps been fixed/implemented before MT was released.

There may be some trick or work around to implementing settings with a YAML definition file that I've yet to discover. If there is (please leave it in the comment below) this brings me back to another point I've been making since well before MT4 -- developers should have to work so hard to make things work. Things have improved, but it's times like these, when what's been communicated and what's been done in practice don't line up, that still burn me up.


← Before After →