Page MenuHomePhabricator

Add JavaScript variable for whether user can edit the page
Closed, ResolvedPublic


This will make it easier for extensions and gadgets to determine if the current user can edit the current page.

Right now, you either have to hack it by looking for an edit tab, or try to figure it out from wgRestrictionEdit and wgUserGroups. But wgRestrictionEdit has weird things like MediaWiki pages being an empty array when logically it should be ["sysop"]), and doesn't take into account important features like cascading protections and TitleBlacklist.

I think the right way may be to use Title::userCan.

Version: 1.21.x
Severity: enhancement
See Also:



Event Timeline

bzimport raised the priority of this task from to Medium.Nov 22 2014, 1:31 AM
bzimport set Reference to bz43790.

Definitely useful. Use Title::quickUserCan( 'edit' ) which sets $doExpensiveQueries false to skip "potentially expensive cascading permission checks". Comment says "May provide false positives, but should never provide a false negative", maybe name JS variable wcsUserCanProbablyEdit (* wikipedia client-side, I need to make a separate proposal).

Gerrit at . I used the name wgIsProbablyEditable, since I did go with quickUserCan (same as SkinTemplate).

Change 65009 merged by jenkins-bot:
Add wgIsProbablyEditable for editability based on quickUserCan.