This topic was marked solved by its starter, on October 7th, 2012, 05:48 PM
Drafts being saved is not shown in QR

Arantor

  • With a Box
  • As long as the planets are turning, as long as the stars are burning, as long as your dreams are coming true...
  • Posts: 13,617
Drafts being saved is not shown in QR
« 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.
  When we unite against a common enemy that attacks our ethos, it nurtures group solidarity. Trolls are sensational, yes, but we keep everyone honest.


Nao

  • With a Box
  • If you say so.....
  • Posts: 12,902
Re: Drafts being saved is not shown in QR
« Reply #1 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...
...« I say wedge wedge (in the butt) »
 « Everyone knows rock attained perfection in 1974. It's a scientific fact. » (Homer Simpson)

Arantor

  • With a Box
  • As long as the planets are turning, as long as the stars are burning, as long as your dreams are coming true...
  • Posts: 13,617
Re: Drafts being saved is not shown in QR
« Reply #2 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.
  When we unite against a common enemy that attacks our ethos, it nurtures group solidarity. Trolls are sensational, yes, but we keep everyone honest.


Nao

  • With a Box
  • If you say so.....
  • Posts: 12,902
Re: Drafts being saved is not shown in QR
« Reply #3 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)
...« I say wedge wedge (in the butt) »
 « Everyone knows rock attained perfection in 1974. It's a scientific fact. » (Homer Simpson)

Arantor

  • With a Box
  • As long as the planets are turning, as long as the stars are burning, as long as your dreams are coming true...
  • Posts: 13,617
Re: Drafts being saved is not shown in QR
« Reply #4 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.
  When we unite against a common enemy that attacks our ethos, it nurtures group solidarity. Trolls are sensational, yes, but we keep everyone honest.


Arantor

  • With a Box
  • As long as the planets are turning, as long as the stars are burning, as long as your dreams are coming true...
  • Posts: 13,617
Re: Drafts being saved is not shown in QR
« Reply #5 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.
  When we unite against a common enemy that attacks our ethos, it nurtures group solidarity. Trolls are sensational, yes, but we keep everyone honest.


Nao

  • With a Box
  • If you say so.....
  • Posts: 12,902
Re: Drafts being saved is not shown in QR
« Reply #6 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...?
...« I say wedge wedge (in the butt) »
 « Everyone knows rock attained perfection in 1974. It's a scientific fact. » (Homer Simpson)

Arantor

  • With a Box
  • As long as the planets are turning, as long as the stars are burning, as long as your dreams are coming true...
  • Posts: 13,617
Re: Drafts being saved is not shown in QR
« Reply #7 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.
  When we unite against a common enemy that attacks our ethos, it nurtures group solidarity. Trolls are sensational, yes, but we keep everyone honest.


Nao

  • With a Box
  • If you say so.....
  • Posts: 12,902
Re: Drafts being saved is not shown in QR
« Reply #8 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...?
...« I say wedge wedge (in the butt) »
 « Everyone knows rock attained perfection in 1974. It's a scientific fact. » (Homer Simpson)

Arantor

  • With a Box
  • As long as the planets are turning, as long as the stars are burning, as long as your dreams are coming true...
  • Posts: 13,617
Re: Drafts being saved is not shown in QR
« Reply #9 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.
  When we unite against a common enemy that attacks our ethos, it nurtures group solidarity. Trolls are sensational, yes, but we keep everyone honest.


Nao

  • With a Box
  • If you say so.....
  • Posts: 12,902
Re: Drafts being saved is not shown in QR
« Reply #10 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.
...« I say wedge wedge (in the butt) »
 « Everyone knows rock attained perfection in 1974. It's a scientific fact. » (Homer Simpson)

Arantor

  • With a Box
  • As long as the planets are turning, as long as the stars are burning, as long as your dreams are coming true...
  • Posts: 13,617
Re: Drafts being saved is not shown in QR
« Reply #11 on April 27th, 2012, 09:11 PM »
I forgot about addQMark :/ It would certainly be cleaner to use that than an inline ternary.
  When we unite against a common enemy that attacks our ethos, it nurtures group solidarity. Trolls are sensational, yes, but we keep everyone honest.


Nao

  • With a Box
  • If you say so.....
  • Posts: 12,902
Re: Drafts being saved is not shown in QR
« Reply #12 on April 27th, 2012, 09:14 PM »
It's a pretend function you know. You didn't forget anything ;)
...« I say wedge wedge (in the butt) »
 « Everyone knows rock attained perfection in 1974. It's a scientific fact. » (Homer Simpson)

Arantor

  • With a Box
  • As long as the planets are turning, as long as the stars are burning, as long as your dreams are coming true...
  • Posts: 13,617
Re: Drafts being saved is not shown in QR
« Reply #13 on April 27th, 2012, 09:21 PM »
>_> I get confused so easily these days.
  When we unite against a common enemy that attacks our ethos, it nurtures group solidarity. Trolls are sensational, yes, but we keep everyone honest.


Nao

  • With a Box
  • If you say so.....
  • Posts: 12,902
Re: Drafts being saved is not shown in QR
« Reply #14 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...?!
...« I say wedge wedge (in the butt) »
 « Everyone knows rock attained perfection in 1974. It's a scientific fact. » (Homer Simpson)