Page MenuHomePhabricator

Uncaught TypeError: Cannot read properties of null (reading 'namespaces') in MobileFrontend when clicking the edit icon if VE is not installed
Closed, ResolvedPublicBUG REPORT

Description

Steps to replicate the issue (include links if applicable):

  • Install MobileFrontend and needed dependencies
  • Make sure not to have VisualEditor installed
  • Go to any page in the mobile version (e.g., useformat=mobile)
  • Click the button to edit the page

What happens?:
The editor does not load, and the following error is logged in the console:

oojs.js:867 Uncaught TypeError: Cannot read properties of null (reading 'namespaces')
    at t.value (mobile.common.js:1:17590)
    at P (mobile.init.js:1:2338)
    at r.eval (mobile.init.js:1:3447)
    at r._matchRoute (mobile.common.js:1:15138)
    at r.eval (mobile.common.js:1:14727)
    at Array.reduce (<anonymous>)
    at r._checkRoute (mobile.common.js:1:14691)
    at OO.EventEmitter.emit (oojs.js:858:12)
    at eval (oojs-router.js:46:11)
    at OO.EventEmitter.emit (oojs.js:858:12)

What should have happened instead?:
The editor should load (without VE).

Software version (skip for WMF-hosted wikis like Wikipedia):
Everything master.

Other information (browser name/version, screenshots, etc.):
VE is an optional dependency to MF, and therefore the latter should work even if the former is not available. The code in question (introduced in r434730, 2023-06-09) is:

isVEVisualAvailable() {
	var config = mw.config.get( 'wgVisualEditorConfig' );
	var visualEditorNamespaces = config.namespaces || [];

	return this.isVEAvailable() &&
		visualEditorNamespaces.indexOf( mw.config.get( 'wgNamespaceNumber' ) ) !== -1;
}

This should be rearranged to return early if isVEAvailable is false.

Event Timeline

Since VE is in the default distribution now, we could also revisit whether MF should just depend on it.

Change 961404 had a related patch set uploaded (by DLynch; author: DLynch):

[mediawiki/extensions/MobileFrontend@master] Don't error when editing if VE isn't installed

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

DLynch moved this task from Backlog to Team:Editing on the MobileFrontend board.
DLynch moved this task from Incoming to Code Review on the Editing-team (Kanban Board) board.

Change 961404 merged by jenkins-bot:

[mediawiki/extensions/MobileFrontend@master] Don't error when editing if VE isn't installed

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