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 updated the task description. (Show Details)
MrStradivarius raised the priority of this task from to High.
MrStradivarius added a subscriber: MrStradivarius.
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptJul 25 2015, 3:45 PM
MrStradivarius set Security to None.

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 closed this task as Resolved.Jul 27 2015, 2:58 PM
Jackmcbarn claimed this task.