Page MenuHomePhabricator

Unprotected error on accessing `exists` field of `mw.title` object created with an invalid title
Closed, DuplicatePublic

Description

The following Lua module provides a function that currently throws an error on line 6 (title.exists) when it is invoked: Lua error in mw.title.lua at line 209: bad argument #1 to 'pairs' (table expected, got nil).

local p = {}

function p.show(frame)
	local title = mw.title.new("#")
	
	return title.exists
end

return p

This error happens because php.getExpensiveData( t.fullText ) on line 209 of mw.title.lua is nil.

# is an invalid title, and the documentation says that mw.title.new returns nil when supplied an invalid title, so I'd expect title to be nil and the error to be attempt to index a nil value.