Steps to replicate the issue (include links if applicable):
- As user A (who is registered for an event that has collaborative contributions enabled), make an edit
- As user B, Revdelete the author of the edit (author A)
- As the organizer of the event, using the "Add an edit" button implemented in T403727, try to add that edit to any event
What happens?:
The following uncaught TypeError is thrown:
2025-12-08 21:16:35 08a2c2d906e7 my_wiki: [0ed6824c12f25aa53f0d80fe] /w/rest.php/campaignevents/v0/event_registration/1106/edits/my_wiki/2198 TypeError: MediaWiki\Extension\CampaignEvents\MWEntity\CampaignsCentralUserLookup::newFromUserIdentity(): Argument #1 ($userIdentity) must be of type MediaWiki\User\UserIdentity, null given, called in /var/www/html/w/extensions/CampaignEvents/src/EventContribution/EventContributionValidator.php on line 133
#0 /var/www/html/w/extensions/CampaignEvents/src/EventContribution/EventContributionValidator.php(133): MediaWiki\Extension\CampaignEvents\MWEntity\CampaignsCentralUserLookup->newFromUserIdentity()
#1 /var/www/html/w/extensions/CampaignEvents/src/Rest/EventContributionsHandler.php(47): MediaWiki\Extension\CampaignEvents\EventContribution\EventContributionValidator->validateAndSchedule()
#2 /var/www/html/w/includes/Rest/SimpleHandler.php(41): MediaWiki\Extension\CampaignEvents\Rest\EventContributionsHandler->run()
#3 /var/www/html/w/includes/Rest/Module/Module.php(452): MediaWiki\Rest\SimpleHandler->execute()
#4 /var/www/html/w/includes/Rest/Module/Module.php(301): MediaWiki\Rest\Module\Module->executeHandler()
#5 /var/www/html/w/includes/Rest/Router.php(485): MediaWiki\Rest\Module\Module->execute()
#6 /var/www/html/w/includes/Rest/Router.php(444): MediaWiki\Rest\Router->doExecute()
#7 /var/www/html/w/includes/Rest/EntryPoint.php(207): MediaWiki\Rest\Router->execute()
#8 /var/www/html/w/includes/MediaWikiEntryPoint.php(184): MediaWiki\Rest\EntryPoint->execute()
#9 /var/www/html/w/rest.php(25): MediaWiki\MediaWikiEntryPoint->run()
#10 {main}That's because Revision::getUser() can return null when the revision's author is deleted (we are using FOR_PUBLIC in the audience check, which is correct, so any kind of deletion will do). However, the code assumes it to be non-null.
What should have happened instead?:
Not sure... Perhaps we should fail with a user-friendly error, or maybe we could also allow adding the revision anyway (the record will be semi-deleted in EventContributionComputeMetrics anyway, based on the revision visibility). I believe this is a product question.
The association should go through anyway (and the user's name will later show up as "deleted user"), see T412063#11469854.
The association should fail with the following error message: This edit has been deleted and cannot be associated with the event.. See T412063#11526133
Other information (browser name/version, screenshots, etc.):
Note that this is already reproducible on current master using the API endpoint for associating edits. (And potentially, also making an edit, leaving the association dialog open, revdeleting the edit in a different tab, then confirming the association).