Page MenuHomePhabricator

postEdit event has amnesia
Closed, ResolvedPublic

Description

for user code, the postEdit event never fires.
this is unexpected.: when user code hooks document.ready, or 'wikipage.content' events, the expectation is that if the event was fired before user code hooked it, the hooked function will be called immediately.

postEdit does not behave this way, and it should.

(there is a workaround: examine global variable wgPostEdit,, but we should not have to resort to this).

REPRODUCTION
add to common.js the following code:

mw.hook( 'postEdit' ).add( function() { alert( 'postEdit event was triggered!' ); } );

EXPECTED RESULT:
whenever the user with this code saves a page, an alert will be shown

ACTUAL RESULT:
nada.

in contrast, similar code for 'wikipage.content' event, *does* trigger.

peace.

Event Timeline

Hi,

thanks for your report. Unfortunately, I can't reproduce the problem. I've put the code inside my MediaWiki:Common.js, and edited a page afterwards (with different modi, like fast connection, slow connection, bypassing cache, with browser cache) and the hook always fired.

Florian edited projects, added JavaScript; removed MediaWiki-extensions-PostEdit.

Hi,

thanks for your report. Unfortunately, I can't reproduce the problem. I've put the code inside my MediaWiki:Common.js, and edited a page afterwards (with different modi, like fast connection, slow connection, bypassing cache, with browser cache) and the hook always fired.

confirmed.
i don't think i was hallucinating - it really *didn't* work when i tested it (in hewiki, maybe in mw also), but now it does.
maybe it was a hickup, and maybe something else. thanks for testing this.

closing the ticket now.

peace.

Great, thanks for the feedback! :)

@Florian

sorry for the noise: the brain-fart was when i marked this "invalid".

let me explain:
yes, if you register your handler in your personal common.js, it <s>will</s> might trigger (depending on load order). the problem is that it highly dependent on order of actions: of instance, if you call mw.loader.load( some script ), which happens asynchronously, and "some script" finish loading after the event was fired, your handler will not be called. this is the "amnesia" i was talking about.

peace.

REPRODUCTION

  1. save a wiki page
  2. open browser's console
  3. verify mw.config.get('wgPostEdit') returns true
  4. type in console mw.hook( 'wikipage.content' ).add(alert)
  5. notice an alert is fired
  6. type in console mw.hook( 'postEdit' ).add(alert)
  7. notice no alert fired

this is the "amnesia" a was talking about.

matmarex subscribed.

This works as expected for me today. No idea what was the cause of the problem, or when it was fixed.