`mediawiki.page.watch.ajax` currently assumes all users have watchlist access (whenever it is loaded onto the frontend), and calls the `action: 'watch'` API unconditionally. It also prevents further propagation of the onClick handler for the watch icon#MinervaNeue displays the watchstar unconditionally to all users, preventing skins or extensions from introducand either uses it as a watchlist client (by submitting their own error handling (nicer than core's).
This affects #minervaneue,action=watch requests) or as a CTA for signing up (see T330518). and means that the CTA drawer added in T330518 doesn't display for temporary users.It also always includes `data-mw=interface` in said watchstar, If `mediawiki.page.watch.ajax` is stopped from processing the onclick event (or at least from propagating its propagation;even when it is not used as an actual watchlist client. a very early return in the JS is sufficienThis means MW Core tries to use it for demonstration purposes)watchlist requests, the CTA draw appearsand shows an useless error message instead of the CTA draw.
There are two options we could select from:
1. Make `mediawiki.page.watch.ajax` aware of user permissions and wrap the call to `$( init )` in `mediawiki.page.watch.ajax.js:428` with a permission check.
1. Use `mw.user.getRights()` (calls the API)
2is can be fixed by including `data-mw=interface` only when the button is supposed to be used for `action=watch` API. Change `mw.user.getRights()` to use a JS config variable rather than API (not sure how expensive fetching permissions on pageview would be).
3.For more details, Introduce a new JS-config just for watchlist needs.
2. Allow extensions / skins to provide their own error handling (instead of core's)see https://gerrit.wikimedia.org/r/c/mediawiki/core/+/953717 (particularly the last comment).