Page MenuHomePhabricator

The fragment property of title objects fetched with mw.title.getCurrentTitle persists across #invokes
Closed, ResolvedPublic

Description

Module 1:

local p = {}

function p.main()
	local title = mw.title.getCurrentTitle()
	title.fragment = 'a fragment'
	return 'The fragment is: ' .. title.fragment
end

return p

Module 2:

local p = {}

function p.main()
	local title = mw.title.getCurrentTitle()
	return 'The fragment is: ' .. title.fragment
end

return p

Module invocations:

{{#invoke:Module 1|main}}

{{#invoke:Module 2|main}}

The fragment property persists across the two #invokes, giving the output:

The fragment is: a fragment

The fragment is: a fragment

I've made example modules here and here, and an example invocation here.

This only happens for title objects fetched with mw.title.getCurrentTitle. Fragments don't persist across #invokes for title objects made with mw.title.new, even if the title is for the current page.

Event Timeline

MrStradivarius raised the priority of this task from to High.
MrStradivarius updated the task description. (Show Details)
MrStradivarius added a project: Scribunto.
MrStradivarius subscribed.

Change 226987 had a related patch set uploaded (by Jackmcbarn):
Prevent leaking title fragments across invokes

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

Change 226987 merged by jenkins-bot:
Prevent leaking title fragments across invokes

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

Jackmcbarn claimed this task.