[wp-testers] A RE-EXAMINATION OF THEME REQUIREMENTS - AN ESSAY

Otto otto at ottodestruct.com
Mon Jun 27 23:03:28 UTC 2011


On Mon, Jun 27, 2011 at 5:13 PM, Bruce Wampler <brucewampler at gmail.com> wrote:
> If the same data base item was manipulated with two instances of forms
> using the Settings API, one case would wipe out the sub-settings manipulated
> by the other instance.
> I spent countless hours tracking this down, and in the end, decided it was
> likely a database cache
> problem. The result, however, was that I needed to used two database entries
> - one for each of
> the different Settings API forms.

I'm trying to understand this in more detail.

Presumably you had your settings page all as one form. Then the
validation function would receive all the settings from that single
form, and return the settings which the API would save as your DB
entry.

So if you had two copies of the page open, then saved them both,
whatever was on the second one saved would naturally override the
first. At least, that's what your problem sounds like to me.

There's a few ways around this. One is to make your validation
function only write changes to the DB, however this is still going to
be a problem when you're loading the same form in two tabs, obviously.
Also, with big giant forms you have a problem where you start to
exceed some servers maximum allowed number of POST variables. We even
have this problem on the Menus screen, although it's been improved
somewhat. Make too many menus, and it stops working. Usual number is
about 16 or more.

Still, no reason you can't the page have multiple forms AND still save
all the settings in one DB. Then, as long as the two loaded pages are
on different tabs, then you can still be able to not have one override
the other. You might have to get creative with your form building
though.

-Otto


More information about the wp-testers mailing list