Page MenuHomePhabricator

Default temporary user config causes a JavaScript error
Closed, ResolvedPublic

Description

Problem

By default, $wgAutoCreateTempUser['matchPatterns'] is null.

Visiting Special:Contributions/<tempuser> with the defaults causes the error: TypeError: Cannot read properties of null (reading 'length')

The problem is here in mediawiki.util/util.js, isTemporaryUser():

https://gerrit.wikimedia.org/g/mediawiki/core/+/a5c1fc67ee53eeea2f363abcf7b38aabb4ec6973/resources/src/mediawiki.util/util.js#1158

Although this isn't deployed to production yet, it would be good to fix soon, since it's difficult for developers to work with.

Solution

In PHP, in RealTempUserConfig, the array of match patterns is automatically set to an array containing $wgAutoCreateTempUser['genPattern'] if it is null:

https://gerrit.wikimedia.org/g/mediawiki/core/+/8e8093d627ec92fc7a1d9226dcab8135f09c25be/includes/user/TempUser/RealTempUserConfig.php#73

Event Timeline

Change #1047932 had a related patch set uploaded (by Tchanders; author: Tchanders):

[mediawiki/core@master] Correctly set $wgAutoCreateTempUser['matchPattern'] config in JS

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

Change #1047932 merged by jenkins-bot:

[mediawiki/core@master] Correctly set $wgAutoCreateTempUser['matchPattern'] config in JS

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

Looks like for QA, the steps are:

  • Visiting Special:Contributions/<tempuser> with default MW core configuration for temp accounts (specifically that $wgAutoCreateTempUser['matchPatterns'] = null), you should not see the error TypeError: Cannot read properties of null (reading 'length') in browser console

Looks like for QA, the steps are:

  • Visiting Special:Contributions/<tempuser> with default MW core configuration for temp accounts (specifically that $wgAutoCreateTempUser['matchPatterns'] = null), you should not see the error TypeError: Cannot read properties of null (reading 'length') in browser console

Thanks @kostajh, that's right.

To trigger the error, you'll also need to do the following:

  • Load the CheckUser extension
  • Log in as a user with the checkuser-temporary-account-no-preference right (e.g. a CheckUser)
  • Visit Special:CheckUser/<tempaccount>

Before the fix, you'd see the error and no "reveal IP buttons". After the fix, you should see the "reveal IP" buttons and no errors.

Djackson-ctr subscribed.

I have verified the new code has been implemented and is functioning and displaying as expected, thank you both for the QA steps, its greatly appreciated.

image.png (375×1 px, 39 KB)