Closed georgebarnick closed 10 years ago
This seems to be happening on Deepsea too.
I found the problem. The cookie set to add them has the wrong expiration date. I would fix it, but I'm not sure where the code is for it. Does anyone know?
@seaside98: mediawiki.action.view.postEdit.js
Where is the code for submitting an edit? That is really the root of the problem. There is no need for the cookie to be avaliable in all the subdomains.
@seaside98: EditPage.php?
Ok, on line 1214 of EditPage.php a cookie is set. This cookie (on brickimedia) has the domain property of ".brickimedia.org". This value has to be referenced in the postEdit.js when deleting the cookie. It would be easy enough to fix for Brickimedia, but I don't know how it would affect others that don't have subdomains.
The easiest solution would be to edit postEdit.js and add in the domain. I don't know if it will work universally though. Line 70 should be:
$.cookie( cookieKey, null, { path: '/', domain: wgServer.replace(/.*?([^\.\/]*\.[^\.]*)$/, '.$1') } );
I used regex to break apart the wgServer variable and make sure no subdomains get matched. I know that this will work on Brickimedia, I just can't be absolutely certain about other wikis.
Yeah, it must be using $wgCookieDomain, which is set in LocalSettings_private.php on our server. Can a cookie fix be made front-end with JavaScript? We don't really want to have any core since Brickimedia (unlike Wikia) uses completely pure MediaWiki.
Yes, easily. Where should I add it?
First I'd suggest adding it to Special:MyPage/common.js to see if it works, and then I can add it to MediaWiki:Global.js once you have it working.
// Remove cookie after edit var config = mw.config.get( [ 'wgAction', 'wgCookiePrefix', 'wgCurRevisionId' ] ), cookieKey = config.wgCookiePrefix + 'PostEditRevision' + config.wgCurRevisionId; if ( config.wgAction === 'view' && $.cookie( cookieKey ) === '1' ) { $.cookie( cookieKey, null, { path: '/', domain: '.brickimedia.org' } ); }It runs great in the console, and there is no complex JS that would prevent it from working on the Global.js.
I've added that to MediaWiki:Global.js, however I don't seem to get the "Your edit was saved" box at all now, when it should trigger.
Hmm. Then lets make it wait to fire until the whole page has loaded.
// Remove cookie after edit $(window).bind('load', function() { var config = mw.config.get( [ 'wgAction', 'wgCookiePrefix', 'wgCurRevisionId' ] ), cookieKey = config.wgCookiePrefix + 'PostEditRevision' + config.wgCurRevisionId; if ( config.wgAction === 'view' && $.cookie( cookieKey ) === '1' ) { $.cookie( cookieKey, null, { path: '/', domain: '.brickimedia.org' } ); } });
Works great! Thanks for the fix, Seaside! :smile:
After saving an edit to a page, then leaving the page, and later returning to the page, the "Your edit was saved" dialog is still there, when it shouldn't be. I've only tried this in the Refreshed skin so far.