I have extended Page into my ItemPage and added a few Varchar fields in the $db static. I also have added a tab to the CMS that will reach out via API to a service to set its name there. When the API call (which is a method of ItemPage) succeeds it will do a write to itself like $this->APIServiceName = $api_return; $this->write();
This all works well up to this point. Whenever changes are made to any other tab or CMS field my APIServiceName gets wiped out. Looking at the DB I see that my APIServiceName is set in ItemPage_Live, it will go missing off and on from ItemPage, but it is never set in ItemPage_versions.
I have a feeling it has to do with Versioned. Is there a new object created in Stage every time that wouldn't copy all the data over? If i am doing the write from within a ItemPage object am I not writing to the correct Stage/Live version?
Weird, now that I have done all kinds of crazy onBeforeWrite() work to force the API to be re-called and APIServiceName written to every time, I see now that it exists in every ItemPage and ItemPage_Live table.
Now I'm having a hard time make it null so I can test your suggestion above.
My issue is resolved, but I guess I need to spend some time discovering how the Versioned code works with respect to pushing between environments. There seems to be some kind of copying to/from that I have yet to make sense of.
Is it that Versioned items need to have the publish performed in additional to any ->write() calls to keep them in sync?