Page MenuHomePhabricator

Stop supporting external pages when editing and viewing registrations
Closed, ResolvedPublic

Description

We should remove support for interwikis when creating or editing a registration, but still make it possible to display the event page's full title on wikis other than the one where the event page is located. Testing instructions: T307358#7957782

Detailed description

Event registrations are global, and our goal is to make it possible to view, create, and edit them from any wiki, with the event page possibly being on another wiki than the one you're currently on. This requires a decent level of support for external pages within MediaWiki, which isn't quite there. In particular, we have the following use cases:

  1. When you create a registration, you can enter a page title, potentially being on another wiki
  2. Same when you edit a registration; additionally, in this case we should also format the page title (à la getPrefixedText) for the default value of the field
  3. When you query the details of a registration (using this endpoint), one of the elements in the response is the formatted page title
  4. In the "Your events" page, we should provide links to event pages potentially being on another domain; there should also be the formatted page title
  5. Same for the event calendar/agenda that we will build in a future version

Let's start from the places where users can input page titles: these are the CreateEventRegistration and EditEventRegistration special pages. We have two ways to allow external pages there: a single title input field with interwiki support, or two separate fields -- one for the wiki name, and one for the page title as relative to that wiki (without interwiki support). For more details, see T307108. The first solution is not recommended because of limitations with interwiki links (chiefly T306713, and also T307107, since interwikis can point to non-local, non-MediaWiki sites). The second solution is much better, and in the first implementation we could omit the wiki field altogether, hence forcing all pages to be local to the wiki where the registration is created. This would address use case (1.) (CreateEventRegistration).

Now onto the other input, EditEventRegistration. If you're editing the registration from a wiki other than the one where the event page is located, we don't have a way to format the page title. The details of this will be discussed for item (3.), but here the main issue is that we do need both form fields (title and wiki), and we chose to omit the second one for now. We have two options here: a) Display an error message and send the user to the right wiki; b) do implement the wiki field. Option a) is easier to implement and would address this use case; option b) is more ideal, but harder to implement, plus there would be additional limitations outlined below. So let's say that we choose option a) for now. This, together with the same validation implemented for the CreateEventRegistration page, would be enough for (2.).

Now, let's talk about the API for event details. The issue here is that we may have to format the title of a page located on another wiki, having the namespace ID, the page's own name and the wiki it belongs to as our only information. Unfortunately, this doesn't seem to be possible: a wiki cannot reliably access the namespaces of another wiki (T226667). MediaWiki does have something (Site::normalizePageName()) that formats the name of a foreign page by making an HTTP request to the other wiki; however, to use that you need to already know the namespace name + page title, which is exactly the information that we need and don't have. More broadly, IIUC, clients have no way to map a namespace ID to a namespace name via the public API -- this information only exists within MediaWiki. Thus, we cannot format a page title by having only the namespace ID and the page's own name. Once again, we have two options: a) if the page is external, redirect the client to the correct wiki with a 3xx status code; b) store the formatted title in the database when a registration is created or updated. Option (a) is easier but it only shifts the problem to the next use case. Option (b) would possibly work, but it's hacky and less clean. Moreover, if we do (b), we would be able to format the page name in other places, like the EditEventRegistration use case (after the "wiki" field is implemented).

As for the "Your events" page: we do need to show external page here; I think this is pretty much not negotiable: no errors or redirects here. I think the only way to get a formatted page title is option (b) proposed for item (3.): storing it in the database. The same considerations above apply here. Additionally, we need a link. This should be easy to do via Site::getPageUrl, assuming that we have the full page name (and we do, if it's stored in the DB).

Finally, for the event calendar/agenda: it should be 100% the same as "Your events".


Conclusion: storing the full page name in the database seems pretty much necessary and the only option we have. It's a bit hacky, but perhaps acceptable. This would be enough for use cases (3.), (4.), and (5.). It would also be necessary (but not sufficient) for (1.) and (2.), but for those we would additionally need a wiki input field.

Please let me know if I missed any use case and what you think of the above. Thanks!

Event Timeline

One thing I forgot to mention: if we choose to store the full title in the DB, I'm still unsure how that would be represented in the code. Presumably, the full name should be injected into ICampaignsPage objects at construction time; an implication of this is that we can only construct (and format) pages that are either local, or already associated to a registration. I think this would be acceptable, but I'm not 100% sure.

Also, correction: I just realized that for (1) and (2), even the wiki input field wouldn't be sufficient. If the page is external, I don't think we have a way to retrieve the namespace ID.

Change 788389 had a related patch set uploaded (by Daimona Eaytoy; author: Daimona Eaytoy):

[mediawiki/extensions/CampaignEvents@master] [WIP] Store the prefixedtext of pages in the database

https://gerrit.wikimedia.org/r/788389

Thank you for this very detailed and thorough breakdown, @Daimona. You did a great job explaining your thinking, and your recommendations make sense to me. We can discuss it more during our 1:1 tomorrow. Really appreciate the work you have put into this!

Also, correction: I just realized that for (1) and (2), even the wiki input field wouldn't be sufficient. If the page is external, I don't think we have a way to retrieve the namespace ID.

We do! By making an API request (action=query + titles param), we get the ID of the namespace; the problem is more like clients have no way (I think) to use the ID when making requests. Note, I still haven't checked if we can obtain the rest of the data,

Update: @Daimona and I discussed this ticket during our 1:1 and we decided upon the following:

  • For V0, there will be no wiki selector, and all event pages will be created & edited locally
    • In other words, when you (as an organizer) edit registration that you created on Meta-Wiki, you can edit it on Meta-wiki. If you are on another wiki, you cannot edit registration. There is an error that says something like, “This registration was created on X site. Please edit it there.”
  • It would be great to have a project & wiki selector in V1 or V2, but we would need 2 things:
    • A selector of project/wiki (design + engineering would need to work on this)
    • We need to see if it is possible when you enter an external page to obtain information like the namespace ID

@Daimona, I assume we need a ticket for this error handling if the user tries to create/edit registration on a non-local wiki. Correct?

@Daimona, I assume we need a ticket for this error handling if the user tries to create/edit registration on a non-local wiki. Correct?

Maybe? Error handling is already included in the demo patch above

Change 788389 merged by jenkins-bot:

[mediawiki/extensions/CampaignEvents@master] Store the prefixedtext of pages in the database

https://gerrit.wikimedia.org/r/788389

Testing notes

Setup suggestions

  • You should set up a wiki farm with two wikis locally, possibly using CentralAuth as well. Please feel free to ask if you need more information, I remember this not being trivial the last time I did it.
  • The two wikis should use different content languages (set $wgLanguageCode in your LocalSettings.php). Also, I recommend translating the name of the "Event" namespace for the non-English wiki. We don't have translations yet, so you'll have to do it manually. For instance, supposing that your second wiki is in Italian, you would have to edit CampaignEvents.namespaces.php and add
$namespaceNames['it'] = [
	NS_EVENT => 'Evento',
	NS_EVENT_TALK => 'Discussioni_evento',
];

Note that as long as you're logged-in, you can change the interface language back to English just for your account from Special:Preferences#mw-prefsection-personal-i18n.

Specs

  1. Users should be able to create en event registration using Special:CreateEventRegistration for a page on the current wiki;
  2. Users should NOT be able to create en event registration using Special:CreateEventRegistration for a page on another wiki (e.g. using interwikis); (form validation should fail)
  3. Users should be able to edit en event registration using Special:EditEventRegistration if the event page is on the current wiki;
  4. Users should NOT be able to edit en event registration using Special:EditEventRegistration if the event page is not on the current wiki; (i.e., if they open Special:EditEventRegistration/X where "X" is the ID of a registration created on another wiki, there should be an error)
  5. The 4 items above should remain true when using the "Create an event registration" and "Edit an event registration" API endpoints instead of the special pages.
  6. Anyone should be able to obtain details about an event registration using this endpoint, regardless of which wiki you're sending the request to, and which wiki the event page is on. The response should contain the title of the event page, and it should be formatted accordingly to the wiki where the event page is (e.g., the translated name of the "Event" namespace should match)
Daimona renamed this task from Support external pages when editing and viewing registrations to Stop supporting external pages when editing and viewing registrations.May 25 2022, 5:12 PM
Daimona updated the task description. (Show Details)

Specs

  1. Users should be able to create en event registration using Special:CreateEventRegistration for a page on the current wiki;
  2. Users should NOT be able to create en event registration using Special:CreateEventRegistration for a page on another wiki (e.g. using interwikis); (form validation should fail)
  3. Users should be able to edit en event registration using Special:EditEventRegistration if the event page is on the current wiki;
  4. Users should NOT be able to edit en event registration using Special:EditEventRegistration if the event page is not on the current wiki; (i.e., if they open Special:EditEventRegistration/X where "X" is the ID of a registration created on another wiki, there should be an error)
  5. The 4 items above should remain true when using the "Create an event registration" and "Edit an event registration" API endpoints instead of the special pages.

Everything above is working correctly in UI and API. Including screenshots of testing the first four specs above.
1 - Creating event registration

UI:

Screen Recording 2022-07-27 at 12.15.54 AM.mov-242BDEF6-EEFC-48AC-B1EB-DAC06DDE71F3.gif (398×720 px, 954 KB)

API

api event creation.png (1×1 px, 198 KB)

2 - Users should NOT be able to create en event registration for a page on another wiki - (this event Event:Ar-beta-2 does exist without registration enabled on ar betacluster wiki, but is not found on english wiki. It can not be registered on en betacluster wiki, so it is functioning correctly.)

UI:

Screen Shot 2022-07-27 at 12.10.16 AM.png (1×2 px, 395 KB)

API:

ar no event page with this name.png (1×1 px, 252 KB)

API using interwiki syntax:

Screen Shot 2022-07-27 at 12.12.43 AM.png (1×1 px, 253 KB)

3 - Users should be able to edit an event registration using Special:EditEventRegistration if the event page is on the current wiki

UI:

Screen Recording 2022-07-27 at 12.20.54 AM.mov-8043A4B1-4619-4135-BB54-E19EBA3E2AD4.gif (398×720 px, 918 KB)

API:

Screen Shot 2022-07-26 at 5.22.24 PM.png (1×1 px, 232 KB)

4 - Users should NOT be able to edit en event registration using Special:EditEventRegistration if the event page is not on the current wiki

API

Screen Shot 2022-07-27 at 12.37.00 AM.png (1×1 px, 245 KB)

UI using interwiki syntax:

Screen Shot 2022-07-26 at 11.51.17 PM.png (906×1 px, 124 KB)

API using interwiki syntax:

Screen Shot 2022-07-26 at 11.54.44 PM.png (1×1 px, 261 KB)

So, everything is working as expected on specs 1-5. Including the screenshots for the API just to show it functioning correctly, and to show the messages when trying to use interwiki links.


  1. Anyone should be able to obtain details about an event registration using this endpoint, regardless of which wiki you're sending the request to, and which wiki the event page is on. The response should contain the title of the event page, and it should be formatted accordingly to the wiki where the event page is (e.g., the translated name of the "Event" namespace should match)

@Daimona for 6 in the specs above, it does not currently display the event name in the language of the wiki where the event was created on betacluster. In the following example, the event was created on Arabic wiki, and if I hit either of the following endpoints with a GET request:

https://en.wikipedia.beta.wmflabs.org/w/rest.php/campaignevents/v0/event_registration/17

or

https://ar.wikipedia.beta.wmflabs.org//w/rest.php/campaignevents/v0/event_registration/17

it still returns the following from the api call, and does not use the translated name for Event
"event_page": "Event:Ar beta test",

however, it does use the language that the event was created in the UI (Arabic, in this case) in the URL for the event details page if you go here:
https://ar.wikipedia.beta.wmflabs.org/wiki/%D8%AE%D8%A7%D8%B5:EventDetails/17

  1. Anyone should be able to obtain details about an event registration using this endpoint, regardless of which wiki you're sending the request to, and which wiki the event page is on. The response should contain the title of the event page, and it should be formatted accordingly to the wiki where the event page is (e.g., the translated name of the "Event" namespace should match)

@Daimona for 6 in the specs above, it does not currently display the event name in the language of the wiki where the event was created on betacluster.

Yeah, that's actually expected: the namespace name was not translated yet, so it's simply "Event" in all languages. This can not be tested on beta until the translations are added.

I conducted a simple test of trying to edit from the wiki that event was not created on, and the proper error message occurred (see screenshot below). The more full breakdown of testing was outlined by Vaughn, and it is working as expected, so I'm marking this as Done.

Screen Shot 2022-08-30 at 4.10.46 PM.png (644×2 px, 123 KB)