Closed Bug 1260197 Opened 8 years ago Closed 8 years ago

Update "publish and keep editing" workflow to report errors when publishing.

Categories

(developer.mozilla.org Graveyard :: Editing, defect)

All
Other
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: jwhitlock, Assigned: shobson)

References

Details

(Keywords: in-triage, Whiteboard: [specification][type:bug])

What did you do?
================
1. On a local dev box, enable Akismet and setup a spam test user (username 'viagra-test-1')
2. Edit the document
3. Click "Save and Keep Editing"

What happened?
==============
A box "Saving changes" appears in blue, then turns green with a smiley face.  The document is not saved.

What should have happened?
==========================
An error about spam content should have been displayed.

Is there anything else we should know?
======================================
Using desktop Safari, the following warnings appear in the console:

[Error] Refused to display 'https://developer-local.allizom.org/en-US/docs/Firefox$edit?iframe=1' in a frame because it set 'X-Frame-Options' to 'DENY'.

Sandbox access violation: Blocked a frame at "https://developer-local.allizom.org" from accessing a frame at "null".  The frame being accessed is sandboxed and lacks the "allow-same-origin" flag.

From the code, other possible validation errors are invalid Slugs (new pages or moved pages) and edit collisions. The code suggests that there was special handling for edit collisions, and similar code may be needed for spam blocked edits:

https://github.com/mozilla/kuma/blob/master/kuma/wiki/views/edit.py#L29
Akismet test username is "viagra-test-123", not "viagra-test-1" - http://blog.akismet.com/2012/07/20/pro-tip-testing-testing/. Also, thanks bug 540.
Blocks: 1188029
Assignee: nobody → shobson
We can't edit the slugs on the page anymore so that's not a problem :)
I've spent several hours working on this and discovered that the current implementation in production is broken. It reports a successful save 100% of the time. 

The way it was implemented was a bit of a hack and is definitely a burden on the maintainability of the code. 

At this point fixing it seems like more trouble than it's worth.

Some statistics:
- From March 12 - April 11 there were 6044 edits published 418 of those used the "Publish and keep editing" button - 7% of edits.
- The button was re-labeled on April 8th at the same time the UI for saving a draft was changed
- In the 2 weeks since renaming "Save and keep editing" to "Publish and keep editing" there has been a 50% drop in usage, to an average of 7 clicks a day.

I have recommended to Kadir that we remove it however he wants to do more investigation before making the final decision.
It turns out that most people don't use the button, but the keyboard short-cut Ctr+S instead. So, we are going to rebind Ctrl+S in bug 1279220. We'll try to fix this feature and re-introduce it in the future.
We have the resource to try to tackles this so we're going to try to tackle this.

Let me restate the problem for those new to the bug:

MDN has a "publish and keep editing" button on the wiki edit and translate pages (not on the new document pages). It reports a successful publish 100% of the time. This is a problem because it leads to lost work in the following instances:
- There is an error with some of the content (for example: the page URL is a duplicate, or the revision comment exceeds the max characters).
- The page is blocked for spam edits.
- The user's session has timed out.
- A "mid-air" collision with other edits.

The current script also uses a custom iframe submission mechanism with a specialized response from the server. We should be using built in pieces from django and jquery to do this in a more stable way.

Ideal work flow:
- User makes changes to document.
- User clicks "publish and keep editing" OR CTRL+S.
- The editing form is disabled.
- The page makes an ajax submission of the revision using jQuery's built in ajax function.
- The page informs the user it is attempting a submission with a blue MDN notification "Publishing changes…"
- The server processes this as an ajax submission and responds with information in JSON format, communicating the status of the save.
- The page reports the status of the save to the user.
- If the publish was successful a green MDN notification should replace the blue one with the message, "Changes published."
- If the publish failed a red MDN notification should replace the blue one with one of the error messages detailed below.
- Either way the form should be re-enabled. (on success the page also needs to update the hidden revision ID )


Generic error message (we don't know what went wrong!):
"Publishing failed. Please copy and paste your changes into a safe place and try submitting the form using the 'Publish' button."

Spam detected (this is copied from spam_error.html, if the <p> tags cause problems we can replace them with <br><br>):
<p>
    {% trans does_this_belong_url=wiki_url('MDN/Contribute/Does_this_belong') %}
    Your submission includes content that may not be suitable for MDN.
    Repeated attempts to submit unsuitable material may result in your
    account being deactivated. See our guide
    “<a href="{{ does_this_belong_url }}">Does this belong on MDN?</a>”
    for details on what constitutes appropriate material.
    {% endtrans %}
</p>
<p>
    {% trans admin_email='mailto:mdn-admins@mozilla.org' %}
    If you believe you’ve received this message by mistake, please
    save a draft of your content and <a href="{{ admin_email }}">
    contact the site administrators</a>.
    {% endtrans %}
</p>

Session timeout:
"Publishing failed. You are not currently signed in. Please use a new tab to sign in and try publishing again."

Mid-air collision:
"Publishing failed. Conflicting edit attempts detected. Please copy and paste your edits to a safe and visit the _revision history_ page to see what was changed before making further edits." (with a link to the history page)

I began work on this fix and my work is visible here: https://github.com/mozilla/kuma/pull/3828/files 

This work maybe be useful as a source of:
- how to trigger the MDN notification system
- best practices in jQuery/ajax submissions
- a more sustainable way of handling submission by ajax in Django (disclaimer: I am not a back-end dev).
Summary: "Save and keep editing" workflow doesn't communicate that edit was blocked due to spam → Update "publish and keep editing" workflow to report errors when publishing.
Commits pushed to master at https://github.com/mozilla/kuma

https://github.com/mozilla/kuma/commit/19d43286c912e2a68a9797705bdf2ff8aa5aeb8e
Fix Bug 1260197 - "Save and keep editing" workflow and errors

Change from iframe submission to ajax submission to have better control over response.

Changed name of form field called "form" to be more descriptive.

https://github.com/mozilla/kuma/commit/889e145e470200be3d6c30d08a97f25844f57544
bug 1260197 - handle save&keep editing edits without errors

https://github.com/mozilla/kuma/commit/b4e5f641e4dfdce5090f2d7aadf865f64d5bb6f3
bug 1260197 - handle spam and midair collision error messages

https://github.com/mozilla/kuma/commit/dee75f9c77a0673b9e103ebd5ec47558dac703fb
bug 1260197 - handle save&keep editing on translations

https://github.com/mozilla/kuma/commit/1a1e2edd77c1523e8e8e42c975a4f479cfc4bd2c
bug 1260197 - handle spam revisions

https://github.com/mozilla/kuma/commit/d291373ffb68a56e354e9298b53018952380cc3c
bug 1260197 - update tests and fix flake8 errors

https://github.com/mozilla/kuma/commit/821c17339dceeddb1ff4d191b3bab623a13d37bb
bug 1260197 - add tests for ajax spam and multiple revisions

https://github.com/mozilla/kuma/commit/bef39a6a8a99f22d204c3c9f41b19fd7e990dc6a
bug 1260197 - remove logging from wiki-edit.js and disable form on ajax submits

https://github.com/mozilla/kuma/commit/98b79b0c5fe006427a0aab40df0f4018f426b97b
bug 1260197 - change button type to prevent multiple POSTs

https://github.com/mozilla/kuma/commit/3b715c40efe31bcd816beb3dcdcab9abed8c31b8
bug 1260197 - minor fixes: semicolon, debugger statements, gettext wrappers...

https://github.com/mozilla/kuma/commit/03114f2f824f5c7e9dbb26e212ce4c580fa08dcf
bug 1260197 - errors are dismissable, cleared out on publish attempts

https://github.com/mozilla/kuma/commit/89ccaae377173b457c2112f72e0b7518d81a884b
bug 1260197 - fix test flags, repeated functionality

https://github.com/mozilla/kuma/commit/630231429c5ee30599e502355413dbc457830da6
bug 1260197 - address feedback on backend code

https://github.com/mozilla/kuma/commit/bc154242228fde428debf629adea658b24aefbc4
bug 1260197 - update tests to match previous code; add tests for untested sections of translate.py

https://github.com/mozilla/kuma/commit/aa1941811103d345d55aa4be484682f7e672f718
Merge pull request #3935 from caktus/1260197-save-and-edit-continued

bug 1260197 - Update "publish and keep editing" workflow
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Product: developer.mozilla.org → developer.mozilla.org Graveyard
You need to log in before you can comment on or make changes to this bug.