[wp-hackers] How do you store multiple plugin options

Mike Schinkel mikeschinkel at newclarity.net
Wed Mar 24 21:19:05 UTC 2010


On Mar 24, 2010, at 4:58 PM, Otto wrote:
>> My takeaway is that it's an acceptable hack at time while at other times it can result in data of actual data.  For example, if I wanted to change one but not all similar values in a complex option I could easily overwrite other data that I hadn't intended to overwrite.
> 
> That would be a plugin programming error though, not a user error. And
> it's one that is easy enough to avoid.

But one that would be very hard to test for robustness.  It's the edge cases in that data that would cause problems, enough so that I don't think I could recommend updating data in serialized arrays via SQL except in rare cares.  If the data is not in serialized arrays then it's easy to ensure robustness.

The key takeaway here is that, while there are many benefits to storing data, this is one downside for which there is no good solution when SQL is really the best option.  Saying it's "easy" just glosses over the real concerns.  

I'm not arguing that people don't store options in normalized data vs. serialized arrays, I'm saying we just shouldn't imply a recommendation that they use SQL to update serialized arrays by telling them it is easy. They shouldn't do that and if they really do need to then serialized arrays are not the answer. Sadly the person with the use-case where it's not the answer isn't always the same person who decides how to store the option.)

-Mike


More information about the wp-hackers mailing list