Page MenuHomePhabricator

Add wgPostEdit as core JavaScript variable
Closed, ResolvedPublic

Description

I think it is worth adding a boolean variable wgPostEdit, which is true if and only if the user just saved the article.

Right now, this is implemented in https://www.mediawiki.org/wiki/Extension:PostEdit , but the real point of the extension is to show a visual notification. Other extensions ideally shouldn't have to depend on all that just to get a boolean. E3Experiments currently uses it implicitly (I will temporarily make it an explicit dependency), and I'm sure there are other extensions and gadgets that could use it.

It looks like this could maybe be implemented in attemptSave, but I'm open to suggestions.


Version: 1.21.x
Severity: enhancement
See Also:
https://bugzilla.wikimedia.org/show_bug.cgi?id=42939

Details

Reference
bz43270

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 22 2014, 12:56 AM
bzimport set Reference to bz43270.

I mean "just saved a page", not specifically an article.

GuidedTour also uses this.

I'm going to start implementing this.

Initial version at https://gerrit.wikimedia.org/r/#/c/50480/, ready to start review.

It's basically similar to the Extension:PostEdit implementation of the variable. However, it uses the revision ID to avoid conflicts even if you save the same article twice in close succession (e.g. two sections).

It also uses '/' for the path rather than exporting that.

I've documented this at https://www.mediawiki.org/wiki/Manual:Interface/JavaScript#Page-specific

The documentation notes that you should depend on 'mediawiki.action.view.postEdit'. Even though the module will always be added on views, I believe this is necessary to avoid race conditions.

Loading the module when they did not just save should not cause problems. I've just submitted https://gerrit.wikimedia.org/r/#/c/51885/ to guarantee the variable can never be set on a non-view.