What I'm trying to do seems like it should be simple. It's for the StageCoach extra, which creates a staged resource, the fields of which are used to update the fields of the original resource at a certain date and time. The first person to visit the page after that time should see the new content.
So, I want to update the fields of a document during the request process before it's parsed.
Everything works fine if the target document is not cached or if its cached version has not been created yet.
If the cached version exists, I can replace the fields of $modx->resource in OnLoadWebDocument, save the resource with the cacheFlag set, physically delete the cache file, refresh or remove the cached version or refresh the whole site cache, but MODX still shows the old version of the resource and the cache is not updated.
It appears that the resource is in memory (in some place other than $modx->resource) and that version is used to refresh both the cache and $modx->resource after my code executes. The cached, obsolete version is then retrieved, parsed, and displayed.
I've updated the DB, and cleared the cache for the Resource so is there some way to modify or invalidate the version of the Resource that's in memory?
I may be able to do everything in OnWebPageInit, but it will slow down the site because I'll have to retrieve the resource and check a TV value for every page load rather then just using $modx->resource (which isn't complete at that point).
I could also do my updates later in the process, but then the second person to visit the page would see the updates rather than the first.