Page MenuHomePhabricator

Error: Call to a member function getId() on null
Closed, ResolvedPublicPRODUCTION ERROR

Description

Error
normalized_message
[{reqId}] {exception_url}   Error: Call to a member function getId() on null
exception.trace
from /srv/mediawiki/php-1.38.0-wmf.13/extensions/GrowthExperiments/includes/Mentorship/MentorPageMentorManager.php(335)
#0 /srv/mediawiki/php-1.38.0-wmf.13/extensions/GrowthExperiments/includes/Mentorship/MentorPageMentorManager.php(345): GrowthExperiments\Mentorship\MentorPageMentorManager->makeCacheKeyWeightedAutoAssignedMentors()
#1 /srv/mediawiki/php-1.38.0-wmf.13/extensions/GrowthExperiments/includes/Mentorship/MentorPageMentorManager.php(379): GrowthExperiments\Mentorship\MentorPageMentorManager->getWeightedAutoAssignedMentors()
#2 /srv/mediawiki/php-1.38.0-wmf.13/extensions/GrowthExperiments/includes/Mentorship/MentorPageMentorManager.php(201): GrowthExperiments\Mentorship\MentorPageMentorManager->getRandomAutoAssignedMentor(User, array)
#3 /srv/mediawiki/php-1.38.0-wmf.13/extensions/GrowthExperiments/includes/Mentorship/MentorPageMentorManager.php(156): GrowthExperiments\Mentorship\MentorPageMentorManager->getRandomAutoAssignedMentorForUserAndRole(User, string)
#4 /srv/mediawiki/php-1.38.0-wmf.13/extensions/GrowthExperiments/includes/Mentorship/MentorPageMentorManager.php(210): GrowthExperiments\Mentorship\MentorPageMentorManager->getMentorForUser(User, string)
#5 /srv/mediawiki/php-1.38.0-wmf.13/extensions/GrowthExperiments/includes/HelpPanelHooks.php(219): GrowthExperiments\Mentorship\MentorPageMentorManager->getMentorForUserSafe(User)
#6 /srv/mediawiki/php-1.38.0-wmf.13/extensions/GrowthExperiments/includes/HelpPanelHooks.php(147): GrowthExperiments\HelpPanelHooks->getMentorData(GrowthExperiments\Config\GrowthExperimentsMultiConfig, User, RequestContext)
#7 /srv/mediawiki/php-1.38.0-wmf.13/includes/HookContainer/HookContainer.php(160): GrowthExperiments\HelpPanelHooks->onBeforePageDisplay(OutputPage, SkinVector)
#8 /srv/mediawiki/php-1.38.0-wmf.13/includes/HookContainer/HookRunner.php(935): MediaWiki\HookContainer\HookContainer->run(string, array, array)
#9 /srv/mediawiki/php-1.38.0-wmf.13/includes/OutputPage.php(2695): MediaWiki\HookContainer\HookRunner->onBeforePageDisplay(OutputPage, SkinVector)
#10 /srv/mediawiki/php-1.38.0-wmf.13/includes/MediaWiki.php(917): OutputPage->output(boolean)
#11 /srv/mediawiki/php-1.38.0-wmf.13/includes/MediaWiki.php(930): MediaWiki::{closure}()
#12 /srv/mediawiki/php-1.38.0-wmf.13/includes/MediaWiki.php(563): MediaWiki->main()
#13 /srv/mediawiki/php-1.38.0-wmf.13/index.php(53): MediaWiki->run()
#14 /srv/mediawiki/php-1.38.0-wmf.13/index.php(46): wfIndexMain()
#15 /srv/mediawiki/w/index.php(3): require(string)
#16 {main}
Impact

Seems to happen solely on cawiki. I am guessing some feature is broken as a result?

Notes

Event Timeline

hashar triaged this task as Unbreak Now! priority.Dec 15 2021, 8:21 PM
hashar created this task.
Restricted Application added a subscriber: Aklapper. · View Herald Transcript

@Zabe is right, that's the cause. I asked releng to rollback train because this stops majority of cawiki newcomers from using cawiki.

I'll come up with a patch to fix the error ASAP.

Change 747606 had a related patch set uploaded (by Hashar; author: Hashar):

[operations/mediawiki-config@master] Revert \"group1 wikis to 1.38.0-wmf.13 refs T293954\"

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

Change 747606 merged by jenkins-bot:

[operations/mediawiki-config@master] Revert \"group1 wikis to 1.38.0-wmf.13 refs T293954\"

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

MediaWiki has been rolled back from group 1 wiki since newcomers were unable to login on cawiki.

Change 747621 had a related patch set uploaded (by Urbanecm; author: Urbanecm):

[mediawiki/extensions/GrowthExperiments@master] MentorPageMentorManager: Do not fail hard with no mentor list configured

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

Change 747484 had a related patch set uploaded (by Urbanecm; author: Urbanecm):

[mediawiki/extensions/GrowthExperiments@wmf/1.38.0-wmf.13] MentorPageMentorManager: Do not fail hard with no mentor list configured

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

Both 'getWeightedAutoAssignedMentors' (line 343) and 'invalidateCache' (line 320) call 'makeCacheKeyWeightedAutoAssignedMentors'. The last one calls the getId function of the function getMentorsPage directly( $this->getMentorsPage()->getId(), line 335 ), without checking whether the MentorsPage exists. This could be unsafe.
In getWeightedAutoAssignedMentors there is a check included to see if $this->getMentorsPage() does not return null, that check is NOT made in invalidateCache. I think it is save to have it checked there as well. Or better, make makeCacheKeyWeightedAutoAssignedMentors save by testing there whether $this->getMentorsPage() does not equal null.

Change 747621 merged by jenkins-bot:

[mediawiki/extensions/GrowthExperiments@master] MentorPageMentorManager: Do not fail hard with no mentor list configured

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

Change 747791 had a related patch set uploaded (by Urbanecm; author: Urbanecm):

[mediawiki/extensions/GrowthExperiments@master] MentorManager: Only invalidate cache when mentor list exists

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

Change 747484 merged by jenkins-bot:

[mediawiki/extensions/GrowthExperiments@wmf/1.38.0-wmf.13] MentorPageMentorManager: Do not fail hard with no mentor list configured

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

Mentioned in SAL (#wikimedia-operations) [2021-12-16T08:31:56Z] <urbanecm@deploy1002> Synchronized php-1.38.0-wmf.13/extensions/GrowthExperiments/: 35c055cead3d240625b76d21aa4e685525ca0d4b: MentorPageMentorManager: Do not fail hard with no mentor list configured (T297827) (duration: 01m 09s)

Hopefully, this should be fixed with the backport deployed. Note I temporarily disabled mentorship at cawiki, so purely pushing the train forward will not be enough to test this by traffic. I will hopefully test with certainity very soon.

Change 747795 had a related patch set uploaded (by Thiemo Kreuz (WMDE); author: Thiemo Kreuz (WMDE)):

[mediawiki/extensions/GrowthExperiments@master] Harden MentorPageMentorManager a bit more

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

Change 747791 merged by jenkins-bot:

[mediawiki/extensions/GrowthExperiments@master] MentorManager: Only invalidate cache when mentor list exists

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

Both 'getWeightedAutoAssignedMentors' (line 343) and 'invalidateCache' (line 320) call 'makeCacheKeyWeightedAutoAssignedMentors'. The last one calls the getId function of the function getMentorsPage directly( $this->getMentorsPage()->getId(), line 335 ), without checking whether the MentorsPage exists. This could be unsafe.
In getWeightedAutoAssignedMentors there is a check included to see if $this->getMentorsPage() does not return null, that check is NOT made in invalidateCache. I think it is save to have it checked there as well. Or better, make makeCacheKeyWeightedAutoAssignedMentors save by testing there whether $this->getMentorsPage() does not equal null.

Thanks for noticing that @RonnieV! This is definitely likely to cause a similar issue in the future. Fortunately, the patch that makes use of the invalidation method is not merged as of now, so this is not as serious as the other issue (for now).

Either way, I uploaded a patch to harden the invalidation patch too, see https://gerrit.wikimedia.org/r/c/mediawiki/extensions/GrowthExperiments/+/747791/.

This is resolved (verified at cawiki, manually promoting it to wmf.13).

Change 747908 had a related patch set uploaded (by Urbanecm; author: Urbanecm):

[mediawiki/extensions/GrowthExperiments@wmf/1.38.0-wmf.13] MentorManager: Only invalidate cache when mentor list exists

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

Change 747908 merged by jenkins-bot:

[mediawiki/extensions/GrowthExperiments@wmf/1.38.0-wmf.13] MentorManager: Only invalidate cache when mentor list exists

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

Mentioned in SAL (#wikimedia-operations) [2021-12-16T19:58:21Z] <urbanecm@deploy1002> Synchronized php-1.38.0-wmf.13/extensions/GrowthExperiments/includes/Mentorship/MentorPageMentorManager.php: b8e64fe189a6a447e68e342ce23cedad6f542df0: MentorManager: Only invalidate cache when mentor list exists (T297827) (duration: 01m 06s)

Change 747795 abandoned by Thiemo Kreuz (WMDE):

[mediawiki/extensions/GrowthExperiments@master] Harden MentorPageMentorManager a bit more

Reason:

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