Hi all I've encountered a bit of a situation where Options::get(), as used with plugins, is drawing from a cached source, and I need to force it not to.
I've posted a basic outline of the code at http://pastoid.com/bh5 with comments to give you an idea of what I'm doing. I discussed this with Mikelietz on IRC tonight, and our conversation was as follows (pasted so you can see what I've tried): --- [19:44] lildude_home: Hi all. Quick Q: is there anyway I can force Options::get() to NOT pull in a cached version? [19:46] mikelietz: lildude_home: plugin options? [19:47] lildude_home: Yup. [19:47] mikelietz: what is caching them? [19:49] lildude_home: mikelietz: no idea. I'm porting a plugin across from WP and I'm using the on_success FormUI method to submit and save the options. I immediately requery the options and instead of getting the updated options, I get my previous options, even though the new options have made it to the DB. Closing the "Configure" box, or refreshing brings back the updated options. [19:50] lildude_home: Actually, I've just had a thought as I types that. One mo... [19:50] lildude_home: s/types/typed/ [19:50] JibbyBot: lildude_home meant: Actually, I've just had a thought as I typed that. One mo... [19:51] lildude_home: Nevermind. Didn't work [19:52] Morydd: Is it an ajaxy thing, the options don't actually reload maybe? [19:53] mikelietz: lildude_home: that on_success isn't really needed [19:53] mikelietz: submitting should save the options for you. [19:54] mikelietz: what are you using as a reference? [19:54] lildude_home: mikelietz: interesting you say that. I'm going via this method so I can serialize all the options into a single option rather than using multiple option entries. [19:54] mikelietz: oh, I see. [19:54] mikelietz: well, that would complicate things [19:54] lildude_home: WRT your last Q: in what respect? [19:55] mikelietz: wondering if you had an out-of-date plugin to work from - it was a long shot. Clearly your problem is not from being out of date. [19:55] mikelietz: so. [19:55] mikelietz: hmm. [19:55] lildude_home: Aaah, nope. Sadly not. [19:56] mikelietz: pastoid or some such? I'll take a look. [19:59] mikelietz: lildude_home: ? [19:59] lildude_home: Soz. Had to refill my beer. What do you mean ? [20:00] lildude_home: What's pastoid? [20:00] mikelietz: if you paste it somewhere I can take a look. Pastoid.com is one such place you can do so. [20:00] lildude_home: ahh. one mo [20:00] mikelietz: np [20:12] lildude_home: mikelietz: http://pastoid.com/bh5 - It's very simplified, but should give you an idea. I've added comments too that should help explain what I'm seeing. [20:13] mikelietz: if you just print_r() that $options before displaying yhr config form does it have the right values? [20:15] mikelietz: oh I see, the debug in the unserialize [20:15] lildude_home: Nope and yes [20:16] mikelietz: And if you reload the page? [20:16] lildude_home: It works. [20:16] mikelietz: figured as much. [20:16] lildude_home: And if I click the "Close" button and then re-open the "Configure". [20:17] lildude_home: And double submitting works too [20:17] lildude_home: But double submitting is pointless as I know the values are being stored. [20:17] mikelietz: try returning false from serializeNStoreOpts [20:18] mikelietz: ,hw formui [20:18] JibbyBot: mikelietz wiki search for 'formui': http://wiki.habariproject.org/en/Classes/FormUI [20:19] lildude_home: Nope. No diff [20:20] mikelietz: drat. [20:21] mikelietz: I'm not sure what would happen if you added $ui->save(); before the return false, if that would try to save them to the DB (nulled) or just to the form. [20:23] mikelietz: but that might be worth a shot. [20:23] lildude_home: Sadly, no diff [20:23] mikelietz: beyond that I think you might need to post this to -dev, as I am not that well versed in FormUI beyond the ordinary uses of it. [20:25] mikelietz: I don't know when Options::get is read when generating that page, and if there's a way to refresh that without a real reload. [20:25] mikelietz: of course, you could just send a reload header in the success message... [20:26] lildude_home: Hmmmm... that may be a plan [20:27] mikelietz: one other thing to try - what if you comment out the success message? [20:28] lildude_home: Commenting out doesn't work. Just thinking how I'd go about sending the refresh header. Suggestions? [20:29] mikelietz: Hmm. I don't think you can modify the php header output - you may need to refresh it with javascript. [20:29] mikelietz: and let me point out this may be a really, really stupid thing to try. [20:29] mikelietz: but on the other hand, it just may work. [20:30] mikelietz: I don't know if you put an element on the page with an onload to reload if that would work. [20:30] mikelietz: I was just looking around and found this: <input type="button" value="Reload Page" onClick="window.location.reload()"> [20:31] mikelietz: but you'd need to put that on a button, and presumably that would supersede the on_success [20:31] mikelietz: ,seen ringmaster [20:31] JibbyBot: mikelietz: ringmaster was last seen leaving this channel because "" on #habari (2d 6h 50m 20s ago) [20:31] lildude_home: Yup. I think we're heading into the realms of "beat it with a stick and pray". It's getting late now and the wife is starting to huff. I'll post it to -dev and see what the peeps come back with. Thanks for your help. Have a good evening. [20:32] mikelietz: sorry we made no progress. Have a nice night! --- In short, the Utils::debug($options) call is reporting the same options before and after saving my options, even though the database (sqlite) has been updated and reflects the new options. Is this something I'm doing or is this some sort of SQL or other caching taking place? Cheers, Colin -- Colin Seymour Blog: http://www.colinseymour.co.uk Tech Stuff: http://www.lildude.co.uk --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/habari-dev -~----------~----~----~----~------~----~------~--~---
