Page MenuHomePhabricator

[betalabs] MediaSearch - white spaces trigger TypeError: Cannot read property 'length' of null
Closed, ResolvedPublicBUG REPORT

Description

Steps to Reproduce:

  1. On Special:MediaSearch enter couple of white spaces into the search box
  2. Without even pressing Search button, the search field will display:

Screen Shot 2020-08-11 at 5.59.52 PM.png (478×881 px, 40 KB)

The Console error:
TypeError: Cannot read property 'length' of null
at a.getLookupResults

coming from

function Ue(e, t, n) {
                if (!z && !V || "undefined" == typeof console)
                    throw e;
                console.error(e)
            }

Note: the production wmf.3 does not display this issue - below is the screenshot with white spaces entered into the Search field - no visible reaction to users which is a correct behavior.

Screen Shot 2020-08-11 at 6.00.00 PM.png (397×782 px, 33 KB)

Event Timeline

Change 620108 had a related patch set uploaded (by Anne Tomasevich; owner: Anne Tomasevich):
[mediawiki/extensions/WikibaseMediaInfo@master] Trim whitespace from input before fetching autocomplete results

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

Change 620108 merged by jenkins-bot:
[mediawiki/extensions/WikibaseMediaInfo@master] Trim whitespace from input before fetching autocomplete results

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

@AnneT - it's still complaining on the following:

words = input.match(/[^\s]+/g).length;
                       inputRegex = new RegExp('^' + new Array(words + 1).join('[^\\s]+\\s*'), 'i');
                       this.doLookupRequest(input).then(function(results) {....

Hey @Etonkovidova, the fix for this just got merged today and it looks like it's not up on beta Commons yet

Hey @Etonkovidova, the fix for this just got merged today and it looks like it's not up on beta Commons yet

That what I was thinking (and waiting) - thx, @AnneT!