Page MenuHomePhabricator

[M] [betalabs] MediaSearch:TypeError: Cannot read property 'replace' of undefined
Closed, ResolvedPublic

Description

The Console displays TypeError: Cannot read property 'replace' of undefined when the following search is performed in commons betalabs - https://commons.wikimedia.beta.wmflabs.org/wiki/Special:MediaSearch?type=bitmap&q=street&mimeType=jpeg
The error seems to refer to the following:
return this.imageinfo[0].thumburl.replace('/' + oldWidth + 'px-', '/' + newWidth + 'px-');

main: "resources/src/vue/index.js",
    files: {
        "resources/src/vue/index.js": function(require, module) {
            (function() {
                var Vue = require('../../lib/vue/vue.js');
                Vue.use(require('./i18n.js'));
                Vue.config.errorHandler = function(error) {
                    mw.errorLogger.logError(error, 'error.vue');
                    mw.log.error(error);
                }
                ;
                module.exports = Vue;
            }());

Notes:

  • the error is present only in beta and only for the mentioned above search (I could not find any other search queries to reproduce the error).
  • no impact on the user experience

Acceptance Criteria:

  • Rewrite code to drop results if image thumbnail data is missing in both PHP and JS

Event Timeline

CBogen renamed this task from [betalabs] MediaSearch:TypeError: Cannot read property 'replace' of undefined to [M] [betalabs] MediaSearch:TypeError: Cannot read property 'replace' of undefined.Feb 24 2021, 5:37 PM
CBogen updated the task description. (Show Details)

Change 690031 had a related patch set uploaded (by Anne Tomasevich; author: Anne Tomasevich):

[mediawiki/extensions/MediaSearch@master] Check for thumbnail url before running .replace()

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

Change 690031 merged by jenkins-bot:

[mediawiki/extensions/MediaSearch@master] Check for thumbnail url before running .replace()

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