Public area => Bug reports => The Pub => Archived fixes => Topic started by: Arantor on April 25th, 2012, 08:38 PM
Title: Drafts being saved is not shown in QR
Post by: Arantor on April 25th, 2012, 08:38 PM
I now have 53 pages of drafts (at 15 per page!) that have been saved where the AJAX call is being made to save a draft but the response is not properly being handled, so not only does the 'remove draft' button not appear, but the draft is also not purged on posting because the id is never injected into the form.
Title: Re: Drafts being saved is not shown in QR
Post by: Nao on April 26th, 2012, 04:32 PM
Crap. Does that mean it's broken again...? I have 15 pages of drafts myself, and it looks like drafts aren't deleted when they should. I have plenty of versions of my last 'Welcoming new Wedgers' post being written in various stages...
Title: Re: Drafts being saved is not shown in QR
Post by: Arantor on April 26th, 2012, 07:05 PM
Yes, yes it is broken. It's not broken when starting a new topic, only in quick reply.
I'll investigate shortly.
Title: Re: Drafts being saved is not shown in QR
Post by: Nao on April 26th, 2012, 09:52 PM
I turned the qr object into a single object recently but I don't remember if it was yesterday or much much earlier. When did the problem start? I'm sure it's down to one of my changes. Bad Nao... Always obsessed with saving extra bytes ;) (although as a whole it does make wedge faster than the equivalent competition :P)
Title: Re: Drafts being saved is not shown in QR
Post by: Arantor on April 26th, 2012, 10:04 PM
The oldest draft I have is 19th April, and that's 7 days old, so it's possible that it's even older than that, because only 7 days' worth are kept.
Title: Re: Drafts being saved is not shown in QR
Post by: Arantor on April 27th, 2012, 06:20 PM
Well, it's working entirely as expected locally, but here there's a problem causing it to break. The POST is made to wedge.org/pub/bugs/do/post2/;xml with all the proper form data, and there's a 302 header pushed back (though the proper behind-the-scenes occurs) and it redirects to the full URL behind the scenes.
It then doesn't return the correct data and creates errors as a result - there have been 6 attempts while writing this post and all went wrong and all caused JS errors in response.
Title: Re: Drafts being saved is not shown in QR
Post by: Nao on April 27th, 2012, 06:30 PM
Meaning thereis a bug in how purls handles board+actions. Or maybe your draft code adds ;XML directly to the URL, expecting it to have a ? In it...?
Title: Re: Drafts being saved is not shown in QR
Post by: Arantor on April 27th, 2012, 06:51 PM
Yes it does. It takes the URL that the form would be submitted to anyway and pokes ;xml onto the end. I'll get it to check for ? first before it does that.
Posted: April 27th, 2012, 06:34 PM
I think this should have been fixed in r1565.
Title: Re: Drafts being saved is not shown in QR
Post by: Nao on April 27th, 2012, 08:47 PM
I guess this is exactly the kind of thing that we should avoid... And I'm pretty sure there are other situations where this happens as well. Perhaps simply have a 'generic' function to check and add a ? or ; at the end of a URL, a bit like the we_scripturlsomething function...?
Title: Re: Drafts being saved is not shown in QR
Post by: Arantor on April 27th, 2012, 08:58 PM
There aren't many places we do that in JS, actually from what I can remember. Hmm, a generic function could be used, I guess.
Title: Re: Drafts being saved is not shown in QR
Post by: Nao on April 27th, 2012, 09:01 PM
Yeah I had a look at your code and, hmm... (sUrl.indexOf('?') > 0 ? ';' : '?') could be replaced by addQMark(sUrl), where we return ? or ; depending on whether ? is in the URL... It'd be a slightly shorter call but I don't know how shorter it would be in the final gzipped code... Probably not at all.
Title: Re: Drafts being saved is not shown in QR
Post by: Arantor on April 27th, 2012, 09:11 PM
I forgot about addQMark :/ It would certainly be cleaner to use that than an inline ternary.
Title: Re: Drafts being saved is not shown in QR
Post by: Nao on April 27th, 2012, 09:14 PM
It's a pretend function you know. You didn't forget anything ;)
Title: Re: Drafts being saved is not shown in QR
Post by: Arantor on April 27th, 2012, 09:21 PM
>_> I get confused so easily these days.
Title: Re: Drafts being saved is not shown in QR
Post by: Nao on April 28th, 2012, 01:39 AM
So... I did a bit of a (tiny) rewrite to we_prepareScriptUrl(), which is 'the' function that did what I remembered: it takes the script URL and adds a question mark if not there, or a semicolon if a question mark is found. So I renamed it to the more generic 'weUrl' and added a parameter to specify the original URL. If it's empty, it uses we_script. (Obviously!) I'm a bit annoyed by the function itself... At some point it uses url.charAt(url.length - 1), when I could use url.substr(-1) (and save 6 bytes off the gzipped size...), but it's not supported in IE (even 10!). So I switched to url[url.length-1] but I remembered that we discussed this at some point and gave up on it because of poor support... However, I just tried in IE6 (emulated in a virtual box) and it frigging works...?!
Title: Re: Drafts being saved is not shown in QR
Post by: Arantor on April 28th, 2012, 01:43 AM
Yeah, IE supports that but others don't >_<
I think we'll have to deal with this on a case by case basis in the JS, really, and just look for cases where we manually push ;xml onto the URL from JS where we might not otherwise.
Title: Re: Drafts being saved is not shown in QR
Post by: live627 on April 28th, 2012, 09:14 AM
Couldn't you pick a different spot to post? Seems a bit... out of place.
Title: Re: Drafts being saved is not shown in QR
Post by: Nao on April 28th, 2012, 10:36 AM
Ah, the human spammers...
Anyway, Pete -- I checked all ;xml additions, and apart from ajaxRating (which always deals with a long URL that has no chance to fail), it'll always use weUrl()/we_prepareScriptUrl() as a basis anyway. Ah ah, found a way to get rid of my .charAt... Using .match instead :) (or .test, FWIW... Same bytesize results. Saves over 10 bytes compared to the charAt version, and this in just one line of code, eh...)
Title: Re: Drafts being saved is not shown in QR
Post by: Arantor on April 28th, 2012, 02:14 PM